secoxxx Posted August 22, 2008 Share Posted August 22, 2008 Im generating xml with php, eveything works fine except the first result is blank.. Any ideas? <?php header("Content-type: text/xml"); $connection = mysql_connect("localhost","xxxxx", "xxxxx") or die ("could not connect to database"); $db = mysql_select_db("xxxxx",$connection) or die ("Couldn't select database."); $rs = mysql_query("SELECT * FROM video WHERE type = 'public' " .$active. "AND viewtime <> '0000-00-00 00:00:00' ORDER BY viewtime DESC LIMIT 0,10",$connection) or die ("invalid query"); echo ("<ut_response status=\"ok\">"); echo ("<video_list>"); do { echo ("<video>"); echo ("<title>". $row['title']. "</title>"); echo ("<url>http://www.tsxxx.com/video/". $row['VID']. "</url>"); echo ("<thumbnail_url>http://www.tsxxx.com/thumb/". $row['thumb']."_". $row['VID'].".jpg</thumbnail_url>"); echo ("</video>"); } while ($row = mysql_fetch_assoc($rs)); echo ("</video_list>"); echo ("</ut_response>"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/120834-solved-mysql-query-first-result-blank/ Share on other sites More sharing options...
Poddy Posted August 22, 2008 Share Posted August 22, 2008 Try using the while loop alone maybe it dosent catch the result on the first loop and prints blank as in while ($row=mysql_fetch_assoc($rs)) { commands } sorry about formatting typing from a cellphone Quote Link to comment https://forums.phpfreaks.com/topic/120834-solved-mysql-query-first-result-blank/#findComment-623415 Share on other sites More sharing options...
Fadion Posted August 22, 2008 Share Posted August 22, 2008 The do while loop will print the result, then loop through the returned query data, that's why you get a blank first result. You should use a while() loop instead. <?php while($values = mysql_fetch_array($results)){ //print those values } ?> Quote Link to comment https://forums.phpfreaks.com/topic/120834-solved-mysql-query-first-result-blank/#findComment-623419 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.