Page 1 of 1

Newbie having array display probs

Posted: Sat Oct 19, 2002 2:29 pm
by MadCow573
Hi there,

Sorry for the dumb question, but im new to PHP and just cant figure this out . I am trying to create a "roster" type layout but cant get my array items to display the way I wish.

DB schema
rank_id | rank1 | rank2 | rank3

1 | user1 | user2 | user3
2 | user1b |

Idea being that I can display each rank and its users with only one query and array, unfortunatly when I try to pull two or more fields PHP is printing out the rows in succession casuing "user1b" to be inserted AFTER the entire first row has been displayed.

$row = mysql_fetch_array($result);

print $row["rank1"];

print $row["rank2"];

will print
user1, user2, user1b

when I'd like
user1, user1b, user2

(i realize this example is oversimplified)

Is my db flawed? Can i use another function to diplay multi-col only w/o re-query? Am i just a newbie moron?

Thanks for the time,
Eric C

Posted: Sat Oct 19, 2002 2:45 pm
by volka
$result = mysql_query($query, $dbConn) creates a result set according to $query. $result identifies the result set for further access.
$row = mysql_fetch_array($result); fetches one (/the next) row of a result set.
$row["rank1"]; refers to the value of the field rank1 in this row.

there are some mysql/php tutorials at http://www.phpcomplete.com/section_content.php?id=3

btw: welcome to this forum :D