web 2.0

How to use PHP & Access (odbc) Edit/Update Multiple Record

How to use PHP & Access (odbc) Edit/Update Multiple Record This is tutorial  php developers how to using PHP edit/update multiple record on access table.

ShotDev Focus:
- PHP & Microsoft Access edit/update multiple record.

Example

php_access_multiple_update.php

  1. <html>  
  2. <head>  
  3. <title>ShotDev.Com Tutorial</title>  
  4. </head>  
  5. <body>  
  6. <?  
  7. $objConnect = odbc_connect("mydatabase","","");  
  8.   
  9. //*** Update Condition ***//  
  10. if($_GET["Action"] == "Save")  
  11. {  
  12. for($i=1;$i<=$_POST["hdnLine"];$i++)  
  13. {  
  14. $strSQL = "UPDATE customer SET ";  
  15. $strSQL .="CustomerID = '".$_POST["txtCustomerID$i"]."' ";  
  16. $strSQL .=",Name = '".$_POST["txtName$i"]."' ";  
  17. $strSQL .=",Email = '".$_POST["txtEmail$i"]."' ";  
  18. $strSQL .=",CountryCode = '".$_POST["txtCountryCode$i"]."' ";  
  19. $strSQL .=",Budget = '".$_POST["txtBudget$i"]."' ";  
  20. $strSQL .=",Used = '".$_POST["txtUsed$i"]."' ";  
  21. $strSQL .="WHERE CustomerID = '".$_POST["hdnCustomerID$i"]."' ";  
  22. $objQuery = odbc_exec($objConnect,$strSQL);  
  23. }  
  24. //header("location:$_SERVER[PHP_SELF]");  
  25. //exit();  
  26. }  
  27.   
  28. $strSQL = "SELECT * FROM customer";  
  29. $objExec = odbc_exec($objConnect$strSQLor die ("Error Execute [".$strSQL."]");  
  30. ?>  
  31. <form name="frmMain" method="post" action="php_access_multiple_update.php?Action=Save">  
  32. <table width="600" border="1">  
  33. <tr>  
  34. <th width="91"> <div align="center">CustomerID </div></th>  
  35. <th width="98"> <div align="center">Name </div></th>  
  36. <th width="198"> <div align="center">Email </div></th>  
  37. <th width="97"> <div align="center">CountryCode </div></th>  
  38. <th width="59"> <div align="center">Budget </div></th>  
  39. <th width="71"> <div align="center">Used </div></th>  
  40. </tr>  
  41. <?  
  42. $i =0;  
  43. while($objResult = odbc_fetch_array($objExec))  
  44. {  
  45. $i = $i + 1;  
  46. ?>  
  47. <tr>  
  48. <td><div align="center">  
  49. <input type="hidden" name="hdnCustomerID<?=$i;?>" size="5" value="<?=$objResult["CustomerID"];?>">  
  50. <input type="text" name="txtCustomerID<?=$i;?>" size="5" value="<?=$objResult["CustomerID"];?>">  
  51. </div></td>  
  52. <td><input type="text" name="txtName<?=$i;?>" size="20" value="<?=$objResult["Name"];?>"></td>  
  53. <td><input type="text" name="txtEmail<?=$i;?>" size="20" value="<?=$objResult["Email"];?>"></td>  
  54. <td><div align="center"><input type="text" name="txtCountryCode<?=$i;?>" size="2" value="<?=$objResult["CountryCode"];?>"></div></td>  
  55. <td align="right"><input type="text" name="txtBudget<?=$i;?>" size="5" value="<?=$objResult["Budget"];?>"></td>  
  56. <td align="right"><input type="text" name="txtUsed<?=$i;?>" size="5" value="<?=$objResult["Used"];?>"></td>  
  57. </tr>  
  58. <?  
  59. }  
  60. ?>  
  61. </table>  
  62. <input type="submit" name="submit" value="submit">  
  63. <input type="hidden" name="hdnLine" value="<?=$i;?>">  
  64. </form>  
  65. <?  
  66. odbc_close($objConnect);  
  67. ?>  
  68. </body>  
  69. </html>  

Create a php file and save to path root-path/myphp/

Run
http://localhost/myphp/php_access_multiple_update.php

Screenshot

PHP Microsoft Access (Edit/Update Multiple Record)

.
.
.

Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

One Response to “How to use PHP & Access (odbc) Edit/Update Multiple Record”

  1. 2forswear…

Leave a Reply

You must be logged in to post a comment.