-
Notifications
You must be signed in to change notification settings - Fork 4
/
getproduct.php
74 lines (65 loc) · 2.49 KB
/
getproduct.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
$id=$_GET["id"];
$action=$_GET["action"];
if (strlen($id) >0) {$flag=TRUE;}
else $flag=FALSE;
if ($action == "edit") {$edit=TRUE;}
else $edit=FALSE;
if($flag){
$con = mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("ram_db", $con);
$result = mysql_query("SELECT * FROM products
WHERE productid=\"".$id."\"");
while($row = mysql_fetch_array($result))
{
$prodid = $row['ProductID'];
$name = $row['Name'];
$type = $row['Type'];
$pivot = $row['Pivot'];
$material = $row['Material'];
$price = $row['Price'];
$notes = $row['Notes'];
}
}
if( $flag && (strlen($prodid) > 0) ){
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" href="style.css" type="text/css"/>
<script type="text/javascript">
function editProduct(){
window.location="getproduct.php?<?php echo "id=".$id."&action=edit\""?>;
}
function updateProduct(){
alert("updated!");
}
</script>
</head>
<body>
<div class="tblReg">
<form onsubmit="return false;">
<table>
<tr><td>קוד מוצר:</td><td> <input type="text" name="productID" id="prodid" value="<?php echo $prodid; ?>" <?php (!$edit) ? print "readonly" :print "";?>/></td></tr>
<tr><td>שם מוצר:</td><td><input type="text" name="name" id="name" value="<?php echo $name; ?>" <?php (!$edit) ? print "readonly" :print "";?>/></td></tr>
<tr><td>סוג:</td><td><input type="text" name="type" id="type" value="<?php echo $type; ?>" <?php (!$edit) ? print "readonly" :print "";?>/></td></tr>
<tr><td>ציר:</td><td><input type="text" name="pivot" id="pivot" value="<?php echo $pivot; ?>" <?php (!$edit) ? print "readonly" :print "";?>/></td></tr>
<tr><td>חומר:</td><td><input type="text" name="material" id="material" value="<?php echo $material; ?>" <?php (!$edit) ? print "readonly" :print "";?>/></td></tr>
<tr><td>מחיר:</td><td><input type="text" name="price" id="price" value="<?php echo $price; ?>" <?php (!$edit) ? print "readonly" :print "";?>/></td></tr>
<tr><td>הערות:</td><td><Textarea name="notes" id="notes" cols=40 rows=6 <?php (!$edit) ? print "readonly" :print "";?>> <?php print str_replace("\"",""",$notes); ?></textarea></td></tr>
</table>
<?php if(!$edit) { ?>
<input type="submit" value="ערוך" onclick="editProduct()">
<?php }
elseif ($edit) { ?>
<input type="submit" value="שמור" onclick="updateProduct()">
<?php } ?>
</form>
</div>
</body>
</html>
<?php } ?>