Jump to content

Validation Support


fallenangel1983

Recommended Posts

Hey all,

 

to cut to the chase: I have a table in which i successfully connect to via php. I has many columns with one named ID. I allow the user to enter an ID on a html form. if the ID they enter matches one in the table then the row is shown.

 

that all works fine with this code:

 

$ID=$_POST['ID'];

 

$sql="select * from table where ID = '$ID'";

$result = blah blah

$num = blah blah

 

$i=0;

while ($i < $num)

{ blah blah......

 

However what i want to do now is show an error when an ID that a user enters is NOT in the table.

 

appreciate any help.

 

Link to comment
https://forums.phpfreaks.com/topic/98359-validation-support/
Share on other sites

I assume that $num will be the number of rows returned, so...

 

$ID=$_POST['ID'];

 

$sql="select * from table where ID = '$ID'";

$result = blah blah

$num = blah blah

 

if($num == "0") {echo "There were no results to return.";} else {

$i=0;

while ($i < $num)

{ blah blah......}

Link to comment
https://forums.phpfreaks.com/topic/98359-validation-support/#findComment-503353
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.