Forum Moderators: coopster
I'm trying to set-up a simple A-Z list so that people can search a mysql database by each letter. Click on "A" get all records in the DB that start with "A". I have it working no problem but i want to be able to add "#" so that the user can get all records that start with a Number.
For some reason the query i'm running won't grab any records that start with a number?
here is the query:
SELECT *
FROM products,supplier
WHERE productName LIKE 'colname%' AND products.supplier_id = supplier.supplier_id
ORDER BY productName ASC
And the query string for the "#" is:
searchByList.php?index=1
for each of the Letters i have
searchByList.php?index=A
searchByList.php?index=B
etc etc....
it works on the letters but not on the number?
I'm using Dreamweaver so the 'colname%' has default value of -1 and a runtime value of $_GET['index']
any ideas on changing the query to grab the records with numbers would be helpful?
Thanks.
Try something like the following and tell me what you get:
$query = "SELECT * FROM products,supplier WHERE productName LIKE '".[url=http://us2.php.net/mysql-real-escape-string]mysql_real_escape_string[/url]($_GET['index'])."%' AND products.supplier_id = supplier.supplier_id ORDER BY productName ASC";