简体   繁体   中英

Select only rows with certain critiera then output data

So im developing a web page with the following sql query:

$sql=mysql_query("SELECT * FROM `fotf_images` WHERE `image_fotfnum` = '$Fivedigits'");

now, $fivedigits is a $_POST from a previous forms input data. So basically the form parses the mysql db for rows that contain ONLY $Fivedigits in a specific column. What i want to do, is output EVERY row that has these criteria. So far i used the following:

while ($row = mysql_fetch_array($sql, MYSQL_ASSOC)) {
print_r($row);  
}

this only seems to output the first row, when i know as a fact there are exactly 2 rows that contain the criteria. Please help! Thanks!

try using

    Select * from fotf_images 
where Concat(image_fotfnum, '', field2, '', fieldn) 
like concat('%','",$Fivedigits,"','%')

since its not only numeric you may need to use LOWER or UPPER case while comparing. This will help you search in every mentioned feilds of fotf_images table

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM