I've looked online for about two days and I'm not sure how to ask Google this scenario. I'm trying to pull all rows from a single column that contain the word 'Helmet'. What I'm getting is only 2 rows. There's actually about 10 rows but it contains words like 'Legs, Helmet' The rows that only have the word 'Helmet' are populating correctly. Code I'm using.
id | rune_slot
---------------------------------
0 | Shoulders
---------------------------------
1 | Chest
---------------------------------
2 | Main Hand, Off Hand, Ranged
---------------------------------
3 | Helmet
---------------------------------
4 | Legs, Helmet
---------------------------------
5 | Helmet
---------------------------------
6 | Legs, Helmet
---------------------------------
As you can see, this is my table. Like I said, I'm getting rows 3 and 4, but I can't seem to get rows 4 and 6 also.
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
$sql = 'SELECT * FROM runes WHERE rune_slot LIKE "Helmet"' ;
mysql_select_db('runelist');
$retval = mysql_query( $sql, $conn );
if(!$retval )
{
die('Could not get data: ' . mysql_error());
}
while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
{
echo "Rune Name : {$row['rune_name']} "." Craft Level : {$row['craft_level']} "." Rune Slot : {$row['rune_slot']} ".
"<br />";
}
echo "Fetched data successfully\n";
mysql_close($conn);
This is the code I got from http://www.tutorialspoint.com/php/mysql_select_php.htm .
I've tried as many different select statements that I know of. I've tried changing mysql_fetch_array to _assoc and I've browsed the http://www.php.net/manual/en/function.mysql-fetch-assoc.php . I'm guessing it's bad practice to put multiple data in a single column? Any help would be appreciated, I come here often to learn about PHP and MYSQL, now I'm just stuck. Thanks!!