Ryan,
this line is not correct:
> $line = mysql_fetch_array($result, MYSQL_ASSOC);
Instead, you will need to loop through the result set, like:
while($row = mysql_fetch_array($result)) {
for($i=0; $i < mysql_num_fields($result); $i++) {
echo $row[$i];
}
}
You can find more info here: http://www.php.net/manual/en/ref.mysql.php
I leave formatting the output up to you ;-)
Regards,
--
Stefan Hinz <[EMAIL PROTECTED]>
Gesch�ftsf�hrer / CEO iConnect GmbH <http://iConnect.de>
Heesestr. 6, 12169 Berlin (Germany)
Tel: +49 30 7970948-0 Fax: +49 30 7970948-3
----- Original Message -----
From: "Ryan McDougall" <[EMAIL PROTECTED]>
To: "mysql" <[EMAIL PROTECTED]>
Sent: Sunday, January 19, 2003 6:47 PM
Subject: A mysql php question
> Hello everyone,
>
> I'm not sure if this is the proper place to be asking this question as
I
> believe it is more of a question on how to traverse through php arrays
and such
> but it is using a mysql_query function. So if this not the place
pleace don't
> read any further and ignore and/or delete this message.
>
> So I am new to mysql AND php, with a background in Oracle SQL. Anyway
I am just
> starting out writing a web application for a DB of the collection of
videos,
> games, and cds of me and my wife's. So I want to start out with just
making a
> table with the field names as the header rows and then the data
underneath the
> corresponding field name/column. The current code (last part of this
message)
> only prints out the right column headers/field names and then puts the
right
> information under it but it only gives me the first record, I want all
records.
>
> *********example of current code output*********
> IdNum FName LName
> 1 Ryan McDougall
>
> This is my code so far, be prepared to laugh as this is pretty bad
code I'm
> sure (I just don't want to be held liable for any injuries from
falling out of
> your chairs :-P ):
>
> <html>
> <head><title>My PHP test file</title></head>
> <body>
> <?php
> $link = mysql_connect ("localhost", "username", "password")
> or die ("Could not connect <br>\n");
> print ("Connected successfully<br>\n");
> mysql_select_db("DBname") or die("Could not select database");
>
> $query = "SELECT * FROM Who";
> $result = mysql_query ($query)
> or die ("Query failed");
>
> $line = mysql_fetch_array($result, MYSQL_ASSOC);
>
> print "<table>\n";
> print "\t<tr>\n";
> foreach ($line as $key => $value) {
> print "\t\t<td>$key</td>\n";
> }
> print "\t</tr>\n";
> print "\t<tr>\n";
> foreach ($line as $col_value) {
> print "\t\t<td>$col_value</td>\n";
> }
> print "\t</tr>\n";
> print "</table>\n";
>
> mysql_free_result ($result);
>
> mysql_close ($link);
>
> ?>
> </body>
> </html>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
>
> ---------------------------------------------------------------------
> Before posting, please check:
> http://www.mysql.com/manual.php (the manual)
> http://lists.mysql.com/ (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php