Note that there are some explanatory texts on larger screens.

plurals
  1. POUse php and sql to make an action url per item id
    primarykey
    data
    text
    <p>I am trying to make page in php/html that will display a "product's details." I have it displaying the icon and the link to the "details page," but it will not display ONLY one item on the "details page." Currently, the product's page (where the icon and the link are) will link to the "details page" just fine. However, when the page loads it loads every item in the sql database that has an 'ID.' I expected it to only take the item's id and display the page related to that item, however I received a cluster of them all... The code I have is what follows. I am currently trying to learn PHP so please if I make an error, a really bad one like something that isn't efficient. Please post the more efficient way of doing it. I am learning it the way I was taught at school.</p> <pre><code> &lt;?php //This page display a topic include('admin/variable.php'); if(isset($_GET['id'])) { $id = intval($_GET['id']); $dn1 = mysql_fetch_array(mysql_query('select c.id, c.name, c.description, c.price, c.quantity, c.itemID, c.imgName, c.position, (select count(t.id) from topics as t where t.parent=c.id and t.id2=1) as topics, (select count(t2.id) from topics as t2 where t2.parent=c.id and t2.id2!=1) as replies from categories as c group by c.id order by c.position asc')); if($dn1['id']&gt;0) { ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;link href="&lt;?php echo $design; ?&gt;/style.css" rel="stylesheet" title="Style" /&gt; &lt;title&gt;&lt;?php echo htmlentities($dn1['name'], ENT_QUOTES, 'UTF-8'); ?&gt; - &lt;?php echo htmlentities($dn1['itemID'], ENT_QUOTES, 'UTF-8'); ?&gt; - KB Computers&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="header"&gt; &lt;a href="&lt;?php echo $url_home; ?&gt;"&gt;&lt;img src="&lt;?php echo $design; ?&gt;/images/logo.png" alt="Forum" /&gt;&lt;/a&gt; &lt;/div&gt; &lt;div class="Content"&gt; &lt;?php ?&gt; &lt;h1&gt;&lt;?php echo $dn1['name']; ?&gt;&lt;/h1&gt; &lt;?php $dn2 = mysql_query('select c.id, c.name, c.description, c.price, c.quantity, c.itemID, c.imgName, c.position, c.position, (select count(t.id) from topics as t where c.parent=c.id and t.id2=1) as topics, (select count(t2.id) from topics as t2 where t2.parent=c.id and t2.id2!=1) as replies from categories as c group by c.id WHERE c.id = ' . $id .' order by c.position asc'); ////////////////////////////////////////////////////////// while($dnn2 = mysql_fetch_array($dn2)) //This is line 30! ////////////////////////////////////////////////////////// { $parent = $dnn2['parent']; if(isset($_GET['id'])) { if($_GET['id'] == $parent){ ?&gt; &lt;div id="thing"&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt;&lt;?php echo $dnn2['imgName']; ?&gt;&lt;/th&gt; &lt;/tr&gt; &lt;br /&gt; &lt;tr&gt; &lt;th&gt;&lt;?php echo $dnn2['price']; ?&gt;&lt;/th&gt; &lt;/tr&gt; &lt;br /&gt; &lt;tr&gt; &lt;th&gt; &lt;?php echo $dnn2['description']; ?&gt;&lt;/th&gt; &lt;/tr&gt; &lt;br /&gt; &lt;tr&gt; &lt;th&gt;&lt;?php echo $dnn2['itemID']; ?&gt;&lt;/th&gt; &lt;/tr&gt; &lt;?php if(isset($_SEESION['username']) and $_SESSION['username'] == $admin){?&gt;&lt;div class="edit"&gt;&lt;a href="edit_product.php?id=&lt;?php echo $id; ?&gt;&amp;id2=&lt;?php echo $dnn2['itemID']; ?&gt;"&gt;&lt;img src="&lt;?php echo $design; ?&gt;/images/edic.png" alt="Edit" /&gt;&lt;/a&gt;&lt;/div&gt; &lt;?php } ?&gt; &lt;/table&gt;&lt;/div&gt; &lt;?php }else{echo 'The parent and id values are not the same.';} }} ?&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; &lt;?php } else { echo '&lt;h2&gt;This topic doesn\'t exisc.&lt;/h2&gt;'; } } else { echo '&lt;h2&gt;The ID of this topic is not defined.&lt;/h2&gt;'; } ?&gt; </code></pre>
    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.
 

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