Ok i'm writing a dictionary program for my website and I want to be able to sort the pages by Letter. So i set up a variable named $sort and then set up some if statements to to handle if the person wanted to see the latest entries, all the entries, or view them by letter.
else
{
echo($sort);
// SELECT * FROM `p2p_dict` WHERE dict_term LIKE '$sort%'
$query = mysql_query("SELECT * FROM 'p2p_dict' WHERE 'dict_term' LIKE $sort%");
while( $row = mysql_fetch_array($query) );
{
// Truncate messages to X length
$str_def_len = strlen($termdef);
if($str_def_len >= 50)
{
$termdef = strip_tags($termdef);
$termdef = substr($termdef,0,75);
$termdef = $termdef . "...";
}
echo('<a href="dictionary.php?word=' . $tid . '"><b>' . $dictterm . '</b></a> - ' . $termdef .'<br />');
}
}
Thats what I did, although I'm not sure why it doesn't work. It says theres a problem with the query but i can't figure it out.
http://www.napjunk.net/dictionary/dictionary.php?word=
oh btw, it's been a while since i posted last but I'd like to say thanks to y'all cause i've learned a bunch just by lurking around the board. 🙂