$news = mysql_query("select StudentId FROM $table"); if($mydata=mysql_fetch_object($news)) { //got it } else { // no such StudentId }
John Taylor-Johnston wrote:
Ok, this is a basic MySQL question, but I don't know how to code it in PHP. I want to check in StudentId. If it exists, ... Anyone good humoured who would help me fill in the blank. Like I should know this, but haven't even thought of coding SQL in a while :)
$myconnection = mysql_connect($server,$user,$pass); mysql_select_db($db,$myconnection);
$news = mysql_query("select StudentId $table");
while ($mydata = mysql_fetch_object($news)) { }
if exists {do this}else{do that}
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php