Jump to content

help with this code


MDanz

Recommended Posts

The cell keywords in mysql has multiple keywords in it.  This is just one cell. How do i list the keywords of this cell separately in an index?  Below doesn't list them separately, it takes the first letter of the entry in the cell and displays all the keywords(grouped).

 

Any help greatly appreciated.

 

<?php


mysql_connect("localhost", "master", "pword");
mysql_select_db("db");

$letter = htmlentities($_GET['search']); 
$user = mysql_query("SELECT * FROM Stacks WHERE keywords LIKE '$letter%' ORDER BY keywords")or die (mysql_error());  


while($rowz = mysql_fetch_array($user)){
$keyword = $rowz['keywords'];

$bad = mysql_query("SELECT * FROM Stacks WHERE keywords LIKE '$letter%' ORDER BY keywords")or die (mysql_error()); 
$num_rows = mysql_num_rows($bad)or die (mysql_error());  
}

if ($num_rows == 0)
{
echo "<font face='Courier New' font size=18px font color=#FF9900>$letter</font><br /><br />";
echo "<font face='Courier New' font size=3px font color=#FBB917>No Stacks</font><br>";
}
else {




echo "<font face='Courier New' font size=18px font color=#FF9900>$letter</font><br /><br />";
echo "<font face='Courier New' font size=3px font color=#FBB917><a href='stack.php?search=$keyword&submit=Go!' style='text-decoration: none';>$keyword</a></font><br>";
}
?>

 

how can i change the query to only select the keywords that begin with $letter in the one cell in mysql?

e.g. $letter= 'a'  and in the one cell in mysql it has keywords ... apple, bananna, etc.

 

it should only list apple.  how?

Link to comment
https://forums.phpfreaks.com/topic/191121-help-with-this-code/
Share on other sites

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.