View Full Version : PHP problems

11-30-2006, 01:58 AM
I'm a php newbie, so please do bear with me. I want to have a php file that lists all of hte contents on one of the rows on a sql table.

I have a table with two fields, username, and password.

I want a page that displays all the stuf funder username.

I have this:


$sql = "SELECT username FROM beta";
$query = mysql_query($sql, $var);

while($row = mysql_fetch_row($query)) {

echo $row['0'].'<br />';



It doesn't work. Can someone provide me with a better code, that actually works.


I posted this on the othe rforum too so I could get an answer.

11-30-2006, 03:21 AM
If I'm understanding correctly, you want to display all the usernames in your table.

The query:

$query = "SELECT * FROM beta";
$result = mysql_query($query);

while($row = mysql_fetch_row($result))

$entries[] = $row;


To display it on the page:

foreach ($entries AS $entry) {
print $entry['username'];

Lee Stevens
11-30-2006, 03:25 AM
Posted to your post in MySQL Section....