-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathview_table.php
More file actions
executable file
·62 lines (60 loc) · 1.54 KB
/
view_table.php
File metadata and controls
executable file
·62 lines (60 loc) · 1.54 KB
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
<?php session_start(); ?>
<html>
<head>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
echo "Welcome, <b>" . $_SESSION["username"] . "</b><p/>";
$con = mysql_connect("localhost","root","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("hos",$con);
$table_name=$_POST["table_name"];
//echo $table_name;
//echo $POST["table_name"];
$sql="Select * from " . $table_name;
$result=mysql_query($sql);
if(!$result)
echo die(mysql_error());
//echo "fine till here.";
//echo mysql_field_name($result,0);
//echo "Select the table:-";
//echo "<form action='view_table.php' method='post'>";
//echo "<select name='table_name'>";
echo "<table>";
for($i=0;$i<mysql_num_fields($result);$i++)
{
echo "<th class='spec'>" . mysql_field_name($result,$i) . "</th>";
}
$count=0;
while($row=mysql_fetch_array($result))
{
$count++;
/* echo $row["name"] . " " . $row["number"];
echo "<br/>";*/
echo "<tr>";
for($i=0;$i<mysql_num_fields($result);$i++)
{
if($count%2==0)
echo "<td>" . $row[mysql_field_name($result,$i)] . "</td>";
else
echo "<td class='alt'>" . $row[mysql_field_name($result,$i)] . "</td>";
}
// echo "<tr>";
// echo "<td>" . $row['name'] . "</td>";
// echo "<td>" . $row['number'] . "</td>";
echo "</tr>";
// echo "<option value=" . $row[mysql_field_name($result,0)] . ">" . $row[mysql_field_name($result,0)] . "</option>";
}
echo "</table>";
//echo "</select>";
//echo "<p/>";
//echo "<input type='submit' value='submit'>";
//echo "</form>";
mysql_close($con);
?>
</html>
</body>