php - I need to create a custom query using specific characters from database -
what have rather large database of flight numbers based on divisions. flight number entered following eg: ccc-noc001 number breaks down follows ccc airline code noc division code , 001 actual flight number.
now trying create filter select flight number schedule based on division code. clarify way flight numbers entered database in 2 fields first being code entered ccc , flight number noc001 etc.
so need if possible strip numbers end of flight number searched noc or 1 of other division codes there 9 separate divisions. , able filter queries if drop down list select noc flight numbers noc show in table.
ccc-noc001 ccc-noc002 .... can give me appreciated
$dbh = new pdo($dsn, $user, $password); $query = "select * [tablename] [columnname] '%noc%'"; $stmt = $dbh->prepare($query); $stmt->execute(); if ($stmt->rowcount() > 0) { $resultset = $stmt->fetchall(pdo::fetch_assoc); foreach ($resultset $row) { $flight = $row['columnname']; $flightnum = str_replace('ccc-noc', '', $flight); } }
Comments
Post a Comment