|  | 
	                
  
    | 
	 
        ช่วยดูให้ผมทีครับ ว่าผิดตรงไหน มือใหม่หัดเขียนครับ     |  
    |  |  
 
	
		|  |  |  |  |  
		|  |  | 
          
            | <? include ("includes/dbconnect.php");
 ?>
 
 <a href="?option=free&a=1">Report</a>
 <a href="?option=free&a=2">Addnew</a>
 
 <?
 $a=$_GET['a'];
 //echo "a=".$a;
 ?>
 
 <?
 if($a=="1"){
 echo "<br>แสดงผล";
 $sql="SELECT id,title,email,detail,telephone,sender FROM tb129_id";
 $result= mysql_query($sql) or die ("Query Not Complete!".mysql_error());
 $num= mysql_num_rows($result);
 echo"<br>num=".$num;
 
 if($num<1) {
 echo"<br>ไม่มีข้อมูล";
 }else{
 echo"<br>มีข้อมูล $num แถว";
 echo"<table width=\"100%\"border=\"1\">";
 echo"<tr>
 <td>id</td><td>title</td><td>email</td><td>detail</td><td>telephone</td><td>sender</td>
 </tr>";
 
 for($i=0;$i<$num;$i++){
 $rs=mysql_fetch_array($result);
 echo "<tr>
 <td>".$rs[0]."</td>
 <td>".$rs[1]."</td>
 <td>".$rs[2]."</td>
 <td>".$rs[3]."</td>
 <td>".$rs[4]."</td>
 <td>".$rs[5]."</td>
 </tr>";
 }
 echo"</table>";
 }
 }
 if ($a=="2") {
 echo"<br>Addnew";
 ?>
 
 <form id="form1" name="form1" method="post" action="?a=21">
 <table width="200" border="1">
 <tr>
 <td width="70">Title</td>
 <td width="114"><label>
 <input type="text" name="title" id="title" />
 </label></td>
 </tr>
 <tr>
 <td>E-mail</td>
 <td><label>
 <input type="text" name="email" id="email" />
 </label></td>
 </tr>
 <tr>
 <td>Detail</td>
 <td><label>
 <textarea name="detail" id="detail" cols="45" rows="5"></textarea>
 </label></td>
 </tr>
 <tr>
 <td>Telephone</td>
 <td><label>
 <input type="text" name="telephone" id="telephone" />
 </label></td>
 </tr>
 <tr>
 <td>Sender</td>
 <td><label>
 <input type="text" name="sender" id="sender" />
 </label></td>
 </tr>
 <tr>
 <td> </td>
 <td><label>
 <input type="submit" name="send" id="send" value="send" />
 <input type="submit" name="Reset" id="Reset" value="reset" />
 </label></td>
 </tr>
 </table>
 </form>
 
 <?
 }
 ?>
 
 <?
 if($a=="21") {
 $title =  $_POST['title'];
 $email = $_POST['email'];
 $detail = $_POST['detail'];
 $telephone = $_POST['telephone'];
 $sender = $_POST['sender'];
 
 echo "<br>title=".$title;
 echo "<br>email=".$email;
 echo "<br>detail=".$detail;
 echo "<br>telephone=".$telephone;
 echo "<br>sender=".$sender;
 
 $sql="INSERT INTO tb129_id (title,email,detail,telephone,sender) VALUES ('$title','$email','$detail','$telephone','$sender')";
 $result= mysql_query($sql) or die ("Query Not Complete!" .mysql_error());
 if($result) {
 echo "เรียบร้อย";
 }else{
 echo "เกิดข้อผิดพลาด กรุณาทำรายการใหม่";
 }
 }
 ?>
 
 
 
 Tag : PHP, MySQL
 
 
 |  
            |  |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2010-09-26 04:14:06 | By :
                          เด็กน้อยหัด php | View :
                          804 | Reply :
                          8 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |  
		|  |  |  |  |  
  
    | 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ไม่ผิดครับ ขี้เกียจไล่โค๊ด บอกแบบนี้ใครจะไล่ให้ทีละบรรทัดละครับ เอา error หรือว่าอาการที่บอกว่ามันผิดมาเล่าสู่กันฟังนิดนึงครับ
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-09-26 04:36:38 | By :
                            PlaKriM |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ขอโทดทีครับ 
 คือ มันกดเพิ่มข้อมูลแล้ว มันไม่มีอะไรเกิดขึ้นเลยอ่ะครับ แต่หน้า report มีตารางให้ดูครับ
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-09-26 04:40:01 | By :
                            เด็กน้อยหัด php |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | <? $a=$_GET['a'];
 //echo "a=".$a;
 ?>
 
 เอาคอมเม้นออกซิครับ มันใช้ a == 2 หรือเปล่า
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-09-26 04:49:29 | By :
                            PlaKriM |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ครับ ใช้ a == 2 แต่ กด เพิ่มแล้ว ไม่มีอะไร เกิดขึ้นเลยครับ ไม่เพิ่มข้อมูลเลยครับ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-09-26 04:52:55 | By :
                            เด็กน้อยหัด php |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | <form id="form1" name="form1" method="post" action="?option=free&a=21"> มั้ง
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-09-26 04:54:17 | By :
                            PlaKriM |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ขอบคุณมากครับ  ผมจะได้ เอาไปปรับปรุงครับ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-09-26 04:59:28 | By :
                            เด็กน้อยหัด php |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ตกลงได้หรือไม่ได้ละ นั่นมั่วเอานะ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-09-26 05:01:24 | By :
                            PlaKriM |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ได้แล้วครับ ขอบคุณพี่ มากๆเลยครับ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-09-26 05:01:57 | By :
                            เด็กน้อยหัด php |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  |  |