1. < ? php
2. // STEP 1. CREATE DATABASE
3. // --------------------------------------------------------------------------------
4. // create database : eod
5. // create table : tbproduk
6. // create field on table tbproduk :
7. // idp kprod nprod hprod sprod gprod tprod pstatus pview pstock
8. // --------------------------------------------------------------------------------
9. // STEP 2. ACTIVATE OF DATABASE
10. // --------------------------------------------------------------------------------
11. $db_hname = "localhost"; //hosting name of database
12. $db_uname = "root"; //user name of database
13. $db_pword = ""; //password of user database
14. $db_name = "eod"; // database name
15. $link = mysql_connect($db_hname, $db_uname, $db_pword) or die("Not Success ....!");//connection of database
16. if (!$link) { die('Could not connect: ' . mysql_error()); } //error handling possiblity
17. mysql_select_db($db_name); //select function for database selection to using
18.
19. // --------------------------------------------------------------------------------
20. // STEP 3. ACTIVATE THE TABLE
21. // --------------------------------------------------------------------------------
22. $tb_produk = mysql_query("SELECT * FROM tbproduk");
23. $rtb_produk = mysql_num_rows($tb_produk);
24. echo 'Product Information
';
25. for ($i=1;$i<=$rtb_produk;$i++){
26. // STEP 4. VIEW THE RECORD OF TABLE
27. $tbv_product = mysql_fetch_array($tb_produk);
28. // some of script must using :: mysql_fetch_array('tb_produk')
29. // update php.ini
30. // --------------------------------------------------------------------------------
31. echo 'Product : '.$i.'< br >';
32. echo 'Name : '.$tbv_product['nprod'].'< br >';
33. echo 'ID : '.$tbv_product['kprod'].'< br >';
34. echo 'Price : USD '.number_format($tbv_product['hprod'], 2, '.', ',').'< br >';
35. echo 'Stock : '.$tbv_product['pstock'].'< br >';
36. echo '---------------------------------------------------------------------------< br >';
37.
38. }
39. // --------------------------------------------------------------------------------
40. // With the script above, then the entire data record will appear on web pages.
41. // --------------------------------------------------------------------------------
42. // --------------------------------------------------------------------------------
43. ? >
No comments:
Post a Comment