Title: Datagrid search php mysql Post by: tooletime on March 09, 2016, 03:44:49 PM Can someone PLEASE tell me why this doesn't work? ive racked my brain till i dont have one anymore....
if i take out the where " . $where . " it works but the search function fails. If i do a SELECT * from description where " . $where . " it works fine but the media_type is wrong. PLEASE HELP!! ;D Code: <?php Title: Re: Datagrid search php mysql Post by: nprioleau on March 10, 2016, 12:51:57 AM I battled for ages with this but have got it working with the code below, hope this helps?
<? require('kernal.php'); $itemid = trim(strip_tags($_REQUEST['id'])); // Get sales $getRows = $db->query(sprintf("SELECT *, p.prod_productID, p.prod_productName FROM sales_detail inner join products p on p.prod_productID = salesd_productID WHERE salesd_salesID = '$itemid' GROUP BY salesd_ID")) or SQLError(); while($row = $getRows->fetch_assoc()) { $rows[] = $row; } $smarty->assign('rowsNum', $total); $smarty->assign('rows', $rows); echo json_encode($rows); ?> Title: Re: Datagrid search php mysql Post by: tooletime on March 10, 2016, 08:39:56 AM thank you for your reply and believe it or not i got it working after i posted this LOL..
This is how i got it to work. something to do with if you are using double quotes, then your variables have to be in brackets... go figure... Original: $rs = mysql_query("SELECT `description`.*,`media`.`media_type` FROM `description` RIGHT OUTER JOIN `media` ON (`media`.`media_type` = `description`.`MEDIA_TYPE`) WHERE " . $where . " order by $sort $order limit $offset,$rows ") ; NEW: $rs = mysql_query("SELECT `description`.*,`media`.`media_type` FROM `description` RIGHT OUTER JOIN `media` ON (`media`.`media_type` = `description`.`MEDIA_TYPE`) WHERE {$where} order by $sort $order limit $offset,$rows ") ; |