Php 当选择多个列时,脚本(while循环)停止并且没有输出
我想从表中选择多个列,但一旦while循环启动,脚本就无法工作。我的php和html代码是:Php 当选择多个列时,脚本(while循环)停止并且没有输出,php,mysql,mysqli,while-loop,Php,Mysql,Mysqli,While Loop,我想从表中选择多个列,但一旦while循环启动,脚本就无法工作。我的php和html代码是: <table border="0"> include_once $_SERVER['DOCUMENT_ROOT'].'/include/db.inc.php' ; $sql="select post_title,post_desc,post_date,course,semester,firstname,lastname FROM wbut_forum_posts left jo
<table border="0">
include_once $_SERVER['DOCUMENT_ROOT'].'/include/db.inc.php' ;
$sql="select post_title,post_desc,post_date,course,semester,firstname,lastname
FROM wbut_forum_posts left join users on post_by = email
ORDER BY post_id DESC LIMIT 25";
$result = mysqli_query($link,$sql );
if (!$result) {
include_once "wall.html.php";
echo'<tr><td align="center"> OOOOPPPPPSSS!!!SORRY,UNABLE TO DISPLAY LATEST 25 TOPICS</td></tr>';
exit();
}
while ($row = mysqli_fetch_array($result)) {
$titles[] = $row['post_title'];
$descs[] = $row['post_desc'];
$dates[] = $row['post_date'];
$courses[] = $row['course'];
$semesters[] = $row['semester'];
$firstnames[] = $row['firstname'];
$lastnames[] = $row['lastname'];
}
$cnt=0;
foreach ($titles as $x) {
$title[$cnt]=$x;
$cnt=$cnt+1;
}
$cnt=0;
foreach ($firstnames as $x) {
$firstname[$cnt]=$x;
$cnt=$cnt+1;
}
$cnt=0;
foreach ($lastnames as $x) {
$lastname[$cnt]=$x;
$cnt=$cnt+1;
}
$cnt=0;
foreach ($descs as $x) {
$descs[$cnt]=$x;
$cnt=$cnt+1;
}
$cnt=0;
foreach ($dates as $x) {
$date[$cnt]=$x;
$cnt=$cnt+1;
}
$cnt=0;
foreach ($courses as $x) {
$courses[$cnt]=$x;
$cnt=$cnt+1;
}
$cnt=0;
foreach ($semesters as $x) {
$semester[$cnt]=$x;
$cnt=$cnt+1;
}
echo'AFTER FOREACHES';
for ($i=0;$i<$cnt;$i=$i+1) {
echo'<table border="0">';
echo'<tr>';
echo '<td align="left"><span class="style1">';
echo $firstname[$i] . " " . $lastname[$i] ;
echo '</span></td>';
echo '<td align="center" colspan="2">RELATED COURSE :';
echo $course[$i];
echo ' RELATED SEMESTER:';
echo $semester[$i];
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td> </td>';
echo'<td align="left"><span class="style3">';
echo $desc[$i];
echo '</span></td>';
echo'<td valign="baseline">';
echo $date[$i];
echo '</td>';
echo '</tr>';
echo'<tr>';
echo '<td> </td>';
echo '<td align="left" background="reply_bg.gif"><span class="style3"> ';
echo 'echo the replies here';
echo '</span>';
echo '</td>';
echo'<td> </td>';
echo '</tr>';
echo '<tr>';
echo '<td> </td>';
echo '<form action="reply.html.php" method="post"><td align="left" ><textarea rows="5" cols="40" name="reply" id="reply"></textarea> </td><td valign="baseline"><input type="submit" name="asd" value="REPLY" /><input type="hidden" name="reply" value="reply" /></td></form>';
echo ' </tr>';
echo '</table>';
}
echo' CLOSING MAIN FOR ';
?>
</table>
include_once$_SERVER['DOCUMENT_ROOT']./include/db.inc.php';
$sql=“选择帖子标题、帖子描述、帖子日期、课程、学期、名字、姓氏
从wbut_论坛_帖子左侧通过=电子邮件加入帖子上的用户
邮递订单_iddesc LIMIT 25”;
$result=mysqli\u查询($link,$sql);
如果(!$result){
包括_once“wall.html.php”;
echo'ooopppppsss!!!抱歉,无法显示最新的25个主题';
退出();
}
while($row=mysqli\u fetch\u数组($result)){
$titles[]=$row['post_title'];
$descs[]=$row['post_desc'];
$dates[]=$row['post_date'];
$courses[]=$row['courses'];
$semesters[]=$row['Semest'];
$firstnames[]=$row['firstname'];
$lastnames[]=$row['lastname'];
}
$cnt=0;
foreach(标题为$x){
$title[$cnt]=$x;
$cnt=$cnt+1;
}
$cnt=0;
foreach($x为名字){
$firstname[$cnt]=$x;
$cnt=$cnt+1;
}
$cnt=0;
foreach($x的姓氏){
$lastname[$cnt]=$x;
$cnt=$cnt+1;
}
$cnt=0;
foreach(描述为$x){
$descs[$cnt]=$x;
$cnt=$cnt+1;
}
$cnt=0;
foreach(日期为$x){
$date[$cnt]=$x;
$cnt=$cnt+1;
}
$cnt=0;
foreach(课程为$x){
$courses[$cnt]=$x;
$cnt=$cnt+1;
}
$cnt=0;
每学期(学期为$x){
$EXTERM[$cnt]=$x;
$cnt=$cnt+1;
}
回音“前额痛后”;
对于($i=0;$i)
注1:不工作..我在不同的地方发出了回声。我注意到它在while循环启动时完全停止了
$sql
之后,哪里是$result
$result=mysql\u query($sql)**或die(mysql\u error)**//如果存在任何错误,则给出mysql的输出错误
while
之前,使用变量转储($row)
,或打印($row)
error\u reporting(E\u ALL);
编辑:抱歉,您正在使用MySQLi。使用
$MySQLi->error
您的代码的第一行没有打开的PHP标记。
应该是:
<table border="0"><?
没有获取u。我应该在哪里执行该操作?您在哪里用}
关闭了while循环?我看不到它。您能为我们提供原始文件吗?在退出()之后}
i在此处复制时出现相同错误..请参阅最新编辑..我编写了$resultconsor输出MySQLi生成的错误。您可能有一组空行,因此没有得到任何结果。或者语法错误