Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/279.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_Mysql - Fatal编程技术网

Php 内部联接问题

Php 内部联接问题,php,mysql,Php,Mysql,我在php页面中使用了内部连接。问题是,当我在mysql查询浏览器中启动查询时,它会获取近6行。所有这些都是正确的,但是当我在我的php页面中使用相同的代码时,它只会获取一行。这只是一个值 while($row=mysql_fetch_array($result1)) { while ($resultpoet = mysql_fetch_array($poet)) { ?> <tr> <td><?= $iCounter?&

我在php页面中使用了内部连接。问题是,当我在mysql查询浏览器中启动查询时,它会获取近6行。所有这些都是正确的,但是当我在我的php页面中使用相同的代码时,它只会获取一行。这只是一个值

while($row=mysql_fetch_array($result1))
{   
while ($resultpoet = mysql_fetch_array($poet)) {
    ?>
    <tr>
        <td><?= $iCounter?>
            . </td>
        <td><? if(($row['roman']=="")&&($row['hindi']=="")) { ?>
            <?=$row['name'] ?>
            <? } else { ?>
            <a href="sview.php?title=<?=$row['sid'] ?>">
            <?=$row['name'] ?>
            </a>
            <? } ?></td>
        <td width="216"><? 

 if($resultpoet['pstatus']!='u')
 print '<a href="pview.php?title='.$resultpoet['pname'].'">'.$resultpoet['pname'].'</a>';
else 
 print $resultpoet['pname'];

            ?>



            </td> 
        <td width="135"><?=$row['category'] ?></td>
        <td width="67"><a href="songtitle_action.php?title=<?=$row['sid'] ?>"> Edit </a>
            <input name="check[]" type="checkbox" value="<?=$row[s_id]?>" id="checkbox_<?=$row[sid]?>"></td>
        <td width="75"><?  if(($row['roman']=="")&&($row['hindi']=="")) { ?>
            <a href="song_add_lyrics.php?title=<?=$row['sid'] ?>"> Add Lyrics</a>
            <? } ?></td>
    </tr>
    <? }
            $iCounter++;
         }?>
while($row=mysql\u fetch\u数组($result1))
{   
而($resultpoet=mysql\u fetch\u数组($poter)){
?>
. 

您必须继续调用
获取数组

while ($result = mysql_fetch_array($poet))
{
  /* do stuff with $result */
}

您必须继续调用
获取数组

while ($result = mysql_fetch_array($poet))
{
  /* do stuff with $result */
}

您只调用了一次
mysql\u fetch\u array
,所以只得到一行

相反,您需要使用
while
进行迭代,并对查询返回的每一行进行输出。这是一个非常简单的示例:

$poet= mysql_query("SELECT  p.name as pname, p.status as pstatus from poet p INNER JOIN song s ON p.pid=s.pid");
while ($resultpoet= mysql_fetch_array($poet)) {
   if($resultpoet['pstatus']=='u')
     print '<a href="pview.php?title='.$resultpoet['pname'].'">'.$resultpoet['pname'].'</a>';
   else 
     print $resultpoet['pname'];
}
$poter=mysql\u查询(“从poter p中选择p.name作为pname,p.status作为pstatus,p.pid=s.pid上的poter p内部连接歌曲s”);
而($resultpoet=mysql\u fetch\u数组($poter)){
如果($resultpoet['pstatus']='u')
打印“”;
其他的
打印$resultpoet['pname'];
}

查看,示例代码详细阐述了这一原理。

您只调用了一次
mysql\u fetch\u array
,因此您只得到一行

相反,您需要使用
while
进行迭代,并对查询返回的每一行进行输出。这是一个非常简单的示例:

$poet= mysql_query("SELECT  p.name as pname, p.status as pstatus from poet p INNER JOIN song s ON p.pid=s.pid");
while ($resultpoet= mysql_fetch_array($poet)) {
   if($resultpoet['pstatus']=='u')
     print '<a href="pview.php?title='.$resultpoet['pname'].'">'.$resultpoet['pname'].'</a>';
   else 
     print $resultpoet['pname'];
}
$poter=mysql\u查询(“从poter p中选择p.name作为pname,p.status作为pstatus,p.pid=s.pid上的poter p内部连接歌曲s”);
而($resultpoet=mysql\u fetch\u数组($poter)){
如果($resultpoet['pstatus']='u')
打印“”;
其他的
打印$resultpoet['pname'];
}

查看,示例代码详细阐述了这一原理。

是的,我忘记了做这件事……纠正这一点……一个小时以来一直困惑不解。因为我在另一个while循环中使用了这一点,所以每次outer while is fetch value时,它都会获取该特定列或元组的所有计算。如何管理两个while循环?您可以嵌套所有while循环“我想,只要确保您使用的变量名不同即可。:)编辑您的答案并包含更多的代码…不明白您所说的。仍然缺少一些代码…放在您执行查询的部分。是的,我忘了做这些…更正这些…一个小时以来一直感到困惑。因为我在另一个while循环中使用这些代码,所以每次ter while是fetch value它获取该特定列或元组的所有计算组。如何管理两个while循环?您可以随意嵌套while循环,只需确保使用不同的变量名即可。:)编辑您的答案并包含更多代码…不理解您所说的内容。仍然缺少一些代码…放在你正在做查询。