was following up on a couple of tutorials from phpacademy.
I wanted to create a database, accesss it by PDO and display an image on a page. eventually looping throug several by using today epoch time vs 2038 epoch time.
have three files the config files has an array w/the host/username/databse info.
//advertrotation dbase
//secondarybnrs 2ndtable
$config ["db02"] = array (
'host' => 'localhost',
'username' => 'root',
'password' => '',
'dbname' => 'advertrotation'
);
it passes the info to a second file
include 'db02.inc.php';
$db02 = new PDO ('mysql:host='.$config["db02"]["host"].';dbname='.$config["db02"]["dbname"],$config["db02"]["username"] ,$config["db02"]["password"]);
$query = $db02->query("SELECT `id`,`image` FROM `secondarybnrs` WHERE UNIX_TIMESTAMP() < `eol` AND `shown`=0 ORDER BY `id` ASC LIMIT 1");
while ($row = $query->fetchAll(PDO::FETCH_ASSOC)){
$id = $row ["id"];
$image = $row ["image"];
echo '<a href="go.php?id='.$id.'" target="_blank" > <img src="'.$image.'"/> </a>';
$query = $db02->query("UPDATE `secondarybnrs` SET `shown`=1 ");
$shown = $db02->query("SELECT COUNT(`id`)FROM `secondarybnrs` WHERE `shown`=0");
}
/*if ($query = $db02->query($shown, 0)== 0){
$query = $db02->query("UPDATE `adverts` SET `shown` = 0");
}
$db02->query("SELECT `id`,`image` FROM `secondarybnrs` WHERE UNIX_TIMESTAMP() < `eol` AND `shown`=0 ORDER BY `id` ASC LIMIT 1"); */
and the results, are displayed in a third page that has a php include line. It worked. up to displaying the image. Got to see the result or print_r.
But how can I get it to show the image? Better yet any hints on how to get it to loop?
I have in the dabase a bol filed for “begining of life” (epoch time) and an eol “end of life” epoch time. I want to create a while loop that says that as long as bol is less than eol…++
thx
D