Note that there are some explanatory texts on larger screens.

plurals
  1. POextract icon for each tag from database
    primarykey
    data
    text
    <p>I want to display icons for each tag, just like Stackoverflow does. <img src="https://i.stack.imgur.com/2jVIx.jpg" alt="Heroku"> <img src="https://i.stack.imgur.com/RwvIT.jpg" alt="Android"> <img src="https://i.stack.imgur.com/WVG2m.jpg" alt="Jetty"></p> <p>There are 2 tables related, table_icon and table_event.</p> <p>table_event is for recording the events happened, of course tags to each event; table_tag is for storing tags and icons to them.</p> <p>Here's the structure of table_icon:</p> <pre><code>tag_id tag_name icon (an url to an img) </code></pre> <p>Here's the structure of table_event:</p> <pre><code>event_id name modtime tag </code></pre> <p>In table_event, tag is stored "tag1,tag2,tag3" in tag cell.</p> <p>To make it clearer, Here's an example - </p> <p>Event: "Kobe Got Hurt", related tags: Kobe, Lakers, Injure</p> <p>table_event:</p> <pre><code>event_id ---- 1 name -------- Kobe Bryant got hurt modtime ----- Mar. 13, 2013 tag --------- Kobe,Lakers,injure </code></pre> <p>Corresponding table_tag: (say we have those data in table_tag before hand)</p> <pre><code>tag_id ------ 24 tag_name ---- Kobe icon -------- .../icon/kobe.png tag_id ------ 123 tag_name ---- Lakers icon -------- .../icon/NBA_team_lakers.png tag_id ------ 36 tag_name ---- injure icon -------- .../icon/red_cross.png </code></pre> <p>This is how I extract each tag in PHP:</p> <pre><code>... // Link to Db and table and call smarty. $t_sql = mysql_query("SELECT * FROM event WHERE 1"); $id = array(); $name = array(); $tag = array(); $icon = array(); while($t_row = mysql_fetch_array($t_sql)){ array_push($id, $t_row['event_id']); array_push($name, $t_row['name']); $tag_array = explode(',', $t_row['tag']); array_push($tag, $tag_array); // Don't know how to extract icon for each tag. } $smarty-&gt;assign('tid', $tid); $smarty-&gt;assign('name', $name); $smarty-&gt;assign('tag', $tag); $smarty-&gt;display('event.html'); </code></pre> <p>Any suggestion? Thx in advance!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload