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); Link to comment https://forums.phpfreaks.com/topic/137293-solved-mysql-problem-or-php-problem/ 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); } } } ?> Link to comment https://forums.phpfreaks.com/topic/137293-solved-mysql-problem-or-php-problem/#findComment-717345 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!!! Link to comment https://forums.phpfreaks.com/topic/137293-solved-mysql-problem-or-php-problem/#findComment-717358 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.