Jump to content

php mysql


calmchess

Recommended Posts

I'm using the following code to query mysql server the problem is there is multiple results but i can only add the last result to a variable i need to add each returned result to a variable......could somebody help me to do that plz.

mysql_connect("192.168.1.2", "root", "KKT1pKT2KKT1pKT2") or die(mysql_error());
mysql_select_db("page0") or die(mysql_error());

$result = mysql_query("SELECT userstream FROM page0")
or die(mysql_error());  

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

$username0 = $row['userstream'];

Link to comment
https://forums.phpfreaks.com/topic/140996-php-mysql/
Share on other sites

[code=php:0]
mysql_connect("192.168.1.2", "root", "KKT1pKT2KKT1pKT2") or die(mysql_error());
mysql_select_db("page0") or die(mysql_error());

$result = mysql_query("SELECT userstream FROM page0")
or die(mysql_error());  

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

$username0[] = $row['userstream'];
}

foreach ($username0 AS $name) {
  echo $name."<br/>\n";
}

 

$username0 is now an array, so make sure you know how to use arrays

Link to comment
https://forums.phpfreaks.com/topic/140996-php-mysql/#findComment-737944
Share on other sites

Archived

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

×
×
  • 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.