Jump to content

Archived

This topic is now archived and is closed to further replies.

Doomflame

Help me please, im not very good with mysql.

Recommended Posts

I told it to select username from phpbb_users, and it should select multiple values. how would i make these values print on the page? I need all of them to print. Here is the code i have so far in case it helps:

 


$mysql = mysql_connect("localhost", "doomflam_admin", "PASSWORD") or die("Could Not Connect To Database!");

mysql_select_db("doomflam_forum");

$query = "SELECT username FROM phpbb_users";

$setquery = mysql_query($query);

$res = mysql_fetch_array($setquery);

foreach($res as $key => $value) {

print "$value <br>";

}

 

And this outputs:

 

Doomflame  

Doomflame

 

Doomflame is the first username in the list, but i need it to list all of them.

Share this post


Link to post
Share on other sites

Try this:

[php:1:6823e43252]<?php

//Databaseinfo

$database=\"db\";

$db = mysql_connect(\"localhost\",\"user\",\"pass\");

mysql_select_db($database);

//Code

$listm = mysql_query(\"SELECT * FROM contest_users\") or die (mysql_error());

while ($row = mysql_fetch_array($listm)) {

print(\"$row->username\");

}

?>[/php:1:6823e43252]

 

Use $row to select the row that you want, like username, or pass...

 

Hope it helps

Share this post


Link to post
Share on other sites

try this it works on my box.. as a matter a fact I\'m using it

[php:1:eca989abab]<?php

//Settings

$server=\"localhost\";

$database=\"db\";

$username=\"user\";

$pass=\"pass\";

$table=\"table\";

 

//Code

$db = mysql_connect($server,$username,$pass\");

mysql_select_db($database);

$list = mysql_query(\"SELECT * FROM $table\") or die (mysql_error());

while ($row = mysql_fetch_array($list)) {

print(\"$row[usernme]\");

}

 

?>[/php:1:eca989abab]

 

Again chage username to what ever field you have.. this works on my box, if it don\'t on yours, then I suggest you get another one.

Share this post


Link to post
Share on other sites

Try this:

$mysql = mysql_connect("localhost", "doomflam_admin", "PASSWORD") or die("Could Not Connect To Database!");

mysql_select_db("doomflam_forum",$mysql) or die("Unable To Locate Database!");

$query = "SELECT username FROM phpbb_users";

$setquery = mysql_query($query) or die("Query failed!");



if (mysql_num_rows($setquery)>0)

{

 while ($res = mysql_fetch_array($setquery))

 {

   print $res[\'username\']."<br>rn";

 }

}

else

{

 print "There are no entries!";

}

 

Hope that helps.

 

You can break it down if you need to customize it.. let us know if you need more help.

 

edit // posted late.. either method will work. :)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.