-2

该脚本正在显示我请求的数据(Id、Dsc、School),但我在第 20 行出现错误。

{
  if ($row['suspended']==1){

解析错误:语法错误,第 20 行 C:\wamp\www\unit5\scripts\meminclude.php 中的意外 '}'

   <?php
 include("dbconnect1.php");

$query = "SELECT id,dsc, school FROM module WHERE dsc LIKE '%%%s%%'";

$link = @ mysql_query($query);
  if (!$link) {

header("location:../account/account.master.php?page=invalid&errorcode=1");
   die();
 }

$i=0;
 $status="";

while ($row = mysql_fetch_array($link, MYSQL_ASSOC))


{
  if ($row['suspended']==1){


$status="SUS";
  }
   echo "

<tr id='row$i' class='trows'>".
         "
<td id='id$i'>".$row['id']."</td>".
         "
<td id='dsc$i'>".$row['dsc']."</td>".
         "
<td id='school$i'>".$row['school']."</td>".
         "
</td>".
         "
<td><input type='radio' name='whome' id='showMe$i' onclick='showMem($i)' /></td>
";
         if ($status=='SUS'){
          echo "
<td><input type='radio' name='suspend' checked='checked' disabled='disabled' /></td>
";
         } else {
          echo "
<td><input type='radio' name='suspend' id='suspend$i' onclick='suspendMem($i)' /></td>
";
         }
         echo "
<td><input type='radio' name='delete' id='delete$i' onclick='deleteMe($i)' /></td>
".
         "
<td id='status$i'>".$status."</td></tr>";
  $i++;
  $status="";
 }
?>

此处引用了该脚本:

    <script type="text/javascript">
     $(document).ready(function() {
           var numrecs=$(".trows").length;
           var me= $('#th1').html()+" - "+(numrecs)+" Records in Table.";
           $('#th1').html(me);
           RiVm=numrecs;
      });
     </script>
     <link rel="stylesheet" href="../css/results.css" type="text/css" /> 
     <div id="appleft">
         <form id="myapprovelist" method="post"> 
         <fieldset style="border:none">
         <table id="myTable"> 
          <tr><th id="th1" colspan="10">Active Membership List</th></tr>
          <tr class="red"> 
           <th>ID</th>
           <th>DSC</th>
           <th>School</th>
           </tr>
          <?php include("../scripts/meminclude.php")?>  
         </table> 
        </fieldset>
       </form>
      </div>
      <div id="appright">
       <img id="theBroon" src="" alt="" /><br />
       <span id="myBroon"></span>
      </div>
    </div>
    <div style="clear:both">    
    </div>
4

1 回答 1

1

我检查并清理了格式、缩进并更改了整个引用堆。

尝试这个:

<?php
    include("dbconnect1.php");
    $query = "SELECT id,dsc, school FROM module WHERE dsc LIKE '%%%s%%'";
    $link = @ mysql_query($query);
    if (!$link) 
    {
        header("location:../account/account.master.php?page=invalid&errorcode=1");
        die();
    }

    $i=0;
    $status="";
    while ($row = mysql_fetch_array($link, MYSQL_ASSOC))
    {
        if ($row['suspended']==1)
        {
            $status="SUS";
        }
        echo "<tr id='row".$i."' class='trows'><td id='id".$i."'>".$row['id']."</td><td id='dsc".$i."'>".$row['dsc']."</td><td id='school".$i."'>".$row['school']."</td></td><td><input type='radio' name='whome' id='showMe".$i."' onclick='showMem(".$i.")' /></td>";
        if ($status=='SUS')
        {
            echo "<td><input type='radio' name='suspend' checked='checked' disabled='disabled' /></td>";
        }
        else
        {
            echo "<td><input type='radio' name='suspend' id='suspend".$i."' onclick='suspendMem(".$i.")' /></td>";
        }
        echo "<td><input type='radio' name='delete' id='delete".$i."' onclick='deleteMe(".$i.")' /></td><td id='status".$i."'>".$status."</td></tr>";
        $i++;
        $status="";
    }
?>

和数据库连接:

<?php 
    $hostname = "localhost";
    $username = "root";
    $password = "";
    $dbase = "timetable";
    $link = @ mysql_connect($hostname, $username, $password);
    if (!$link) 
    {
        header("location:../account/account.master.php?page=invalid&errorcode=1");
        die($link);
    }
    $db_selected = @ mysql_select_db($dbase, $link);
    if (!$db_selected) 
    {
        header("location:../account/account.master.php?page=invalid&errorcode=1");
        die();
    }
?>
于 2012-07-19T10:50:59.957 回答