-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathindex.php
36 lines (36 loc) · 1.06 KB
/
index.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
<html>
<head>
<title>My first PHP website</title>
</head>
<body>
<?php
echo "<p>Hello World!</p>";
?>
<a href="login.php">Click here to login</a> <br/>
<a href="register.php">Click here to register</a>
</body>
<br/>
<h2 align="center">List</h2>
<table width="100%" border="1px">
<tr>
<th>Id</th>
<th>Details</th>
<th>Post Time</th>
<th>Edit Time</th>
</tr>
<?php
mysql_connect("localhost", "root","") or die(mysql_error()); //Connect to server
mysql_select_db("first_db") or die("Cannot connect to database"); //connect to database
$query = mysql_query("Select * from list Where public='yes'"); // SQL Query
while($row = mysql_fetch_array($query))
{
Print "<tr>";
Print '<td align="center">'. $row['id'] . "</td>";
Print '<td align="center">'. $row['details'] . "</td>";
Print '<td align="center">'. $row['date_posted']. " - ". $row['time_posted']."</td>";
Print '<td align="center">'. $row['date_edited']. " - ". $row['time_edited']. "</td>";
Print "</tr>";
}
?>
</table>
</html>