calmchess Posted January 15, 2009 Share Posted January 15, 2009 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 More sharing options...
Mchl Posted January 15, 2009 Share Posted January 15, 2009 [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 More sharing options...
calmchess Posted January 15, 2009 Author Share Posted January 15, 2009 thanks i tried sticking it in an array but couldn't figure out how now i know.thanks again. Link to comment https://forums.phpfreaks.com/topic/140996-php-mysql/#findComment-737968 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.