有誰可以告訴我我按刪除的時候會跑出一堆空值

edited 九月 2014 in PHP新手區
====================副程式del.php======================
<?php
header('content-type:text/html;charset=utf-8');
include'mysql.php';
if($_GET['del']!='')
{
$sql="DELETE FROM happytime 
      where number='{$_GET['del']}'";
	  mysqli_query($con,$sql);
	  $rowdeleted = mysqli_affected_rows($con);
	  if($rowdeleted>0){
	  echo"success";
	  header('Location:sell.php');
	  exit();
	  }
	  else
	  {
	  die("fail:".mysqli_error($con));
	  }
}

?>
==================主程式sell.php=======================
<?php
include'mysql.php';
error_reporting(E_ALL ^ E_DEPRECATED);
?>
<form method="post" action="" enctype="multipart/form-date" name="form1">
名子:<input type="text" name="name" size="10">
電話:<input type="text" name="phone" size="10">
販賣:<input type="text" name="sell" size="10">
<input type="submit" value="送出"><input type="reset" value="重設">
</form>
<?php
$phone_number = $_POST['phone'];
$user_name=$_POST['name'];
$sell_name=$_POST['sell'];
if(!isset($phone_number)==empty($phone_number))
if(!isset($user_name)==empty($user_name))
if(!isset($sell_name)==empty($sell_name))
{
 {
  {
  $sql = " INSERT happytime(phone,name,sell)
         value('$phone_number','$user_name','$sell_name')";
		 mysqli_query($con,$sql);
  }
 }
}
 else
{
 {
  {
 echo"資料請勿留空白";
  }
 }
}
$sql = "SELECT *
       FROM happytime";
	  $result = mysqli_query($con,$sql);
	  
      $rowcount=mysqli_num_rows($result);	  
	   
	   if($rowcount>0)
       {
	
	  echo"<table border=1> <tr>
	         <td>姓名</td>
	         <td>物品</td>
		     <td>電話</td>
			 <td></td>";
	    while($row = mysqli_fetch_array($result))
		{
		 echo"<td>{$row['name']}</td>
		      <td>{$row['sell']}</td>
			  <td>{$row['phone']}</td>
			  <td><a href='delet.php?del={$row['number']}'>刪除</td>
			  <tr>";
		}echo"</table>";
	   }
	   
	   $sql="INSERT happytime(name,phone,sell)
	        value('$phone_number','$user_name','$sell_name')";
			if(!mysqli_query($con,$sql))
			{
			die("fail:".mysqli_error($con));
			}
	   
	   ?>
按刪除跑出一堆不必要的空值

評論

Sign In or Register to comment.