View Full Version : Checking for existance of a record

02-01-2007, 08:12 PM
I am not looking for help coding this, all I need is for someone to point me towards a good tutorial or forum post.

I need to have a script that will simply check to see if a record id exists. If the record id does not exist I want a line of text to be echoed that says "NOT FOUND". That is it. Nothing more or less.

If anyone knows where I can read up on this, let me know. Thanks.

02-01-2007, 08:47 PM
dont feel you cant come on here and ask questions

Ask as many as you like... We exist for you guys

// psuedo code //////////////////////
$sql_query = "SELECT * FROM table where fieldID = '$id'";
$query = mysql_query($sql_query);
$row = mysql_fetch_array($query);

if($row) {
$message = "The value exists";
} else {
$message = "The value does not exists";

<body ...

<?php echo $message; ?>

... /body>