if ($stmt - > execute()) {
if ($stmt - > rowCount() > 0) {
$menu_id = array();
while ($selected_row = $stmt - > fetch(PDO::FETCH_ASSOC)) {
$menu_id[] = array('menuid' => $selected_row['menulist_id'], );
}
$stmt = $dbh - > prepare("SELECT * FROM menulist_tbl WHERE menulist_id = :menuid AND menu_displayorder <= :value");
$menu_name = array();
$input = array_map("unserialize", array_unique(array_map("serialize", $menu_id)));
//print_r($menu_id);
//print_r($input);
foreach($input as $row) {
$stmt - > execute(array(':menuid' => $row['menuid'], ':value' => '10000'));
//while ($selected_row =$stmt->fetch(PDO::FETCH_COLUMN, 0)){
while ($selected_row = $stmt - > fetch(PDO::FETCH_ASSOC)) {
$menu_name[] = array('displayorder' => $selected_row['menu_displayorder'], 'menuname' => $selected_row['menu_name'], 'menuurl' => $selected_row['menu_url'], 'menuflag' => $selected_row['menu_flag'], 'menuid' => $selected_row['menulist_id']);
}
}
array_multisort($menu_name);
//print_r($menu_name);
return $menu_name;
}
}
This is how i get menu from database this code will do the following:
From result of another query it will store in an array the menulist_id
then I will use this menulist_id
to query the menu table for menu name that has a display order of less 10000
, I have this parameter of less than 10000
because i can hide menu from the list of menu without deleting them so I want to show them again I just reduce their display order and they can be seen again. But why is my display order parameter not working even if i have a display order of 10011
the menu is still showing. Any idea is appreciated
FYI
the column menu_displayorder is varchar.
For a varchar you will want to CAST
as a numerical data type that can controlled better with >=
try this:
AND CAST(menu_displayorder AS UNSIGNED) <= :value