function getProdsByManufacs() { if (!isset($_REQUEST['manf'])) { //return error echo '{"result":0,"message": "search did not work."}'; } $search_text = $_REQUEST['manf']; include "products.php"; $obj = new products(); if (!$obj->searchByManfs($search_text)) { //return error echo '{"result":0,"message": "search did not work."}'; return; } //at this point the search has been successful. //generate the JSON message to echo to the browser $row = $obj->fetch(); echo '{"result":1,"products":['; //start of json object while ($row) { echo json_encode($row); //convert the result array to json object $row = $obj->fetch(); if ($row) { echo ","; //if there are more rows, add comma } } echo "]}"; //end of json array and object }
status message </div> <div id="divContent"> Content space <span class="clickspot">click here </span> <?php include_once "products.php"; $obj = new products(); $search_text = ""; if (isset($_REQUEST['txtSearch'])) { $search_text = $_REQUEST['txtSearch']; } $obj->search_by_name($search_text); echo "<table border='1' id='prodTable'>"; echo "<tr style='background-color:olive; color:white; text-align:center'><td></td><td>Name</td><td>Price</td><td>manufacturers</td><td></td></tr>"; $row = $obj->fetch(); $style = ""; $i = 0; while ($row) { if ($i % 2 == 0) { $style = "style='background-color:Khaki'"; } else { $style = ""; } echo "<tr {$style} >"; echo "<td><input type='checkbox' id=''products[]' name='products[]' value='{$row['product_id']}'></td>"; echo "<td><span class='clickspot' onclick='getDesc({$row['product_id']})'>{$row['product_name']}<span></td>"; echo "<td>{$row['product_price']}</td> <td>{$row['manf_id']}</td>"; echo "<td><span class='clickspot' onclick='getDesc({$row['product_id']})'>Edit<span>   <span class='clickspot' onclick='deleteProduct({$row['product_id']})'>Delete<span></td>"; echo "</tr>"; $row = $obj->fetch();