Is there any way to write an efficient code better than this.
because everytime I call the values I just do the following:Code:try{ $sql = "SELECT * FROM device.monitor WHERE del_stat IS NULL AND id = ?"; $q = connection::$db->prepare($sql); $q -> bindValue(1, $id, PDO::PARAM_INT); $q ->execute(); $row = $q->rowCount(); if ($row == 0) { echo 'no records found.'; }else{ while ($row = $q->fetch(PDO::FETCH_ASSOC)) { $mon = $row['mon_brand']; $ay= $row['id']; $return[] = array($mon, $ay); } } }catch (Exception $e) { print "Error!:" . $e->getMessage(); }
I wonder if there is another way of doing it like calling just automatically call the id and it will show its value.Code:foreach ($view as $test) { $id = $test[1]; $brand = $test[0]; }
Thank you in advance.



Reply With Quote



Bookmarks