use url to sort???

admin

Administrator
Staff member
I'm trying to get the following code to take a url such as test.php?alpha=r-t and return all entries starting with R Thru T.

Does anyone know how I can make it return all entries starting with R THRU T ?

I'm getting an error near the while statement.

thanks.

//<?php

$db = mysql_connect()
or die ("Could not connect");

mysql_select_db("udllabs")
or die ("Could not select database");

$letter = split("-", $alpha);

$letter[0];
$letter[1];

$query = mysql_query("SELECT * FROM products WHERE substr(product_description, 0, 1) >= '$letter[0]' AND substr(product_description, 0, 1) <= '$letter[1]'");


echo "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n";
echo "<tr>\n";
echo "<td style=\"background-color: #000;\"><table cellpadding=\"2\" cellspacing=\"1\" border=\"0\">\n";
echo "<tr>\n";
echo "<th>NDC#</th>\n";
echo "<th>Product Description</th>\n";
echo "<th>Package Size</th>\n";
echo "<th>Compare To</th>\n";
echo "</tr>\n";


while ($row = mysql_fetch_array($query));

{

echo $row [ printf("
<tr valign=\"top\">\n
<td class=\"data\" nowrap>%s</td>\n
<td class=\"data\">%s</td>\n
<td class=\"data\">%s</td>\n
<td class=\"data\">%s</td>\n
</tr>\n", $row["ndc"], $row["product_description"], $row["size"], $row["compare"])];

}
echo "</table>\n";

//?>
 
Back
Top