Jump to content

[SOLVED] mysql query first result blank...


secoxxx

Recommended Posts

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>");
?>

Link to comment
https://forums.phpfreaks.com/topic/120834-solved-mysql-query-first-result-blank/
Share on other sites

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
}
?>

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.