0

I have a page which displays a list of items found in mysql database. This page is a classifieds page, so users will be able to see the submitted information on this page.

I'd like to know how I would create the divs then fill them with mysql information straight from the database. Heres some code.

<?php
//load database connection
    $host = "localhost";
    $user = "root";
    $password = "root";
    $database_name = "ctrader";
    $pdo = new PDO("mysql:host=$host;dbname=$database_name", $user, $password, array(
    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
    ));

include('Specials.html');
$query = $pdo->prepare("SELECT * FROM adsubm WHERE CATEGORY LIKE 'Specials'"); 

while($row = mysql_fetch_array($result)) 
{ 
  echo "<div>".$row['Name']."</div>"; 
} 

?>

I've been so confused with this that I just included the html for safety, my knowledge on such is very limited. All answers are appreciated, Thanks.

Kamanda
  • 305
  • 3
  • 4
  • 11
  • tht's how it will be, are there any errors? – Lucky Chingi Nov 16 '15 at 19:49
  • How is your current output differing from desired output? – Josh KG Nov 16 '15 at 19:50
  • Shouldn't you execute your prepared query before fetching the results? Otherwise I don't see any issue with your code, and there isn't any need for JS :) – Terry Nov 16 '15 at 19:51
  • you not executing the query after the prepare? http://php.net/manual/en/pdostatement.execute.php – Mi-Creativity Nov 16 '15 at 19:51
  • You are preparing a PDO query, but you loop over the $result fetching data with (DEPRECATED) mysql functions. – Yuri Nov 16 '15 at 19:54
  • @Terry I've put that in but still its not visible on the page, I'm I meant to specify the div class and so forth? there is also some divs on that page, could that pose as a problem? – Kamanda Nov 16 '15 at 20:02

0 Answers0