-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewstable.php
47 lines (39 loc) · 1.13 KB
/
newstable.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
<?php
include('conn.php');
$query="select * from news";
$result=$con->query($query);;
//here you check to see if any data has been found and you define the width of the table
If($result){
echo "<table>
<tr>";
$i=0;
If(mysqli_num_rows($result)>0)
{
//here you fetch the data from the database and print it in the respective columns
while($i<mysqli_num_fields($result))
{
echo "<th>".mysqli_fetch_field($result)->name."</th>";
$i++;
}
echo "</tr>";
$color=1;
while($rows=mysqli_fetch_array($result, MYSQL_ASSOC))
{
If ($color==1){
echo "<tr>";
foreach ($rows as $data){
echo "<td >".$data. "</td>";
}
echo "<td >"."<a href = \"call4.php?headline=".$rows['headline']."\">"."<button> Delete News </button>". "</td>";
$color=2;
}
$color=1;
}
} else {
echo"no results found";
echo "</table>";
}
} else {
echo "error running query:".MYSQL_error();
}
?>