Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 而在这种情况下_Php_Loops_While Loop_Nosql - Fatal编程技术网

Php 而在这种情况下

Php 而在这种情况下,php,loops,while-loop,nosql,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]=

所以我有这个代码:

    //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++;
      } 
$ia=1;
而($ia
//桌面游戏\u图像
$GameImages_rel=array();
$GameImages_cover=array();
$GameImages_logo=array();
$GameVideo_url=array();
$a=0;
$sql\u game\u images=mysql\u query(“从ID='1'的game\u images中选择*);
while($row=mysql\u fetch\u数组($sql\u game\u images)){
$GameImages_rel[$a]=$row['img_rel'];
$GameImages_cover[$a]=$row['cover'];
$GameImages_logo[$a]=$row['logo'];
$a++;
}
//桌面游戏视频
$c=0;
$sql\u game\u video=mysql\u查询(“从game\u video中选择*,其中ID='1');
while($row=mysql\u fetch\u数组($sql\u game\u video)){
$GameVideo_url[$c]=$row['url'];
$c++;
}
回声“游戏视频

”;
对于($i=0,$j=count($GameVideo_url);$i如果我有2个以上的while语句,我有5个或6个以上的语句,我如何解决这个问题呢?上面的代码应该和你的4个while循环做同样的事情。你不需要那么多。你需要更熟悉一些程序结构。
    //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>';
      }