I am a Monkey see Monkey do Programmer. so at my age to old to learn anything new. I do need some advice and help!
I need to pull data from a table. (See table fields below)
- ID
- Title
- DatePosted
- Description
- Picture
(This i can do and list them perfectly below each other) using
<?php
try {
$conn = new PDO("mysql:host=$hostdb; dbname=$namedb", $userdb, $passdb);
$conn->exec("SET CHARACTER SET utf8");// Sets encoding UTF-8
$sql = "select * from TableNews Order by DatePosted ASC LIMIT 5 " ;
$result = $conn->query($sql);
if($result !== false) {
$cols = $result->columnCount();
foreach($result as $row) {
echo $row['Title'] . "
";
echo $row['DatePosted'] . "
";
}
}
$conn = null;
} catch(PDOException $e) {
echo $e->getMessage();
}
?>
This works perfect !!!
Here is where i need advice.
In my results i need the first record that comes out to only list the title and the picture anbd the remaining 4 Records only to show the -Title -DatePosted -Description.
Much of a Muchness like the news image included here
Thank you