Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/271.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/8/mysql/55.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 mysql查询中未显示的行_Php_Mysql - Fatal编程技术网

Php mysql查询中未显示的行

Php mysql查询中未显示的行,php,mysql,Php,Mysql,我有两部分代码。代码的第一部分根据情况告诉我表中记录的数量,第二部分提取并显示实际记录信息。在下面的代码中,它以is 3显示正确的记录计数,但当它尝试提取信息以显示它时,它仅显示1条记录 $depcourselist=mysql_query("select * from organization_dep_courses odc left join course c on odc.courseid=c.id where orgid=$orgid and depid=$departmentid"

我有两部分代码。代码的第一部分根据情况告诉我表中记录的数量,第二部分提取并显示实际记录信息。在下面的代码中,它以is 3显示正确的记录计数,但当它尝试提取信息以显示它时,它仅显示1条记录

  $depcourselist=mysql_query("select * from organization_dep_courses odc left join course c on odc.courseid=c.id where orgid=$orgid and depid=$departmentid");
echo '<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr bgcolor="#eaeaea" height="40">
<th align="left">Course Catalog<span>('.$countdepcourses.')</span></th>
</tr>';
while($courselist=mysql_fetch_array($depcourselist) )
$coursename = $courselist['fullname'];
{
if($coursecolor==1)
{
echo "<tr bgcolor='#f1f1f1' width='100%' height='25'>
  <td align='left'>".$coursename."<a href='#'><img src='".$remove."' /></a></td>
  </tr>";
$coursecolor="2";
}
else 
{
echo '<tr bgcolor="#ffffff" height="25">
   <td align="left">'.$coursename.'<a href="#"><img src="'.$remove.'" /></a></td>
   </tr>';
$coursecolor="1";
}  
}
echo '</table>';
$depcourselist=mysql\u query(“选择*来自组织的dep\u课程odc左连接odc上的课程c.courseid=c.id,其中orgid=$orgid,depid=$departmentid”);
回声'
课程目录(“.$countdepcourses.”)
';
而($courselist=mysql\u fetch\u数组($depcurseList))
$coursename=$courselist['fullname'];
{
如果($coursecolor==1)
{
回声“
“$coursename。”
";
$coursecolor=“2”;
}
其他的
{
回声'
“.$coursename。”
';
$coursecolor=“1”;
}  
}
回声';
如果您能帮助您找出导致记录无法正确显示的原因,我们将不胜感激。

更改此部分:

while($courselist=mysql_fetch_array($depcourselist) )
$coursename = $courselist['fullname'];
{
为此:

while($courselist=mysql_fetch_array($depcourselist) )
{
$coursename = $courselist['fullname'];
注意花括号{

和使用

mysql_fetch_assoc 
而不是

mysql_fetch_array 
(这样做更好,因为它更优化,您在这里只需要关联数组,不需要数字数组)

使用此代码

  $depcourselist=mysql_query("select * from organization_dep_courses odc left join course c on odc.courseid=c.id where orgid=$orgid and depid=$departmentid");
echo '<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr bgcolor="#eaeaea" height="40">
<th align="left">Course Catalog<span>('.$countdepcourses.')</span></th>
</tr>';
while($courselist=mysql_fetch_array($depcourselist) )
{ // Changed here
$coursename = $courselist['fullname'];
if($coursecolor==1)
{
echo "<tr bgcolor='#f1f1f1' width='100%' height='25'>
  <td align='left'>".$coursename."<a href='#'><img src='".$remove."' /></a></td>
  </tr>";
$coursecolor="2";
}
else 
{
echo '<tr bgcolor="#ffffff" height="25">
   <td align="left">'.$coursename.'<a href="#"><img src="'.$remove.'" /></a></td>
   </tr>';
$coursecolor="1";
}  
}
echo '</table>';

1.设置代码格式。2.请显示正确显示计数的代码。
   while($courselist=mysql_fetch_array($depcourselist) )
        { // Changed here
        $coursename = $courselist['fullname'];
.
.
.