show.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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>Untitled Document</title>
</head>
<body>
<?php
define('SMARTY_DIR', './smarty/');
require_once(SMARTY_DIR. 'Smarty.class.php');
$smarty = new Smarty();
mysql_connect('localhost', 'root', '');
mysql_select_db('Track');
$smarty -> assign('title', 'Tracktors');
if (isset($_POST['id'])) {
if ($result = mysql_query("SELECT * FROM Tracktors WHERE id =".$_POST['id'])) {
if ($myrow = mysql_fetch_array($result)) {
echo '<form action="edit.php" method="POST">';
echo '<input type="text" name="name" value="'.$myrow['name'].'">';
echo '<input type="text" name="corp" value="'.$myrow['corp'].'">';
echo '<input type="text" name="country" value="'.$myrow['country'].'">';
echo '<input type="text" name="year" value="'.$myrow['year'].'">';
echo '<input type="text" name="dealer" value="'.$myrow['dealer'].'">';
echo '<input type="text" name="ch" value="'.$myrow['ch'].'">';
echo '<input type="hidden" name="id_edit" value="'.$_POST['id'].'">';
echo '<input type="submit" value="OK">';
echo '</form>';
}
}
}
if ($result = mysql_query("SELECT * FROM Tracktors")){
while ($myrow = mysql_fetch_array($result)) {
echo '<form method="POST">';
echo "Название : ".$myrow['name']."<br>";
echo "Корпорация : ".$myrow['corp']."<br>";
echo "Страна : ".$myrow['country']."<br>";
echo "Год : ".$myrow['year']."<br>";
echo "Поставщик : ".$myrow['dealer']."<br>";
echo "Ответственный : ".$myrow['ch']."<br>";
echo '<input type="hidden" name="id" value="'.$myrow['id'].'">';
echo '<input type="submit" value="&#1048;&#1079;&#1084;&#1077;&#1085;&#1080;&#1085;&#1080;&#1077;">'."<br>";
echo '</form>';
}
}
else {
echo "ERROR!";
exit();
}
?>
</body>
</html>