jscix Posted February 21, 2007 Share Posted February 21, 2007 Ok im having a bit of a problem, This code works.. however, when it finds multiple entries, it is only returning the first one (first row I guess?) How can I get this to find all the rows, and move on to the next one after putting the data into vars? <?php $connection = mysql_connect("mysql", "lllll", "lllll"); if (!$connection) { print "Failed to connect to database";} $db_select = mysql_select_db("posts"); if (!$db_select) { print "Failed to find database";} $sendsql = " SELECT * FROM comments WHERE tou IN ( '$curusr' ) LIMIT 0 , 30 "; $sqlq = mysql_query($sendsql); if (!$sqlq) { print "Failed to find"; die();} $dbdata = mysql_fetch_row(($sqlq)); $postid = $dbdata[0]; // post ID $retuidz = $dbdata[1]; //from user $retusrn = $dbdata[2]; // to user $retcom = $dbdata[3]; //comment print_r ($dbdata); ?> Quote Link to comment Share on other sites More sharing options...
jscix Posted February 21, 2007 Author Share Posted February 21, 2007 hrmm, what I mean is, After I use mysql_fetch_row, and it returns the data from the first-row into the variables, how do I get it to retrive the next row, it seems to only be grabbing the first one every time.. Quote Link to comment Share on other sites More sharing options...
jcbarr Posted February 21, 2007 Share Posted February 21, 2007 fetch_row is only designed to fetch one row. Try using a while loop with mysql_fetch_array. That should work better for you. Something like this. while ($dbdata=mysql_fetch_array($sqlq)) { //echo the values here } Quote Link to comment Share on other sites More sharing options...
jscix Posted February 22, 2007 Author Share Posted February 22, 2007 Oh nice, Tyvm! Quote Link to comment 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.