Forum Moderators: coopster

Message Too Old, No Replies

Passing $id

         

dkin

8:13 pm on Jun 19, 2004 (gmt 0)

10+ Year Member



I have this script.


function results(){
$result = mysql_query ("SELECT * FROM nuke_item_database
WHERE Item_Name LIKE '$Item_Name%' order by id Desc LIMIT 10
");

if ($Item_Name == "");
{$Item_Name = '%';};

if ($row = mysql_fetch_array($result)) {

do {

print ("<tr align=\"center\"><td width=\"100\" align=\"center\">");
print ("<a href=\"modules.php?name=$module_name&item_name&id=$id\">");
print $row["Item_Name"];
print ("</a>\n");
print ("</td>");
print ("<td width=\"30\" align=\"center\">");
print $row["Item_Level"];
print ("</td>");
print ("<td width=\"70\" align=\"center\">");
print $row["Item_Slot"];
print ("</td>");
print ("<td width=\"100\" align=\"center\">");
print $row["Classes"];
print ("</td>");
print ("<td width=\"100\" align=\"center\">");
print $row["Races"];
print ("</td>");
print ("</tr>");
} while($row = mysql_fetch_array($result));

}
else {print "Sorry, no records were found!";}
}

But I want to have something like "WHERE id=$id" so I can make the item names links. where would I stick that code?

ergophobe

8:50 pm on Jun 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




print ("<a href=\"modules.php?name=$module_name&item_name&id=$id\">");

The item_name parameter isn't doing anything. Your URL should look like this:

print ("<a href=\"modules.php?name=$module_name&id=$id\">");

Then in on your page, you build a query like this:

if (isset($_GET['id']) && $_GET['id'])
{

$query = "SELECT field1, field2 FROM table1 WHERE id='" . $_GET['id'] . "'";
...
get that item and show it

}
else
{
... show the list that of products in this category

}

Something like that.

Tom

dkin

10:47 pm on Jun 19, 2004 (gmt 0)

10+ Year Member



I have got it thanks for all the help.