<?php
$connect
= mysqli_connect(
"localhost"
,
"root"
,
""
,
"article_geeksdata"
);
$query
=
"SELECT * FROM geeksdata"
;
$result
= mysqli_query(
$connect
,
$query
);
?>
<!DOCTYPE html>
<html>
<head>
<script src=
</script>
<link rel=
"stylesheet"
href=
<script src=
</script>
</head>
<body>
<div
class
=
"container"
style=
"width:900px;"
>
<h2 align=
"center"
>Geeks
for
Geeks</h2>
<h3 align=
"center"
>
Export data into CSV from Data Base
</h3>
<br />
<!-- After clicking on submit button
export.php code is revoked -->
<form method=
"post"
action=
"export.php"
align=
"center"
>
<input type=
"submit"
name=
"export"
value=
"CSV Export"
class
=
"btn btn-success"
/>
</form>
<br />
<!-- Code
for
table because our data is
displayed in tabular format -->
<div
class
=
"table-responsive"
id=
"employee_table"
>
<table
class
=
"table table-bordered"
>
<tr>
<th width=
"5%"
>UserID</th>
<th width=
"35%"
>Name</th>
<th width=
"10%"
>Article</th>
<th width=
"20%"
>Article Type</th>
<th width=
"5%"
>Published
Date
</th>
</tr>
<?php
while
(
$row
= mysqli_fetch_array(
$result
)) {
?>
<!-- taking attributes
and
storing
in table cells -->
<tr>
<!-- column names in table -->
<td><?php
echo
$row
[
"user_id"
]; ?></td>
<td><?php
echo
$row
[
"name"
]; ?></td>
<td><?php
echo
$row
[
"article"
]; ?></td>
<td><?php
echo
$row
[
"article_type"
]; ?></td>
<td><?php
echo
$row
[
"published_date"
]; ?></td>
</tr>
<?php
}?>
</table>
<!-- Closing table tag -->
</div>
<!-- Closing div tag -->
</div>
</body>
</html>