Hi,
I am at the next stage of learning and so far I have a simple select statement working with PDO as illustrated below. This works fine if you want a list of things or just one thing:
What if, for example I had lets say four products on one page with headings but each product is a different level:
bronze | silver | gold | platinum
Try to imagine that they have similar services but just more of, when you select the higher package.
I am not looking for anyone to write the code for me, just steer me in the right direction.
Here is my code so far which works for one thing.
$book_query = ("SELECT * FROM packages WHERE service = ? LIMIT 10");
if(!$book_stmt = $pdo->prepare($host_query)){
// prepare failed
echo "<pre>Prepare failed:\n";
print_r($pdo->errorInfo());
echo "</pre>";
} else {
if(!$book_stmt->execute(array('books'))){
// execute failed
echo "<pre>Execute failed:\n";
print_r($book_stmt->errorInfo());
echo "</pre>";
} else {
// query ran without any errors, you can test if it returned any rows and use them here
}
}
// Database
if ($book_stmt->rowCount() > 0) {
while ($col = $book_stmt->fetch(PDO::FETCH_ASSOC)) {
$title = $col['title'];
$author = $col['author'];
$descr = $col[''description];
$type = $col['type'];
$language = $col['language'];
$paperback = $col['paperback'];
$currency = $col['currency'];
$price = $col['price'];
}
} else {
$title = 'no data';
$author = 'no data';
$descr = 'no data';
$type = 'no data';
$language = 'no data';
$paperback = 'no data';
$currency = 'no data';
$price = 'no data';
}
I hope what i am trying to achieve is clear. Any help will be great 😉