searchform for mysql数据库:mysql_fetch_array()

时间:2017-11-24 04:06:31

标签: php mysql database phpmyadmin

我正在尝试在php中进行搜索,但我遇到了mysql_fetch_array函数的一些问题。我不明白为什么。我认为我的所有变量都已正确初始化。这是我的问题:

***0) {
$rep = mysql_fetch_array($rep);
?>***

以下是searchform的代码:

<div id="bodybox-s">
  <div id="bodybox-text">
  <h1>Reparaturstatus</h1>
  <br />
  Sie wollen den aktuellen Status Ihrer Reparatur erfahren? Dann geben Sie einfach Ihre Auftragsnummer in das Kästchen ein!<br />
  <br />
  <form name="input" action="http://test23.thirteen-design.com/reparaturstatus/" method="get">
  <input type="hidden" name="page" value="reparaturstatus">
  <input type="text" style="height: 20px; width: 150px;" name="id">
  &nbsp;<input type="submit" style="height: 24px; width: 75px;" value="Suchen">
  </form>
  </div>
  </div>

以下是我的php代码中的代码:

<?php 
$db_host = "";
$db_user ="";
$db_pass = "";
$db_database = "";
$con = mysql_connect($db_host, $db_user, $db_pass);
if (!$con)
{
    die('Could not connect: ' . mysql_error());
}
mysql_select_db($db_database, $con);

?>
  <section id="bodycontainer">

  <div id="bodybox-l">
  <div id="bodybox-text">
  <h1>Reparaturstatus</h1>
  <br />
  <?php 
if (isset($_GET['id'])) {
$rep = mysql_query("SELECT * from reparaturen WHERE ID = ".mysql_real_escape_string($_GET['id'])." LIMIT 1;");
if (mysql_num_rows($rep) > 0) {
$rep = mysql_fetch_array($rep);
  ?>
  <br />
  <h3>- Auftragsangaben</h3>
  <br />
  <b>Auftragsnummer:</b> <?php echo $rep['ID']; ?><br />
  <b>Hersteller:</b> <?php echo $rep['hersteller']; ?><br />
  <b>Modell:</b> <?php echo $rep['model']; ?><br />
  <br />
  <br />
  <h3>- Reparaturhistorie</h3>
  <br />
  <?php
  $historie = mysql_query("SELECT * FROM reparaturhistorie WHERE RID = ".$rep['ID']." ORDER BY ID DESC");
  while($ds = mysql_fetch_array($historie)) {
    ?>
    <div id="bodybox-r" style="background-image: linear-gradient(180deg, rgb(255, 255, 255), rgb(225, 225, 225));">
    <div style="float:left; width: 150px;"><?php echo $ds['datum']; ?></div>
    <div style="float:left; width: 700px;"><?php echo $ds['info']; ?></div>
    </div>
  <?php
  }
} else {
  ?>
  Es konnte keine Reparatur ermittelt werden! Bitte überprüfen Sie ihre Eingaben!
  <?php
}
} else {
  ?>
  Es konnte keine Reparatur ermittelt werden! Bitte überprüfen Sie ihre Eingaben!
  <?php
}
  ?>
  &nbsp;
  </div>
  </div>
  </section>
  <div id="clrf"></div>

我是初学者,希望你们能帮助我:)。

0 个答案:

没有答案