Bhupal Sapkota Computer Programmer Unraveling art, science, and commerce behind technology. Passionate about web/mobile programming, writing, and growing an online business.

My Private Mailing List

If you want early access and opportunities that I don’t post publicly, get on my private email list.


Building Dynamic Queries in PHP MySQL PDO

1. When you need a dynamic Search Query where variable parameters are presents you can use the following approach: $sql = “SELECT * FROM users WHERE “; $where = array(“dist_id = :dist_id”); $params = array(‘:dist_id’ => $distID); if (isset($p->username) && !empty($p->username)) { array_push($where, “username LIKE :username”); $params[‘:username’] = “%{$p->username}%”; } if (isset($p->firstname) && !empty($p->firstname)) { […]

Tagged with: