scripts and tips or simple CRUD PHP Trick

Diposting oleh Algam on Minggu, 28 Juli 2013

Assalamualaikum ................................................. ......... :)Hi readers this first article I am ..... hahaha wow it feels incredible rich gituh ariel .. so bloggers ituh. in my first article I will ngebahas like where .. how create view update delete in the simple ............... not many strings attached for the first time we started to learn php ituh have already mastered HTML Tips transform and easy to learn HTML fast should be memorized Tag, how to link to another page and know how to use Dreamweaver guaranteed to be easy. if you want to learn to use Dreamweaver and create html table please visit the blog Book Information.HTML for us through the matter I consider the reader. :)ok ..... CEkidottttttttttttttCreate your php to CRUD database has touched .. I usually use MYSQL datbase ..Create your first database for easy copy paste ..CREATE TABLE `tb_belajar` (`Id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,`Name` VARCHAR (50) NOT NULL,`Religion` VARCHAR (50) NOT NULL) ENGINE = MYISAM;Both of you make connectionskoneksi.php<? Php$ Host = "loclahost";$ User = "root";$ Pass = "" ;/ / if there is a password please fill in MQYSL$ Dbname = "tutorial";

 
mysql_connect ($ host, $ user, $ pass);mysql_select_db ($ dbname);?>third for form input

 
form.php <? phpinclude "koneksi.php";$ Id = $ _REQUEST ['id'];$ Mode = $ _REQUEST ['mode'];if ($ mode == "edit") {
    
$ Qry = mysql_query ("select * from tb_belajar where id = $ id");
    
$ Show = mysql_fetch_array ($ qry);}?>The source code is id="form1" name="form1" method="POST" action="save.php">
  
<table width="200" border="1">
    
<tr>
      
<td width="51"> name </ td>
      
<td width="133"> <label for="textfield"> </ label>
      
<Input type = "text" name = "name" id = "textfield" value = "<? Php echo $ show [1]?>"> </ Td>
    
</ Tr>
    
<tr>
      
<td> religion </ td>
      
<td> <label for="select"> </ label>
        
<select name="agama" id="select">
          
<option value="islam"> islam </ option>
          
<option value="kristen"> kristen </ option>
          
<option value="budha"> budha </ option>
          
<option value="hindu"> hindu </ option>
      
</ Select> </ td>
    
</ Tr>
    
<tr>
      
<td> </ td>
      
<td> <input type="submit" name="save" id="save" value="Submit"> </ td>
    
</ Tr>
  
</ Table></ Form>save for the fourth syntaksave.ph<? Phpinclude "koneksi.php";$ Id = $ _REQUEST ['id'];$ Mode = $ _REQUEST ['mode'];if ($ mode == "edit") {mysql_query ("UPDATE` tb_belajar `SET` name `= '$ _POST [name]',`Religion` = '$ _POST [religion]' WHERE `id` = $ id ");Else {}
   
mysql_query ("INSERT INTO.` tb_belajar `(`Id`,`Name`,`Religion`)VALUES ('', '$ _POST [Name]', '$ _POST [religion]') ") ;/ / the contents of $ _POST [ituh text and list name in the form before}echo "<script> alert ('Data behasi in save') </ script>";echo "<script> documet.location.href = 'index.php' </ script>";?>Fifth create index for view and deleteindex.php<? Phpinclude "koneksi.php";$ Id = $ _REQUEST ['id'];$ Mode = $ _REQUEST ['mode'];if ($ mode == "delete") {
        
$ Sqlquery = "DELETE FROM` tb_belajar `WHERE` id `= '$ id'";
        
$ Querycek = mysql_query ($ sqlquery);echo "<script> alert ('Delete successfully'); </ script>";}?>The source code is name="form1" method="POST" action="">
  
<table width="200" border="1">
    
<tr>
    
<td colspan="4"> <a href="form.php"> <input type="button" name="button" id="button" value="add"> </ a> </ td>
    
</ Tr>
  
<tr>
    
<td> id </ td>
    
<td> name </ td>
    
<td> religion </ td>
    
<td> action </ td>
  
</ Tr>
  
<? Php
  
$ Sql ​​= mysql_query ("select * from tb_belajar");
  
while ($ data = mysql_fetch_array ($ sql)) {
  
?>
  
<tr>
    
<td> <? php echo $ data [0]?> </ td>
    
<td> <? php echo $ data [1]?> </ td>
    
<td> <? php echo $ data [2]?> </ td>
    
<td> <a href = "form.php & id = <? php echo $ data [0]?> & mode = edit"> <input type = "button" name = "button2" id = "button2" value = " edit "> </ a>
      
<A href = "? Mode = delete & id = <? Php echo $ data [0]?>"> <input Type="button" name="hapus" id="hapus" value="Submit"> </ a> </ td>
  
</ Tr>
  
<? Php
  
}?></ Table></ Form>

 
Hopefully Helpful for us 

allSource MYBLOG Inspirasi OF Dreams

{ 0 komentar... read them below or add one }

Posting Komentar