Dynamic Grid

Coding:

<?php
// Include database connectioninclude_once 'connect_to_mysql.php';// SQL query to interact with info from our database$sql mysql_query("SELECT id, member_name FROM member_table ORDER BY id DESC LIMIT 15"); $i 0;// Establish the output variable$dyn_table '<table border="1" cellpadding="10">';
while(
$row mysql_fetch_array($sql)){
   
    
$id $row["id"];
    
$member_name $row["member_name"];
   
    if (
$i == 0) { // if $i is divisible by our target number (in this case "3")
        
$dyn_table .= '<tr><td>' $member_name '</td>';
    } else {
        
$dyn_table .= '<td>' $member_name '</td>';
    }
    
$i++;
}
$dyn_table .= '</tr></table>';?><html>
<body>
<h3>Dynamic PHP Grid Layout</h3>
<?php echo $dyn_table?></body>
</html>



No comments:

Post a Comment