循环情况

时间:2013-06-10 17:51:54

标签: php loops while-loop nosql

所以我有这段代码:

    //Table game_images
$a = 0;
$sql_game_images = mysql_query("SELECT * FROM game_images WHERE ID ='1'");
while($row = mysql_fetch_array( $sql_game_images )) {
            $aa = $a+1;
            $a = $aa;
            $GameImages_rel[$a]= $row['img_rel'];
            $GameImages_cover[$a]= $row['cover'];
            $GameImages_cover[$a]= $row['logo'];
    }
//Table game_video  
$c = 0;
    $sql_game_video = mysql_query("SELECT * FROM game_video WHERE ID ='1'");
    while($row = mysql_fetch_array( $sql_game_video )) {
            $cc = $c+1;
            $c = $cc;
            $GameVideo_url[$c]= $row['url'];
    }

然后我有:

$ia=1;
    while($ia<=$a)
      {
      mysql_data_seek($sql_game_images, 0);
      $ia++;
      }  

        echo "<div id='game_videos' class='none'><span class=\"game_title\">Game Video</span><br><br>";
    $ic=1;
    while($ic<=$c)
      {                     
            echo '<span class="game_line">';
            echo    '<div class="youtubevideo" style=\'background: url("http://img.youtube.com/vi/' .$GameVideo_url[$ic]. '/0.jpg") no-repeat 100% black; background-size: contain;\'>';
            echo    '</div>';
            echo    '</span>';
      $ic++;
      } 
问题是,现在我的视频结果没有显示出来,我不知道要放什么来避免困难,为了进行,我把     mysql_data_seek($ sql_game_images,0); 但我找到了解决方案,请帮忙,谢谢! PS:我内心有更多的东西,但是因为没有必要我起飞了。

1 个答案:

答案 0 :(得分:0)

    //Table game_images
$GameImages_rel = array();
$GameImages_cover = array();
$GameImages_logo = array();
$GameVideo_url = array();
$a = 0;
$sql_game_images = mysql_query("SELECT * FROM game_images WHERE ID ='1'");
while($row = mysql_fetch_array( $sql_game_images )) {
            $GameImages_rel[$a]= $row['img_rel'];
            $GameImages_cover[$a]= $row['cover'];
            $GameImages_logo[$a]= $row['logo'];
            $a++;
    }
//Table game_video  
$c = 0;
    $sql_game_video = mysql_query("SELECT * FROM game_video WHERE ID ='1'");
    while($row = mysql_fetch_array( $sql_game_video )) {
            $GameVideo_url[$c]= $row['url'];
            $c++;
    }


        echo "<div id='game_videos' class='none'><span class=\"game_title\">Game Video</span><br><br>";
    for($i=0,$j=count($GameVideo_url);$i<$j;$i++){                  
            echo '<span class="game_line">';
            echo    '<div class="youtubevideo" style=\'background: url("http://img.youtube.com/vi/' .$GameVideo_url[$i]. '/0.jpg") no-repeat 100% black; background-size: contain;\'>';
            echo    '</div>';
            echo    '</span>';
      }