faqts : Computers : Programming : Languages : PHP : Database Backed Sites : MySQL

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

4 of 5 people (80%) answered Yes
Recently 3 of 4 people (75%) answered Yes

Entry

I have a MySQL db with a column named "ID". When user enters ID thru form I want to make sure the ID exists and then perform a db query.

Aug 6th, 2003 19:58
Justin Dalrymple, Sam Luther, Ben Udall,


<?php


$grab_id = "SELECT ID FROM table WHERE ID = '$id_variable'";

$result = mysql_query($grab_id);



IF (!$result)
{
echo (mysql_error());
}


ELSE
{


IF (mysql_num_rows($result) > 0)
{
// PUT YOUR CODE HERE
}


ELSE
{
echo ("ID $id_variable Not Found.");
}


}


?>