Jump to content

Grid type of layout - how do i do it


am_25

Recommended Posts

browser-side scripting can be done with javascript. php is a server-side language. your task seems like a difficult one. i recommend using both scripting languages.

 

to answer your question, yes. it is possible. here's an example how:

<?php
        /*connect to the database*/
        $db = mysql_connect("xxx", "xxx", "xxx");
        mysql_select_db("your_db", $db) OR die("<div align=\"center\"><font color=\"FF0000\">
                                                Sorry, could not connect to the database.
                                                Please try again later.</font></div><br />\n");

        /*query table*/
        $sql = "SELECT column1, column2, column3 FROM your_table";
        $query = mysql_query($sql) OR die($sql ."\ncaused the <i>following</i> error:\n". mysql_error());

        /*begin results table*/
        echo "<table border=\"0\">\n".
             "\t<tr><th>column1</th><th>column2</th><th>column3</th></tr>".
             "\t<tr>\n";

        /*establish incriment*/
        $i = 0;

        /*populate results*/
        while($row = mysql_fetch_array($query)){
                $i++;
                (($i % 3 == 0) ? ("\t</tr>\n\t<tr>") : (""));
                echo "<td>". $row['column1'] ."</td><td>". $row['column2'] ."</td><td>". $row['column3'] ."</td>\n";
        }
        
        /*end table*/
        echo "</table>\n";
?>

??? apparently i misunderstood exactly what you wanted to do. your topic and your post are two different things, it's confusing. my above example only illustrates how to populate an html table with the results from querying a database. if you're talking about key-stroke responsive language, it'd be javascript. or ajax, they are very similar languages.

 

try tizag and w3schools

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.