Jump to content

Check if Exist - Better Solution?


lurn

Recommended Posts

I have spent a few hours researching this just because I was curious and can't seem to find a good answer.  Normally I would do something like the following in PHP:

 

$query = "SELECT subd FROM tblsubd WHERE subd = '" & .$idstr. & "') ";
$result = mysql_query($query);
$num = mysql_num_rows($result);
if ($num != 0){
        }

 

The table only has 1 column so I just need to check if exist or not.  Seems like there has to be a better way.  Wouldn't the way I am doing it continue down the column even if it finds a result and search the whole column?  I am trying to avoid that if possible.

 

Thanks in advance so I can continue on.

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/189595-check-if-exist-better-solution/
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.