Reputation: 407
I have a dropdown:
<form name="alphasearch" action="ialphalist.php" method="get">
<select style='font-size:26px;height:30px;width:540px;' name='alphasearch' onchange='this.form.submit()'>
<option value="">Select the First letter of the Business Name</option>
<option value="REGEXP'^[0-9]'">0-9</option>
<option value="a%">A</option>
<option value="b%">B</option>
<option value="c%">C</option>
here is a snippet from ialphalist.php:
list($categoriesRecords, $categoriesMetaData) = getRecords(array(
'tableName' => 'categories',
'perPage' => '5',
'loadUploads' => false,
'allowSearch' => true,
'where' => "Bus_name LIKE '$_GET[alphasearch]'",
'orderBy' => 'Bus_name',
The letters(A, B, C, etc.) display results as expected, I am trying to get it to work if the first character is a number. I thought that using the "REGEXP" statement was supposed to work, maybe I have it formatted wrong? What do I need to change to get this to work?
Upvotes: 0
Views: 56
Reputation: 1143
Try this:-
list($categoriesRecords, $categoriesMetaData) = getRecords(array(
'tableName' => 'categories',
'perPage' => '5',
'loadUploads' => false,
'allowSearch' => true,
'where' => "Bus_name REGEXP '^[a-zA-Z].*'",
'orderBy' => 'Bus_name',
EDIT : Specifying criteria via web page
$regex = "'^".$_GET[alphasearch][0]."'";
list($categoriesRecords, $categoriesMetaData) = getRecords(array(
'tableName' => 'categories',
'perPage' => '5',
'loadUploads' => false,
'allowSearch' => true,
'where' => "Bus_name REGEXP $regex",
'orderBy' => 'Bus_name',
This would get all those bus names which starts with an alphabet(either small or upper) .
[a-zA-Z] => ALphabet
. => Single character (number,alphabet or whatever else)
.* => character after first alphabet could be zero or more.
Hope it helps.
Upvotes: 1