Problem Implementing DataTables
Problem Implementing DataTables
Hi, thanks in advance for any help!
I am trying to implement datatables into my tables but I am not able to get the script to work. I am using WordPress and XAMPP to practice with.
So far the table shows up along with the demo_page.css styling which I implemented to test. I can't seem to find anything wrong with this..
Also, I read the forum rules and know that I should give a test case, but I am unsure how to do this. I do not think a test case would make much of a difference with this basic code.
Here is my code:
<?php
/** Template Name: DataTables */
$con=mysqli_connect("localhost","root","**","groceries");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM groceries");
?>
<!DOCTYPE html>
DataTables
@import "http://localhost/groceries/wordpress/wp-content/DataTables/media/css/demo_table.css";
$(document).ready(function(){
$('#datatables').dataTable();
})
Store
Item
Price
Location
Select
<?php
while($row = mysqli_fetch_array($result))
{
?>
<?=$row['Store']?>
<?=$row['Item']?>
<?=$row['Price']?>
<?=$row['Location']?>
<?php
}
?>
I am trying to implement datatables into my tables but I am not able to get the script to work. I am using WordPress and XAMPP to practice with.
So far the table shows up along with the demo_page.css styling which I implemented to test. I can't seem to find anything wrong with this..
Also, I read the forum rules and know that I should give a test case, but I am unsure how to do this. I do not think a test case would make much of a difference with this basic code.
Here is my code:
<?php
/** Template Name: DataTables */
$con=mysqli_connect("localhost","root","**","groceries");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM groceries");
?>
<!DOCTYPE html>
DataTables
@import "http://localhost/groceries/wordpress/wp-content/DataTables/media/css/demo_table.css";
$(document).ready(function(){
$('#datatables').dataTable();
})
Store
Item
Price
Location
Select
<?php
while($row = mysqli_fetch_array($result))
{
?>
<?=$row['Store']?>
<?=$row['Item']?>
<?=$row['Price']?>
<?=$row['Location']?>
<?php
}
?>
This discussion has been closed.
Replies
[code]$('#datatables').dataTable();
}) ; [/code]
Thanks for the input tangerine!