Php 浏览器上没有显示数据,但数据保存在数据库中

Php 浏览器上没有显示数据,但数据保存在数据库中,php,phpmyadmin,Php,Phpmyadmin,这是我的php代码 <?php include "conn.php"; if(isset($_POST['submit'])){ $id_guru=htmlentities($_POST['id_guru']); $id_pelajaran=htmlentities($_POST['id_pelajaran']); $id_kelas=htmlentities($_POST['id_kelas']); $query=mysql_query("insert into tbl_jadw

这是我的php代码

<?php

include "conn.php";

if(isset($_POST['submit'])){

$id_guru=htmlentities($_POST['id_guru']);
$id_pelajaran=htmlentities($_POST['id_pelajaran']);
$id_kelas=htmlentities($_POST['id_kelas']);

$query=mysql_query("insert into tbl_jadwal values('','$id_guru','$id_pelajaran','$id_kelas')");

if($query){
    ?><script language="javascript">document.location.href="?page=jadwal_pengajaran&status=1";</script><?php
}else{
    ?><script language="javascript">document.location.href="?page=jadwal_pengajaran&status=2";</script><?php
}


}else{
unset($_POST['submit']);
}


?>

<!--  start page-heading --><title>Sistem Informasi SMP YPPI</title>
<div id="page-heading">
<h1>Jadwal Pengajaran</h1>
</div>
<!-- end page-heading -->

<table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
<tr>
<th rowspan="3" class="sized"><img src="images/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
<th class="topleft"></th>
<td id="tbl-border-top">&nbsp;</td>
<th class="topright"></th>
<th rowspan="3" class="sized"><img src="images/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
</tr>
<tr>
<td id="tbl-border-left"></td>
<td>
<!--  start content-table-inner ...................................................................... START -->
<div id="content-table-inner">

        <?php
        if($_GET['status']=='1'){
        ?>

        <div id="message-green">
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
            <td class="green-left">Data Tersimpan</td>
            <td class="green-right"><a class="close-green"><img src="images/table/icon_close_green.gif"   alt="" /></a></td>
        </tr>
        </table>
        </div>

        <?php
        }

        if($_GET['status']=='0'){
        ?>

        <div id="message-red">
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
            <td class="red-left">Gagal Menyimpan</td>
            <td class="red-right"><a class="close-red"><img src="images/table/icon_close_red.gif"   alt="" /></a></td>
        </tr>
        </table>
        </div>

        <?php
        }
        ?>

        <form action="?page=jadwal_pengajaran" method="post">
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr valign="top">
          <td><!--  start step-holder -->
            <!--  end step-holder -->
              <!-- start id-form -->
              <table border="0" cellpadding="0" cellspacing="0"  id="id-form">
                <tr>
                  <th valign="top">Guru</th>
                  <td><select name="id_guru"  class="styledselect_form_1">

                  <?php
                  $guru=mysql_query("select * from data_guru order by nama_guru asc");
                  while($row1=mysql_fetch_array($guru)){
                  ?>
                      <option value="<?php echo $row1['id_guru'];?>"><?php echo $row1['nama_guru'];?> [ <?php echo $row1['nip'];?> ]                               <option>
                  <?php
                  }
                  ?>                          

                    </select>
                  </td>
                  <td></td>
                </tr>

                <tr>
                  <th valign="top">Pelajaran</th>
                  <td><select name="id_pelajaran"  class="styledselect_form_1">

                      <?php
                      $pelajaran=mysql_query("select * from setup_pelajaran order by nama_pelajaran asc");
                      while($row2=mysql_fetch_array($pelajaran)){
                      ?>
                          <option value="<?php echo $row2['id_pelajaran'];?>"><?php echo $row2['nama_pelajaran'];?></option>
                      <?php
                      }
                      ?>    

                    </select>
                  </td>
                  <td></td>
                </tr>

                <tr>
                  <th valign="top">Kelas</th>
                  <td><select name="id_kelas"  class="styledselect_form_1">

                      <?php
                      $kelas=mysql_query("select * from setup_kelas order by nama_kelas asc");
                      while($row3=mysql_fetch_array($kelas)){
                      ?>
                          <option value="<?php echo $row3['id_kelas'];?>"><?php echo $row3['nama_kelas'];?></option>
                      <?php
                      }
                      ?>    

                    </select>
                  </td>
                  <td></td>
                </tr>

                <tr>
                  <th>&nbsp;</th>
                  <td valign="top"><input type="submit" name="submit" class="form-submit" />
                      <input type="reset" class="form-reset"  />
                  </td>
                  <td></td>
                </tr>
              </table>
            <!-- end id-form  -->
          </td>
          <td><!--  start related-activities -->
          </td>
        </tr>
        <tr>
          <td><img src="images/shared/blank.gif" width="695" height="1" alt="blank" /></td>
          <td></td>
        </tr>
        </table>
        </form>

        <p><em>*Tidak boleh 1 Kelas, 1 Pelajaran di ajarkan oleh 2 Guru atau lebih<br /></em> </p>           
        <p>&nbsp;</p>
          <!--  start product-table ..................................................................................... -->
    <form id="mainform" action="">
    <table border="0" width="71%" cellpadding="0" cellspacing="0" id="product-table">
    <tr>
        <th width="13%" class="table-header-repeat line-left minwidth-1"><a href="">Nomor</a>   </th>
        <th width="24%" class="table-header-repeat line-left minwidth-1"><a href="">Nama Guru</a></th>
        <th width="26%" class="table-header-repeat line-left minwidth-1"><a href="">NIP</a></th>
        <th width="24%" class="table-header-repeat line-left minwidth-1"><a href="">Mata Pelajaran</a></th>
        <th width="24%" class="table-header-repeat line-left minwidth-1"><a href="">Kelas</a></th>
        <th width="13%" class="table-header-options line-left"><a href="">Aksi</a></th>
    </tr>


    **<?php
    $view=mysql_query("*SELECT* FROM tbl_jadwal jadwal, setup_kelas kelas, setup_pelajaran pelajaran, data_guru guru where          jadwal.id_kelas=kelas.id_kelas and jadwal.id_pelajaran=pelajaran.id_pelajaran and jadwal.id_guru=guru.id_guru order by id_jadwal         asc");

    $no=0;
    while($row=mysql_fetch_array($view)){
    ?>  
    <tr>
        <td><?php echo $no=$no+1;?></td>
        <td><?php echo $row['nama_guru'];?></td>
        <td><?php echo $row['nip'];?></td>
        <td><?php echo $row['nama_pelajaran'];?></td>
        <td><?php echo $row['nama_kelas'];?></td>
        <td class="options-width">
        <a href="" title="Delete" class="icon-2 info-tooltip"></a>
        <a href="" title="Edit" class="icon-5 info-tooltip"></a>            
        </td>
    </tr>
    <?php
    }
    ?>
    </table>
    <!--  end product-table................................... --> 
    </form>



<div class="clear"></div>

</div>
<!--  end content-table-inner ............................................END  -->
</td>
<td id="tbl-border-right"></td>
</tr>
<tr>
<th class="sized bottomleft"></th>
<td id="tbl-border-bottom">&nbsp;</td>
<th class="sized bottomright"></th>
</tr>
</table>**
是吗

 $view=mysql_query("*SELECT* FROM ...
从粘贴中,它应该如下所示:

 $view=mysql_query("SELECT * FROM ...

将为您提供一个编号数组,而不是关联数组。因此,您需要按顺序访问字段:

 <td><?php echo $row[0];?></td>
 <td><?php echo $row[1];?></td> ...

注:。它们不再得到维护。看到了吗?相反,学习,并使用or-将帮助您决定哪一个。如果选择PDO,.FYI-
没有属性“language”,它已被
弃用。实际上,
返回数组的类型取决于结果类型的定义方式。通过使用MYSQL_-BOTH(默认),您将得到一个既有关联索引又有数字索引的数组。
@Damien Pirsy:您是对的,upvote,从来没有看到过(我不经常使用这个…)您是否更正了上述答案中提到的
SELECT
语句?执行
var\u转储($row)
就在
循环中,
循环中,我假设您的字段名拼写不正确或错误?我的字段名id jadwal、id_kelas、id_pelajaran、id_guru。
 while($row=mysql_fetch_array($view)){
 <td><?php echo $row[0];?></td>
 <td><?php echo $row[1];?></td> ...
 while($row=mysql_fetch_assoc($view)){