TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Lebza Seeko
NA
4
470
trying to display data in dataTables table
Jul 22 2020 6:23 AM
i have a data.php code which is as follows:
and my html projects.php
<?php
include
(
"db_connection.php"
)?>
<?php
include
(
"Main_Dashboard.php"
)?>
<!DOCTYPE html>
<html lang=
"en"
>
<head>
<?php
include
(
"partials/head.php"
)?>
<meta charset=
"UTF-8"
>
<meta name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>Project Information Area</title>
</head>
<body>
<?php
include
(
"partials/add_button.php"
)?>
<hr>
<table id=
"#example"
class
=
"table-striped table-bordered"
style=
"width:100%"
>
<thead>
<tr>
<th>Municipality</th>
<th>Contact Person</th>
<th>Email</th>
<th>Phone</th>
<th>Designation</th>
<th>Department</th>
<th>Project Data</th>
</tr>
</thead>
</script>
</tbody>
</table>
<script type=
"text/javascript"
>
$(document).ready(
function
() {
$(
'#example'
).DataTable( {
"ajax"
:{
"url"
:
"data.php"
,
"dataSrc"
:
" "
},
"columns"
: [
{
"data"
:
"Municipality"
},
{
"data"
:
"Contact Person"
},
{
"data"
:
"Email"
},
{
"data"
:
"Phone"
},
{
"data"
:
"Designation"
},
{
"data"
:
"Deapartment"
},
{
"data"
:
"ProjectData"
},
]
});
});
<?php
include
(
"partials/table_script.php"
)?>
<?php
include
(
"partials/js_script.php"
)?>
</body>
</html>
<?php
$con
= mysqli_connect(
"localhost"
,
"root"
,
""
,
"solid"
);
$result
= mysqli_query(
$con
,
"SELECT municipality, contact_person, email, phone, designation, department, project_data FROM projects"
);
// Add all records into an array
$rows
=
array
();
while
(
$row
= mysqli_fetch_array(
$result
))
{
$rows
[] =
$row
;
}
echo
json_encode(
$rows
);
?>
Reply
Answers (
1
)
Loading Content display
Change iframe content with javascript in cross domain