php - Select statement fill data in a foreach -
i'm trying create php file when clicking 'edit' link job id , list number of rows jobref in applications table.
this list of applications different jobs have available on website.
<?php require 'mysqlcon.php'; if(isset($_get['id'])) { $stmt = $pdo->query('select applications applicationid = :id'); $results = $stmt->fetchall(); echo "<table><tr><td>job reference</td><td>job title</td><td>job location</td><td>job description</td><td>salary</td><td>availability</td> <td>category</td><td>apply</td>"; foreach ($results $row) { echo "<tr><td>".$row['applicationid']."</td>". "<td>".$row['jobref']."</td>", "<td>".$row['fname']."</td>", "<td>".$row['lname']."</td>"; } } ?>
my error cannot code work; i've tried using "pdo::fetch_assoc" still no help.
any ideas on i've gone wrong?
you need use prepare , execute, binding/parameterized queries. need pass value query. try this:
$stmt = $pdo->prepare('select * applications applicationid = ?'); $stmt->execute(array($_get['id'])); $results = $stmt->fetchall();
your select
query needs value selecting. i've put in *
every column. if want columns list them separated commas.
the concatenation , comma separation in echo
strange think should work..
final note, table
doesn't close; should add </table>
after foreach
.
final additional note errors use, http://php.net/manual/en/pdo.errorinfo.php.
Comments
Post a Comment