...

View Full Version : PHP problems



admaster
11-30-2006, 12: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:


<?php

$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.

Thanks.

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

Tyree
11-30-2006, 02: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, 02:25 AM
Posted to your post in MySQL Section....



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum