-
Notifications
You must be signed in to change notification settings - Fork 0
/
form-update-data.php
45 lines (41 loc) · 1.61 KB
/
form-update-data.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<pre>
<?php
//nama file: form-update-<?php echo $_SESSION['tblname'];?>.php
//libatkan file kelas-<?php echo $_SESSION['tblname'];?>.php
require("kelas-<?php echo $_SESSION['tblname'];?>.php");
//buat objek data
$data = new <?php echo $_SESSION['tblname']; ?>();
//panggil fungsi pilih dari file kelas-<?php echo $_SESSION['tblname'];?>.php
//variabel $id diambil dari nilai parameter <b>id=</b> pada address bar
//hasil pemanggilan disimpan di variabel $isi
$id=$_GET['id'];
$isi=$data->pilih($id);
?>
//sesuaikan teks tercetak tebal;
<form action='proses-<?php echo $_SESSION['tblname']; ?>.php?proses=update' method='post'>
<table align='center' width='50%' >
<?php
for($i=0;$i<$_SESSION['da'];$i++){
if($i==0){$ro="readonly";}else{$ro="";}
if($_SESSION['data'][$i][1]!='enum'){
echo "<tr><td>". $_SESSION['data'][$i][0]."</td><td>:<input type='text' name='".$_SESSION['data'][$i][0]."' value='<?php echo \$isi['$i']; ?>' ".$ro." ></td></tr><br />";
}else{
$jd=explode(",",$_SESSION['data'][$i][2]);
echo "<tr><td>".$_SESSION['data'][$i][0]."</td><td>:<select name='".$_SESSION['data'][$i][0]."'><br />";
for($opt=0;$opt<count($jd);$opt++)
{
echo "\t<option value=".$jd[$opt]."><b>".str_replace("'","",$jd[$opt])."</b></option><br />";
}
echo "</select></td></tr><br />";
}
}
?>
<tr><td> </td><td>
<input type='submit' value='Update'>
<input type='reset' value='Reset'>
</td></tr>
</table>
</form>
</pre>
<tr>
<td>