php - Display mysql data in a new div per row returned -
i have created following not displaying data correctly, wish new div per line of data database.
<?php include_once '\inc\header.php'; $db_server = mysql_connect($db_hostname, $db_username, $db_password); if (!$db_server) die("unable connect mysql: ". mysql_error()); mysql_select_db($db_database) or die ("unable select database: " . mysql_error()); $query = "select * deal"; $result = mysql_query($query); if (!$result) die ("database access failed: " . mysql_error()); ?> <body class="metrouicss" onload="prettyprint()" style="zoom: 1;"> <div id="container"> <?php foreach($result $tile) {?> <div class="item tile double bg-color-red"> <?php echo $tile['name']?> </div> <?php }?> </div> <?php mysql_close ($db_server); ?>
`
<?php include_once '\inc\header.php'; $db_server = mysql_connect($db_hostname, $db_username, $db_password); if (!$db_server) die("unable connect mysql: ". mysql_error()); mysql_select_db($db_database) or die ("unable select database: " . mysql_error()); $query = "select * deal"; $result = mysql_query($query); if (!$result) die ("database access failed: " . mysql_error()); ?> <body class="metrouicss" onload="prettyprint()" style="zoom: 1;"> <div id="container"> <?php while($row = mysql_fetch_array($result)) {?> <div class="item tile double bg-color-red"> <?php echo $row['name']?> </div> <?php }?> </div> <?php mysql_close ($db_server); ?>
try it!
Comments
Post a Comment