-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditattributes.php
70 lines (70 loc) · 2.42 KB
/
editattributes.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
<html>
<head>
<title>Edit Attributes</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
function askDelete(aid)
{
if (confirm("are you sure to delete this attribute?"))
{
location.href="att_delete.php?aid=" + aid;
}
}
</script>
</head>
<body>
<?php if (empty($HTTP_POST_VARS['Submit']))
{
?>
<h3><a href="managewizard.php">Main menu</a></h3>
<h3>Manage Attributes</h3>
<p></p>
<form name="data" method="post" action="editattributes.php">
<table align="center" cellspacing="0" cellpading="2" border="2" bordercolor="#003366" bgcolor="#666666">
<tr>
<th bgcolor="#ffffff"></th>
<th bgcolor="#0066CC">Attribute ID</th>
<th bgcolor="#0066CC">Attribute Text</th>
</tr>
<?php
$link = mysql_connect('localhost', 'wizard', 'g10gg') or die('could not connect to sql server');
mysql_select_db("wizard", $link);
$query = "select * from attributes";
$result = mysql_query($query, $link) or die("could not execute query $query");
while ($row = mysql_fetch_array($result))
{
?>
<tr>
<th bgcolor="#ffffff">[<a href="#" onClick="askDelete(<?php printf($row['attributeid']);?>)">Delete</a>]</td>
<th bgcolor="#ffffff"><?php printf($row['attributeid']);?></td>
<th bgcolor="#ffffff"><input type="text" name="<?php printf($row['attributeid']);?>" value="<?php printf($row['attributetext']);?>" size='100'></td>
</tr>
<?php
}
?>
<tr>
<td align="center" colspan="4" bgcolor="#ffffff"><input type="button" onclick="javascript:document.location='addnewatt.php'" name="addnew" value="Add New Attribute"><input type="submit" value="Update" name="Submit"></td></tr>
</table>
<?php
}
else
{
foreach($HTTP_POST_VARS as $key=>$val)
{
$$key = $val;
}
$link = mysql_connect('localhost', 'wizard', 'g10gg') or die('could not connect to sql server');
mysql_select_db("wizard", $link);
$query2 = "select * from attributes";
$result2 = mysql_query($query2, $link) or die("could not execute query $query2");
while($row2 = mysql_fetch_array($result2))
{
$query3 = "update attributes set attributetext = '".$$row2['attributeid']."' where licenseid = ".$row2['licenseid'];
$result3 = mysql_query($query3, $link) or die("could not execute query $query3");
}
?>
<h3 align="center">The attributes table has been successfully updated!</h3>
<h3 align="center">click <a href="managewizard.php">Here</a> to go back to the main menu</h2>
<?php }
?>
</body></html>