I'm attempting to select all records from a table than loop through the results and select all records from another table where tableid is equal to the id of the results of the first query.
So basically select all from first table, while you have results, select all from second table where tableid is equal to first results current id, than pass all this into an array for use later.
I'll take a stab at it, but I'm trying to get properly written code in OOP style using PDO. Its basically a one to many relationship, 1 record in table1 will have multiple records in table2.
public function showLog($table){
$sql="SELECT * FROM $table";
$q= $this->conn->query($sql) or die("failed!");
while($r = $q->fetch(PDO::FETCH_ASSOC)){
$sql="SELECT * FROM :table WHERE id = :id";
$q = $this->conn->prepare($sql);
$q->execute(array(':table'=>"vessels",':id'=>$id));
$data = $q->fetch(PDO::FETCH_ASSOC);
}
return $data;
}