kigroy Posted December 17, 2008 Share Posted December 17, 2008 I'm running WAMPSERVER 2.0 MySQL 5.1.30 and PHP 5.2.7. In my database, db, I have a table, tb, with a column, cl. In cl I have 5 cells that contain the word test. I made my query in phpMyAdmin and it finds the 5 cells that contain the word test in cl of tb, but when I run it in my php code my variable assigned to the query array returns on the instance of the word test. Thoughts? $query = "SELECT cl FROM tb WHERE (`cl` LIKE '%$name%')"; /* $name set from form that I know works*/ $result = mysql_query($query, $conn); $row=mysql_fetch_array($result) print_r($row); Quote Link to comment Share on other sites More sharing options...
trq Posted December 17, 2008 Share Posted December 17, 2008 PHP. You need a loop. <?php $query = "SELECT cl FROM tb WHERE (`cl` LIKE '%$name%')"; /* $name set from form that I know works*/ if ($result = mysql_query($query, $conn)) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_array($result)) { print_r($row); } } } ?> Quote Link to comment Share on other sites More sharing options...
kigroy Posted December 17, 2008 Author Share Posted December 17, 2008 thank you thank you thank you thank you thank you!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.