I'm trying to get my head around php and pdo statements at the moment so bear with.
I have the following code
$dbh = new PDO("mysql:host=$hostname;dbname=texts", $username, $password);
/*** The SQL SELECT statement ***/
$sql = "SELECT * FROM `texts` WHERE `messagesent` = 0 LIMIT 10";
foreach ($dbh->query($sql) as $row)
echo(' '.$row['content'].' ');
/*** close the database connection ***/
$dbh = null;
What I want to do is pull down first ten rows and display the contents of the contents row but if there are no results I want it to do another query from a different table and display the contents from the other table.
I also plan to add another query after the first one so that it updates a col.
The idea is that it pulls the first 10 displays it and updates the col to set it as displayed and refresh and if no results it pulls in from another table.