Jump to content

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.

Link to comment
https://forums.phpfreaks.com/topic/455-help-me-please-im-not-very-good-with-mysql/
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

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.

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. :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.