That query fails.
Back to the code I sent previously. Could it be something with the 'OR'. It works well except that it query A or C rather than A thru C.
Another person posted to try this but I'm lost on the below info:
(Use explode or split (explode might be a little faster, no regex) to separate the first and last letters as suggested by the other post and then query like this.
list($start, $end) = explode("-", $alpha);
select field1, field2 from mytable
where substr(lastname, 0, 1) >= '$start'
and substr(lastname, 0, 1) <= '$end'
order by lastname)
Original Code:
//<?php
$db = mysql_connect()
or die ("Could not connect");
mysql_select_db("udllabs")
or die ("Could not select database");
$letter = split("-", $alpha);
$query = mysql_query("SELECT * FROM products WHERE product_description LIKE '$letter[0]%' OR product_description LIKE '$letter[1]%'");
$letter[0]; // first letter (a)
$letter[1]; // second letter (d)
while($row = mysql_fetch_array($query)) {
echo $row [ printf("
<table>
<tr>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
</tr>
</table>\n", $row["ndc"], $row["product_description"], $row["size"], $row["compare"])];
}
//?>