Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to sort and display database results with MySQL/PHP
    primarykey
    data
    text
    <p>I am using PHP to sort items on my website into different locations/different divs. I have a script in each div where I want the results to be displayed So if there are 4 divs there are 4 scripts. (4 categories) Each script has a query in the head of my page.</p> <p>MySQL query for category/div 1</p> <pre><code>$sql_category1 = &lt;&lt;&lt;SQL SELECT * FROM `list_items` WHERE `category` = 1 ORDER BY `rating` ASC; SQL; if(!$category1 = $db-&gt;query($sql_category1 )){ die('There was an error running the query [' . $db-&gt;error . ']'); } </code></pre> <p>My PHP for category/div 1:</p> <pre><code>&lt;?php while($row = $category1-&gt;fetch_assoc()) { '&lt;div class="list-item-container"&gt;' . '&lt;a href="' . $row['url'] . '"&gt;&lt;img title="' . $row['title'] . '" class="favicon" src="http://www.google.com/s2/favicons?domain='. $row['fav_url'] . '" /&gt;&lt;/a&gt;' . '&lt;/div&gt;'; } ?&gt; </code></pre> <p>My goal: When i am entering data into the table and there are two items that can be classified as two different things, so two different categories, I have to make two copies of it. This way a item will appear in both categories. Same item two different categories. I give one of the items a category value of 1 and the other item a category value of 2.</p> <p>Rather than making two separate entries of the same item is there a way that I can give that item two separate category values? This way the item will appear in both categories when my scripts run and sort them.</p> <p>I tried 1,2 1:2 and 1;2 as the value of the item. Tho im sure it's not even close to that.</p> <p>Thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    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.
    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