0

我创建了 html 表单,当我单击提交按钮时,我从数据库中获取记录,但如果数据不在数据库中,则其打印http://bukkyolu.com/mp3/upload/不是来自表单数据库只是我在下面的声明中打印的静态值 http://bukkyolu.com/mp3/upload/".$row['2']."'> ,如果 .$row['2'].is 不在到数据库我想要空白空间而不是http://bukkyolu.com/mp3/upload/

<?php
$category=$_POST["category"];
$month=$_POST["month"];

$mysql_hostname = "localhost";
$mysql_user = "root";
$mysql_password = "";
$mysql_database = "bukkyolu_mp3";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password)
or die("Opps some thing went wrong");
mysql_select_db($mysql_database, $bd) or die("Opps some thing went wrong");

    $query  = "SELECT title,Amp3,Bmp3,Cmp3 FROM mp3_data WHERE`category` = '$category' and `month` = '$month' ";
$result1 = mysql_query($query);
$row = mysql_fetch_array($result1);
//echo $row['s_id'];

 echo "<table border='1' align='center' >";

while ($row = mysql_fetch_row($result1)){
 // echo "<td><a href='#' onclick='someFunction()'>" .$row['0']. "</a> </td>";
   echo "<tr><th>Title:</th><td>".$row['0']."</td></tr>";  
 echo "<tr><th>African:</th><td><a href 'http://bukkyolu.com/mp3/upload/".$row['1']."'>http://bukkyolu.com/mp3/upload/".$row['0']."</a></td></tr>";
 echo "<tr><th>British:</th><td><a href 'http://bukkyolu.com/mp3/upload/".$row['2']."'>http://bukkyolu.com/mp3/upload/".$row['0']."</a></td></tr>";
 echo "<tr><th>Caribbean:</th><td><a href 'http://bukkyolu.com/mp3/upload/".$row['3']."'>http://bukkyolu.com/mp3/upload/".$row['3']."</a></td></tr>";
  echo "<tr></tr>";
  echo "<tr></tr>";
}
echo "</table>";
}
?>
4

2 回答 2

0

我没有在您的代码中看到combo1和combo2 ...但是,由于您在同一页面中有html和php ..在执行mysqlquery之前最好检查帖子..

<?php
 if(isset($_POST){
     $category=$_POST["category"];
     $month=$_POST["month"];

     $mysql_hostname = "localhost";
     ...... //rest of your code
 }

选择选定的值..

<select name="category">        
  <option <?php echo ( isset($_POST) && ($_POST['category'] =="animals"))? "selected='selected'":"" ?> value="animals">Animals</option>
  <option <?php echo ( isset($_POST) && ($_POST['category'] =="biblical"))? "selected='selected'":"" ?> value="biblical">Biblical</option>
  <option <?php echo ( isset($_POST) && ($_POST['category'] =="fables"))? "selected='selected'":"" ?> value="fables">Fables</option>
  <option <?php echo ( isset($_POST) && ($_POST['category'] =="fairy tales"))? "selected='selected'":"" ?> value="fairy tales">Fairy Tales</option>
  <option <?php echo ( isset($_POST) && ($_POST['category'] =="historical"))? "selected='selected'":"" ?> value="historical">Historical</option>
 </select>

其他组合相同

于 2013-03-18T14:08:38.337 回答
0

这只是一个通知,不是致命错误。无论如何,您的页面仍应运行。它只是意味着变量 combo1 和 combo2 没有在你的源代码中的任何地方初始化,但是你在某个地方使用它们。为了确保它不会显示该错误,请将这行代码放在页面顶部。

error_reporting(E_ALL ^ E_NOTICE);
于 2013-03-18T14:09:44.233 回答