quick question

Alles, was PHP betrifft, kann hier besprochen werden.

quick question

Postby marshal » 06. September 2006 12:16

Code: Select all
$query = "SELECT * FROM pixuri";
$result = mysql_query($query) or die("Query failed : " . mysql_error());

echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_NUM)) {
    echo "\t<tr>\n";
    foreach ($line as $col_value) {
        echo "\t\t<td>$col_value</td>\n";
    }
    echo "\t</tr>\n";
}
echo "</table>\n";


how do i make this display in 3 columns???
marshal
 
Posts: 12
Joined: 05. September 2006 12:04

Postby Flominator » 12. September 2006 14:36

Replace * by the 3 columns you want to see.
Lust auf Kommunikation?
Meinung über Musik vorhanden?
Text nicht verstanden?
Songtexte gesucht?

Dann besucht uns in der Songtexte-Community:
http://www.ramselehof.de/songtexte
User avatar
Flominator
 
Posts: 50
Joined: 30. August 2004 13:59
Location: Hinterzarten

Postby sari42 » 21. September 2006 20:17

Flominator wrote:Replace * by the 3 columns you want to see.

...separated by ","
sari42
 
Posts: 800
Joined: 27. November 2005 18:28

Postby nullplan » 26. September 2006 15:42

Or, if you want to have this as template, you could use a for-loop:
Code: Select all
while ($line = mysql_fetch_array($result, MYSQL_NUM)) {
    echo "\t<tr>\n";
    for ($i = 0; $i < 3; $i++) {
        echo "\t\t<td>$line[$i]</td>\n";
    }
    echo "\t</tr>\n";
}
Lernen ohne zu denken ist sinnlos, aber denken ohne zu lernen ist gefährlich. - Konfuzius
nullplan
 
Posts: 22
Joined: 14. May 2006 10:19


Return to PHP

Who is online

Users browsing this forum: No registered users and 84 guests