I have a database with product names. I want to be able to create one page (products.php) and embed a command as follows: (products.php?alpha=a-c) or (products.php?alpha=d-g). When this link would be clicked on it would pull from the database all last names beginning with d thru g (d-g) etc would come up. I've figured out a way already to do it be creating different pages for all letter segments, but I would like to do it by creating just 1 page.
Here the code i'm stuck on:
//<?php
$db = mysql_connect()
or die ("Could not connect");
mysql_select_db("udllabs")
or die ("Could not select database");
$query = mysql_query("SELECT * FROM products WHERE product_description LIKE '$letter[0]%' OR lastname LIKE '$letter[1]%'");
$letter = split("-", $alpha)
$letter[0] // first letter (a)
$letter[1] // second letter (d)
$result = mysql_query($query)
or die ("Query failed");
if ($myrow = mysql_fetch_array($result))
{
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";
do { printf("
<tr valign=\"top\">
<td class=\"data\" nowrap>%s</td>
<td class=\"data\">%s</td>
<td class=\"data\">%s</td>
<td class=\"data\">%s</td>
</tr>\n", $myrow["ndc"], $myrow["product_description"], $myrow["size"], $myrow["compare"]);}
while ($myrow = mysql_fetch_array($result));
echo "</table></td>\n";
echo "</tr>\n";
echo "</table>\n";}
else { echo "Sorry, no records were found!"; }
//?>
Thanks,
Chad