[thelist] php/mysql: a more efficient method of doing this
Dunstan Orchard
dunstan at 1976design.com
Wed Apr 2 12:27:58 CST 2003
Hi there,
I'm running a little bit of code that checks to see if an item is in a user's
cart or not.
If it's not it prints the '+' link, if it is then it prints the '-' link.
I'm currently doing it like this:
****************************************
$query = ("SELECT * FROM cart WHERE (userid = '$userid') AND (imageid
= '$imageid')");
$result = mysql_query($query);
// if it's not there print the +cart link
if (mysql_num_rows($result) == '0')
{
print the +cart link
}
// if it is there print the -cart link
else
{
print the -cart link
}
****************************************
I'd like to know if there's a more efficient way of doing this check.
Thanks for any suggestions,
- Dunstan
---------------------------
Dorset, England
http://www.1976design.com/
http://www.orchard.it/
http://www.maccaws.org/
More information about the thelist
mailing list