beermaker74 Posted February 21, 2007 Share Posted February 21, 2007 I need to do some checks for someof my dynamic pages. What I need to do is go thru the complete table for one field and see if a value exists. the values are either y n or null. I only need to check for y. IS there a quick and dirty method to do this? Thanks for the help Link to comment https://forums.phpfreaks.com/topic/39393-checking-if-a-value-exists-in-a-mysql-field/ Share on other sites More sharing options...
tom100 Posted February 21, 2007 Share Posted February 21, 2007 if (mysql_num_rows(mysql_query("SELECT * FROM `tablename` WHERE `blah` = 'y')) > 0) Link to comment https://forums.phpfreaks.com/topic/39393-checking-if-a-value-exists-in-a-mysql-field/#findComment-190008 Share on other sites More sharing options...
beermaker74 Posted February 21, 2007 Author Share Posted February 21, 2007 thanks just what i was looking for Link to comment https://forums.phpfreaks.com/topic/39393-checking-if-a-value-exists-in-a-mysql-field/#findComment-190016 Share on other sites More sharing options...
trq Posted February 21, 2007 Share Posted February 21, 2007 <?php // connect to db if ($result = mysql_query("SELECT fld FROM tbl WHERE fld = 'y'")) { if (mysql_num_rows($result)) { // y was found } } ?> Link to comment https://forums.phpfreaks.com/topic/39393-checking-if-a-value-exists-in-a-mysql-field/#findComment-190025 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.