advancedfuture Posted January 9, 2008 Share Posted January 9, 2008 So the below is my attempt at pulling multiple bits of data from the database.... so far the only value that is returning anything useful is $RESUME. What am I doing wrong here? Thankx! $query = "SELECT resume, firstname, lastname, interests FROM profile WHERE username = '$username'"; $results = mysql_query($query); $num = mysql_num_rows($results); while($row = mysql_fetch_array($results)) { $RESUME = $row[0]; //GLOBAL RESUME $FIRSTNAME = $row[1]; $LASTNAME = $row[2]; $INTERESTS = $row[3]; } Quote Link to comment https://forums.phpfreaks.com/topic/85124-php-while-loop-mysql-data/ Share on other sites More sharing options...
simcoweb Posted January 9, 2008 Share Posted January 9, 2008 Since you're running the 'while' loop you don't need to also assign the results to variables unless that's what you want. Are you wanting to print the results? Quote Link to comment https://forums.phpfreaks.com/topic/85124-php-while-loop-mysql-data/#findComment-434234 Share on other sites More sharing options...
advancedfuture Posted January 9, 2008 Author Share Posted January 9, 2008 Yes i am wanting to print the results that is why I am assigning variables to them... this is just a snippet of the code. Quote Link to comment https://forums.phpfreaks.com/topic/85124-php-while-loop-mysql-data/#findComment-434238 Share on other sites More sharing options...
Ken2k7 Posted January 9, 2008 Share Posted January 9, 2008 <?php $query = "SELECT resume, firstname, lastname, interests FROM profile WHERE username = '$username'"; $results = mysql_query($query); $num = mysql_num_rows($results); while($row = mysql_fetch_array($results)) { echo $row[0].", ".$row[1].", ".$row[2].", ".$row[3]; } ?> Does that do any good? Quote Link to comment https://forums.phpfreaks.com/topic/85124-php-while-loop-mysql-data/#findComment-434241 Share on other sites More sharing options...
revraz Posted January 9, 2008 Share Posted January 9, 2008 Post the code after it too. Quote Link to comment https://forums.phpfreaks.com/topic/85124-php-while-loop-mysql-data/#findComment-434254 Share on other sites More sharing options...
simcoweb Posted January 9, 2008 Share Posted January 9, 2008 Ken2k7's snippet will print them out on a single line if that's good enough. Otherwise you'd need in integrate some HTML into the 'echo' to have it return in table cells/rows. Quote Link to comment https://forums.phpfreaks.com/topic/85124-php-while-loop-mysql-data/#findComment-434270 Share on other sites More sharing options...
Ken2k7 Posted January 9, 2008 Share Posted January 9, 2008 Ken2k7's snippet will print them out on a single line if that's good enough. Otherwise you'd need in integrate some HTML into the 'echo' to have it return in table cells/rows. Yeah, I was just seeing if it prints out any results. If it does, the problem is solved. Quote Link to comment https://forums.phpfreaks.com/topic/85124-php-while-loop-mysql-data/#findComment-434274 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.