I set several cookies on the page. Now I need to get the name of each cookie I set and run it against my database if the name from the cookie matches the "ID" in my database I want to display this record. Can anybody help?
I tried to do the following, but it doesn't work:
<?
if (isset ($_COOKIE)) {
while (list ($cname, $cvalue) = each ($_COOKIE)) {
@ $db = mysql_pconnect("localhost", "my_login", "my_password"
if (!$db)
{
echo "Error: Could not connect to database. Please try again later.";
exit;
}
mysql_select_db("catalog"
$query = "select * from pricelist where item_number = '$cname'";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
for ($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
$item_number = stripslashes($row["item_number"]);
echo $item_number;
$description = stripslashes($row["description"]);
echo $description;
.
.
.
}
}
}
?>
I tried to do the following, but it doesn't work:
<?
if (isset ($_COOKIE)) {
while (list ($cname, $cvalue) = each ($_COOKIE)) {
@ $db = mysql_pconnect("localhost", "my_login", "my_password"
if (!$db)
{
echo "Error: Could not connect to database. Please try again later.";
exit;
}
mysql_select_db("catalog"
$query = "select * from pricelist where item_number = '$cname'";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
for ($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
$item_number = stripslashes($row["item_number"]);
echo $item_number;
$description = stripslashes($row["description"]);
echo $description;
.
.
.
}
}
}
?>