Jump to content

[SOLVED] MySQL Problem or PHP problem?


kigroy

Recommended Posts

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

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);
    }
  }
}

?>

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.