How to populate the html table when date is set - javascript

I'm trying to make a table which will get populated with data according to the search date. My search is working but the problem I'm having is how to get all that data into HTML table.
Below is my code which kept trying different ways.
HTML:
<?php
session_start();
include_once("../iConnect/handShake.php");
include_once ("../Functions/userCheck.php");
//TODO write the SQL to accept and retrieve the data
if (isset($_REQUEST["date"])){
$getJobs = "SELECT * FROM usertimetrack WHERE jDate = :jDate";
$getJobsQuery = $dbConnect -> prepare($getJobs);
$getJobsQuery -> bindParam(':jDate', $_REQUEST["date"]);
$getJobsQuery -> execute();
}
//$getJobs = "SELECT * FROM usertimetrack ORDER BY utId ASC";
//$getJobsQuery = $dbConnect -> query($getJobs);
?>
<html>
<head>
<!-- Style Sheets -->
<link rel="stylesheet" type="text/css" href="../../CSS/main.css">
<link rel="stylesheet" type="text/css" href="../../CSS/jquery-ui.min.css">
<!-- Java Scripts -->
<script language="JavaScript" type="text/javascript" src="../../jScripts/jquery-3.2.0.min.js"></script>
<script language="JavaScript" type="text/javascript" src="../../jScripts/jquery-ui.min.js"></script>
<script language="JavaScript" type="text/javascript" src="../../jScripts/editTimeEntryFunctions.js"></script>
</head>
<body>
<div id="divCenter" class="box">
<div class="logo">
<img src="../../images/logo.png" width="142" height="33">
</div>
<div id="mainDiv">
<div id="navi"></div>
<div id="infoi"></div>
<label for="dPicker">Date:</label>
<input type="text" id="dPicker" style="margin-left: .5%;" size="10">
<input type="button" class="getData" value="Submit">
<table id="hor-minimalist-b">
<div id="bgDimmer"></div>
<div id="divContent"></div>
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">User Name</th>
<th scope="col">Category</th>
<th scope="col">Client</th>
<th scope="col">Start Time</th>
<th scope="col">End Time</th>
<th scope="col">Time Spent</th>
<th scope="col">Volume</th>
<th scope="col">Prod. Lines</th>
<th scope="col">Remarks</th>
<th scope="col"></th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<?php while ($getJobsRow = $getJobsQuery -> fetch(PDO::FETCH_ASSOC)) { ?>
<tr>
<td><?php echo $getJobsRow["utId"]; ?></td>
<td><?php echo $getJobsRow["usrId"]; ?></td>
<td><?php echo $getJobsRow["Category"]; ?></td>
<td><?php echo $getJobsRow["Client"]; ?></td>
<td><?php echo $getJobsRow["startTime"]; ?></td>
<td><?php echo $getJobsRow["endTime"]; ?></td>
<td><?php echo $getJobsRow["timeSpent"]; ?></td>
<td><?php echo $getJobsRow["Volume"]; ?></td>
<td><?php echo $getJobsRow["noOfProductLines"]; ?></td>
<td><?php echo $getJobsRow["Remarks"]; ?></td>
<td><input type="button" class="uEdit" value="Edit" data-uid="<?php echo $getJobsRow["utId"]; ?>" /></td>
<td><input type="button" class="uDel" value="Delete" data-uid="<?php echo $getJobsRow["utId"]; ?>" /></a></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
<div id="msg"></div>
</body>
</html>
I have tried to use the below JavaScript submit the data to the same page it does work according to the browser console but it doesn't get loaded into the visible page.
JavaScript:
function getData(){
var date = document.getElementById("dPicker").value;
if(window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}else{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("POST","../functions/editTimeEntry.php?date="+date,true);
xmlhttp.send();
}
When the above code didn't work I have tried to do it using JQuery which was a dead end.
EDIT: Let me make this more simple is there any way to archive the below dirty PHP method using JavaScript or any other.
Script:
<div align="right" style="background-color:#CCC" class="noprint">
<input type="text" id="loomDate" name="loomDate" value="---Select Loom Date---" />
<script type="text/javascript">
$(function(){
$('*[name=loomDate]').appendDtpicker(
{
'dateFormat' : 'DD/MM/YYYY',
'dateOnly': true,
'closeOnSelected': true,
'autodateOnStart': false
}
);
});
</script>
<input type="button" id="Search" name="Search" value="Search" onclick="this.form.submit()" />
<input type="button" id="Print" name="Print" VALUE="Print" onclick="window.print()" />
</div>
Can someone please guide me down the path of light.
UPDATE:
Someone did show me the light so I'm going to share it with you guys here.
Finally found how to get this done thanks to PHP freshers so below is the code I'm using currently need to be refined but still, it has the basic idea.
HTML: (Main Page)
<?php
session_start();
include_once ("../Functions/userCheck.php");
?>
<html>
<head>
<!-- Style Sheets -->
<link rel="stylesheet" type="text/css" href="../../CSS/main.css">
<link rel="stylesheet" type="text/css" href="../../CSS/jquery-ui.min.css">
<!-- Java Scripts -->
<script language="JavaScript" type="text/javascript" src="../../jScripts/jquery-3.2.0.min.js"></script>
<script language="JavaScript" type="text/javascript" src="../../jScripts/jquery-ui.min.js"></script>
<script language="JavaScript" type="text/javascript" src="../../jScripts/editTimeEntryFunctions.js"></script>
</head>
<body>
<div id="divCenter" class="box">
<div class="logo">
<img src="../../images/logo.png" width="142" height="33">
</div>
<div id="mainDiv">
<label for="dPicker">Date:</label>
<input type="text" id="dPicker" style="margin-left: .5%;" size="10">
<input type="button" class="getData" value="Submit" onclick="getData();">
</div>
<div id="table"></div>
</div>
<div id="msg"></div>
</body>
</html>
HTML / PHP: (Display Page)
<?php
session_start();
include_once("../iConnect/handShake.php");
include_once ("../Functions/userCheck.php");
//TODO write the SQL to accept and retrieve the data
if (isset($_REQUEST["date"])){
$getJobs = "SELECT * FROM usertimetrack WHERE jDate = :jDate";
$getJobsQuery = $dbConnect -> prepare($getJobs);
$getJobsQuery -> bindParam(':jDate', $_REQUEST["date"]);
$getJobsQuery -> execute();
}
//$getJobs = "SELECT * FROM usertimetrack ORDER BY utId ASC";
//$getJobsQuery = $dbConnect -> query($getJobs);
?>
<html>
<head>
<!-- Style Sheets -->
<link rel="stylesheet" type="text/css" href="../../CSS/main.css">
<link rel="stylesheet" type="text/css" href="../../CSS/jquery-ui.min.css">
<!-- Java Scripts -->
<script language="JavaScript" type="text/javascript" src="../../jScripts/jquery-3.2.0.min.js"></script>
<script language="JavaScript" type="text/javascript" src="../../jScripts/jquery-ui.min.js"></script>
<script language="JavaScript" type="text/javascript" src="../../jScripts/editTimeEntryFunctions.js"></script>
</head>
<body>
<div id="mainDiv">
<div id="navi"></div>
<div id="infoi"></div>
<table id="hor-minimalist-b">
<div id="bgDimmer"></div>
<div id="divContent"></div>
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">User Name</th>
<th scope="col">Category</th>
<th scope="col">Client</th>
<th scope="col">Start Time</th>
<th scope="col">End Time</th>
<th scope="col">Time Spent</th>
<th scope="col">Volume</th>
<th scope="col">Prod. Lines</th>
<th scope="col">Remarks</th>
<th scope="col"></th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<?php while ($getJobsRow = $getJobsQuery -> fetch(PDO::FETCH_ASSOC)) { ?>
<tr>
<td><?php echo $getJobsRow["utId"]; ?></td>
<td><?php echo $getJobsRow["usrId"]; ?></td>
<td><?php echo $getJobsRow["Category"]; ?></td>
<td><?php echo $getJobsRow["Client"]; ?></td>
<td><?php echo $getJobsRow["startTime"]; ?></td>
<td><?php echo $getJobsRow["endTime"]; ?></td>
<td><?php echo $getJobsRow["timeSpent"]; ?></td>
<td><?php echo $getJobsRow["Volume"]; ?></td>
<td><?php echo $getJobsRow["noOfProductLines"]; ?></td>
<td><?php echo $getJobsRow["Remarks"]; ?></td>
<td><input type="button" class="uEdit" value="Edit" data-uid="<?php echo $getJobsRow["utId"]; ?>" /></td>
<td><input type="button" class="uDel" value="Delete" data-uid="<?php echo $getJobsRow["utId"]; ?>" /></a></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</body>
</html>
JavaScript:
$(function () {
$('#dPicker').datepicker({
dateFormat: 'dd-mm-yy',
showAnim: 'slide'
});
});
function getData(){
var date = document.getElementById("dPicker").value;
if(window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}else{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4 && xmlhttp.status==200){
document.getElementById("table").innerHTML = this.responseText;
}
};
xmlhttp.open("POST","../functions/timeEditResult.php?date="+date,true);
xmlhttp.send();}
If anyone wants to know I'm using Jquery UI for my date picker it's a very good Jquery library.
And hope this helps someone in future.

Related

Submit with one button multiple forms generated by loop

Sorry for spaghetti code :( I can't figure out why is it not working. Button submits only last form, but i want to submit every generated form. What can i do? I tried AJAX but it gives the same result. I wanted to recursively add selections but i think it's the hardest way and there is another solution.
<table id="datatable" class="table table-striped table-bordered">
<thead>
<tr>
<th>Product Name</th>
<th>Product Weight</th>
<th>Product Image</th>
<th>Status</th>
<th>Choose suplier</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<?php
foreach ($result as $k=>$v)
{
$oid[] = $v['op_id'];
$pui[] = $v['pui'];
?>
<tr>
<td><?php echo substr($v['name'], 0,10); ?></td>
<td><?php echo substr($v['gram'], 0,10); ?></td>
<td><img style="width: 50%" src="<?php echo $site_url.'images/'.$v['image']; ?>" alt=""></td>
<td><?php echo substr($v['opia'], 0,10); ?></td>
<td>
<form method="POST" enctype="multipart/form-data" id="demo-form2" data-parsley-validate oidd="<?php echo $v['pui']; ?>" class="form-horizontal form-label-left sels<?php echo $v['op_id'];?>">
<div class="form-group">
<label class="">
</label>
<div class="" style="width: 100%">
<?php
$sups = $db->prepare('SELECT * FROM product p, suplier s, prod_suplier ps WHERE p.u_id=ps.p_id AND ps.suplier_id=s.id AND p.u_id=:u_id GROUP BY s.id');
$sups->execute(array('u_id'=>$v['pui']));
$count_sups = $sups->rowCount();
if ($count_sups==1) {
$get_sups = $sups->fetch(PDO::FETCH_ASSOC);
echo $get_sups['full_name'];
} else {
?>
<select style="" name="supliers" id="">
<?php
while ($get_sup=$sups->fetch(PDO::FETCH_ASSOC)) {
?>
<option value="<?php echo $v['sfn']; ?>"><?php echo $get_sup['full_name']; ?></option>
<?php }?>
</select>
<?php } ?>
</div>
</div>
</form>
</td>
<td>
<form style=" float: right;" method="POST" action="<?php echo $site_url.$state.'delete/' ?>">
<input type="hidden" name="delid" value="<?php echo $v['oid'] ?>">
<button type="button" onclick="dsomo(this);" name="dbtn" style="color: red; background-color: rgba(0,0,0,0); border:none;" href="">
<i class="fa fa-trash fa-2x" ></i>
</button>
</form>
</td>
</tr>
<?php }?>
</tbody>
</table>
</div>
</div>
</div>
<button type="submit" id="acception" name="submit">submit</button>
<script async>
$('#acception').on('click', function () {
<?php
for ($i=0;$i<count($oid);$i++) {
?>
$("tr>td>.sels<?php echo $oid[$i];?>").submit();
<?php } ?>
})
</script>
Thanks to MojoAllmighty I found the solution. As described in the link below if I want to submit multiple forms by one button I have to assign equal classes to form and use ajax for async submitting forms. So maybe it can be marked as a duplicate of a link below.
Jquery - Submit all forms by one button

Bootstrap dataTable not working with database in Codeigniter

I am new in bootstrap and codeigniter, I don't know why dataTable not working with codeigniter.
I've tried to use it just in Bootstrap. It's working fine (pagination, data entry, sorting, and searching). But when I use it in Codeigniter with same code in my View file, it seems like datatable is not working. It does load the data, but the features (pagination, data entry, sorting, and searching) is not showing.
anybody can help me? thanks a bunches !
my old file using Bootstrap only
<table id="myTable" class="table table-hover">
<thead>
<tr>
<th>No</th>
<th>Nama</th>
<th>NPM</th>
<th>Kelas</th>
<th>MP</th>
<th>PK</th>
<th>Pesan</th>
</tr>
</thead>
<tbodys>
<?php $no=0 ; $sql=m ysqli_query($con, "SELECT * FROM form"); while($row=m ysqli_fetch_array($sql)){ $no++; ?>
<tr>
<td>
<?php echo $no ?>
</td>
<td>
<?php echo $row[ 'Nama'] ?>
</td>
<td>
<?php echo $row[ 'NPM'] ?>
</td>
<td>
<?php echo $row[ 'Kelas'] ?>
</td>
<td>
<?php echo $row[ 'MP'] ?>
</td>
<td>
<?php echo $row[ 'PK'] ?>
</td>
<td>
<?php echo $row[ 'Pesan'] ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<script>
$(document).ready(function() {
$('#myTable').DataTable();
});
</script>
here is my View file in Codeigniter + Bootstrap
<script type="text/javascript">
jQuery(function($) {
var oTable1 =
$('#dynamic-table')
.dataTable({
bAutoWidth: false,
"aoColumns": [{
"bSortable": false
},
null, null, null, null, null, null, null, {
"bSortable": false
}
],
"aaSorting": [],
});
</script>
<table id="dynamic-table" method="post" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>No</th>
<th>Nama Lengkap</th>
<th>Tanggal Mulai</th>
<th>Tanggal Akhir</th>
<th>Alasan</th>
<th>File</th>
<th>Nopeg</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php foreach ($hasil->result() as $row) { ?>
<tr>
<td>
<?php echo $row->no ?></td>
<td>
<?php echo $row->nama ?></td>
<td>
<?php echo $row->tglm ?></td>
<td>
<?php echo $row->tgla ?></td>
<td>
<?php echo $row->alasan ?></td>
<td>
<a class="thumbnail" href="<?php echo base_url().'uploads/'.$row->file ?>">
<img src="<?php echo base_url().'uploads/'.$row->file ?>" width="50" height="50">
</a>
</td>
<td>
<?php echo $row->nopeg; ?></td>
<td>
<button type="button" class="btn btn-pink btn-sm">Terima</button>
<button type="button" class="btn btn-info btn-sm">Tolak</button>
</td>
</tr>
<?php } ?>
</tbody>
</table>
the dataTable include in its template, before I display data from database, it working. But when I display data from database, it just a normal table
Put javascript code after end of table tag,
<table id="dynamic-table" method="post" class="table table-striped table- bordered table-hover">
<thead>
<tr>
<th>No</th>
<th>Nama Lengkap</th>
<th>Tanggal Mulai</th>
<th>Tanggal Akhir</th>
<th>Alasan</th>
<th>File</th>
<th>Nopeg</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php foreach ($hasil->result() as $row) { ?>
<tr>
<td>
<?php echo $row->no ?></td>
<td>
<?php echo $row->nama ?></td>
<td>
<?php echo $row->tglm ?></td>
<td>
<?php echo $row->tgla ?></td>
<td>
<?php echo $row->alasan ?></td>
<td>
<a class="thumbnail" href="<?php echo base_url().'uploads/'.$row->file ?>">
<img src="<?php echo base_url().'uploads/'.$row->file ?>" width="50" height="50">
</a>
</td>
<td>
<?php echo $row->nopeg; ?></td>
<td>
<button type="button" class="btn btn-pink btn-sm">Terima</button>
<button type="button" class="btn btn-info btn-sm">Tolak</button>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<script type="text/javascript">
jQuery(function($) {
var oTable1 =
$('#dynamic-table')
.dataTable({
bAutoWidth: false,
"aoColumns": [{
"bSortable": false
},
null, null, null, null, null, null, null, {
"bSortable": false
}
],
"aaSorting": [],
});
</script>
Try like this :)

how can i make print button that will print a report?

I'm doing on a project but my problem is that i don't have any idea on how to make a print button to print my report..the report is in a table..can somebody please help me with this one?my question is how can i add a button for printing?
here is my code for the viewing of specific record
<?php
include_once 'dbconfig.php';
$username = isset($_GET['username']) ? $_GET['username'] : '';
$password = isset($_GET['password']) ? $_GET['password'] : '';
$province = isset($_GET['province']) ? $_GET['province'] : '';
if(isset($_GET['user_id']))
{
$user_id = $_GET['user_id'];
extract($crud->getID($user_id));
}
?>
<body>
<div id="Survey-view">
<div id="header">
</div>
<p><strong>INFORMATION</strong></p>
<hr />
<div id="main-frame">
<table id="information-content" cellspacing="0">
<thead>
<tr>
<th>Username</th>
<th>Password</th>
<th>Province</th>
</tr>
<tbody>
<tr>
<td><?php echo $username; ?></td>
<td><?php echo $password; ?></td>
<td><?php echo $province; ?></td>
</tr>
</tbody>
</thead>
</table>
</div>
<br />
<br />
<p><strong>ASP</strong></p>
<hr />
<div id="asp">
<table id="asp-content" cellspacing="0">
<thead>
<tr>
<th>Date Survey</th>
<th>Date Submitted</th>
<th>Date Approved</th>
<th>Date Recv'd by Region</th>
<th>Date Recv'd by DARPO</th>
</tr>
<tbody>
<tr>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
</tr>
</tbody>
</thead>
</table>
</div><!-- End of asp-->
<br />
<br />
<p><strong>DENR/DARPO</strong></p>
<hr />
<div id="denrdarpo">
<table id="denrdarpo-content" cellspacing="0">
<thead>
<tr>
<th>Date Survey</th>
<th>Date Submitted</th>
<th>Date Approved</th>
<th>Date Recv'd by Region</th>
<th>Date Recv'd by DARPO</th>
</tr>
<tbody>
<tr>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
<td><?php echo $username; ?></td>
</tr>
</tbody>
</thead>
</table>
</div><!--End of denrdarpo-->
<br />
<br />
<p><strong>OTHERS</strong></p>
<hr />
<div id="others">
<table id="others-content" cellspacing="0">
<tr>
<td>Project Number</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
<td>Module Number</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
</tr>
<tr>
<td>Fund Year</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
<td>LAD Target</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
</tr>
<tr>
<td>Land Category</td>
<td><select disabled>
<option><?php echo $username; ?></option>
</select></td>
<td>LAnd Type</td>
<td><select disabled>
<option><?php echo $username; ?></option>
</select></td>
</tr>
<tr>
<td>Date Reported</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
<td>Date Suspended</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
</tr>
<tr>
<td>Date Completed</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
<td>Number of Lots</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
</tr>
<tr>
<td>Station</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
<td>Contractor</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
</tr>
<tr>
<td>Agency</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
<td>Cert 40</td>
<td><input type="text" value="<?php echo $username; ?>" disabled></td>
</tr>
</table>
</div>
</div>
</body>
Every time I need to do this I go to my old Gmail account, print a page and then view the source code cus I'm too lazy to remember the functions..
This is how Google does it.
<script type="text/javascript">// <![CDATA[
document.body.onload=function(){document.body.offsetHeight;window.print()};
// ]]></script>
You could just as easily attach it to a button instead of doing it on load.
<button onclick="document.body.offsetHeight;window.print();">Print</button>
Here's a working example.
And this one will remove the button from the printed page:
<button onclick="this.style.display='none';document.body.offsetHeight;window.print();this.style.display='inline';">Print</button>
And another example.
<html>
<head>
<script type="text/javascript">
function openWin()
{
var myWindow=window.open('','','width=200,height=100');
myWindow.document.write("<p>This is 'myWindow'</p>");
myWindow.document.close();
myWindow.focus();
myWindow.print();
myWindow.close();
}
</script>
</head>
<body>
<input type="button" value="Open window" onclick="openWin()" />
</body>
</html>

Css works on dreamweaver but not on chrome

i'm trying to make a table with html and php code which displays dynamically data, above that i use css for this table, and when i use live mode on dreamweaver it displays perfectly the table with css but empty, but not on chrome or whatever is the web browser, and actually i try to integrate the whole html and css in a ready template.
for the information this is the html code that i used:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div class="background">Placez ici le contenu de class "background"
<center>
<h1>VOS SOUMISSIONS</h1>
<table width="1327" height="128" border="2" cellpadding="20" cellspacing="10">
<tr>
<th width="208">SENDER</th>
<th width="258">TYPE</th>
<th width="258">TITRE</th>
<th width="290">AUTEUR</th>
<th width="289">ABSTRACT</th>
<th width="289">KEYWORDS</th>
<th width="289">DATE</th>
<th width="289">FICHIER</th>
</tr>
<?php
//On recupere les identifiants, les pseudos et les emails des utilisateurs
$result = mysql_query("SELECT * FROM manusrit where id='".$_SESSION["id"]."'");
while($row = mysql_fetch_array($result))
{
?>
<tr>
<td class="left"><?php echo $row['sender']; ?></td>
<td class="left"><?php echo $row['type']; ?></td>
<td class="left"><?php echo htmlentities($row['titre'], ENT_QUOTES, 'UTF-8'); ?></td>
<td class="left"><?php echo htmlentities($row['auteur'], ENT_QUOTES, 'UTF-8'); ?></td>
<td class="left"><?php echo $row['abstract']; ?></td>
<td class="left"><?php echo $row['keywords']; ?></td>
<td class="left"><?php echo $row['date']; ?></td>
<td class="left"><?php echo $row['file']; ?></td>
<td class="left"><form action="/Application/soumissions/<?php echo $row['file']; ?>" method="post">
<input type="submit" value="Download" />
</form></td>
<?php
}
?>
</tr>
</table>
<p> </p><h2><strong>LES AUTRES SOUMISSIONS</strong></h2>';
<table width="1346" height="128" border="2" cellpadding="20" cellspacing="10">
<tr>
<th width="208">SENDER</th>
<th width="258">TYPE</th>
<th width="258">TITRE</th>
<th width="290">AUTEUR</th>
<th width="289">ABSTRACT</th>
<th width="289">KEYWORDS</th>
<th width="289">DATE</th>
<th width="289">FICHIER</th>
<th width="41">ETAT</th>
<th width="84">DECISION</th>
<th width="101">RAPPORT</th>
<th width="120">TELECHARGER</th>
</tr>
<?php
//On recupere les identifiants, les pseudos et les emails des utilisateurs
$req = mysql_query("SELECT * FROM manusrit where id2='1' AND id3='".$_SESSION["id3"]."'");
while (($rows=mysql_fetch_array($req)))
{
?>
<tr>
<td class="left"><?php echo $rows['sender']; ?></td>
<td class="left"><?php echo $rows['type']; ?></a></td>
<td class="left"><?php echo htmlentities($rows['titre'], ENT_QUOTES, 'UTF-8'); ?></td>
<td class="left"><?php echo htmlentities($rows['auteur'], ENT_QUOTES, 'UTF-8'); ?></a></td>
<td class="left"><?php echo $rows['abstract']; ?></td>
<td class="left"><?php echo $rows['keywords']; ?></td>
<td class="left"><?php echo $rows['date']; ?></td>
<td class="left"><?php echo $rows['file']; ?></td>
<td class="left"><?php echo $rows['etat']; ?></td>
<td class="left"><?php echo $rows['decision']; ?></td>
<td class="left"><form action="/Application/rapport/<?php echo $row['rapport']; ?>" method="post">
<input type="submit" value="Voir le rapport" />
</form></td>
<td class="left"><form action="/Application/soumissions/<?php echo $rows['file']; ?>" method="post">
<input type="submit" value="Download" />
</form></td>
<?php
}
?>
</tr>
</table>
</center>
</div>
</body>
</html>
And this is the css code:
.background {
font-family: "Courier New", Courier, monospace;
font-size: 12px;
font-style: italic;
color: #FFF;
background-color: #666;
background-repeat: repeat;
width: 1327px;
}
Thnx for your help!
Presuming that the html provided is your full document, you don't have the css file included. You will need to add
<link rel="stylesheet" type="text/css" href="style.css">
before the end of the head tag. Also the href attribute must be whatever your css file is actually named.

unable to auto refresh two tables in HTML

I would like to ask, why I can't able to refresh two html tables? only 1? is there something wrong with the Javascript code? I already tried to declare 2 variables and tried to create to script for each and still no luck and I tried to change the variables name to unique one but still no luck. My full code below:
<!-- SALES.HTML -->
<div class="col-sm-5 shadow">
<p>
<h3><center>Hyukies</center></h3>
<center>Catbalogan, City</center>
<center><span class="glyphicon glyphicon-time"></span> <?php include('time.php'); ?></center> <br />
<div id="transactions_left">
<?php include_once('salestable.php')?>
</div>
</p>
<div class="row">
<div class="col-sm-12"><b>
<p>
<?php include_once('sales_count.php')?>
<script>
var table = $("#salestableid");
var refresh = function() {
table.load("salestable.php", function() {
setTimeout(refresh, 1);
});
};
refresh();
var table1 = $("#sales_countid");
var refresh1 = function() {
table.load("sales_count.php", function() {
setTimeout(refresh1, 1);
});
};
refresh1();
</script>
<button type="button" class="btn btn-danger btn-md" data-toggle='modal' data-target='#cancel'>Cancel</a>
<button type="button" class="btn btn-warning btn-md" data-toggle='modal' data-target='#hold'>Hold</button>
<button type="button" class="btn btn-success btn-md pull-right" data-toggle='modal' data-target='#payment' >Payment</button>
<br /><br />
<center>Thank you and have a Nice day!</center>
</p>
</div>
</div>
</div>
<!-- End of Page SALES.HTML -->
<!-- SALESTABLE.PHP -->
<?php require_once("../includes/db_connection.php"); ?>
<table class="table table-hover" id='salestableid'>
<thead>
<tr class= "default" style="background-color: #e18728">
<th><font color = "white">Action</font></th>
<th width="200"><font color = "white">Product</th>
<th><font color = "white">Quantity</th>
<th width="75"><font color = "white">Price</th>
<th width ="90"><font color = "white">Total</th>
</tr>
</thead>
<tbody>
<tr>
<?php
$user_query = mysqli_query($connection, "SELECT saleslog.itemid, saleslog.qty, saleslog.date, saleslog.total, saleslog.id, items.`name`, items.description, items.retailprice FROM saleslog LEFT JOIN items ON items.id = saleslog.itemid")or die(mysqli_error());
while($row = mysqli_fetch_array($user_query)){
$id = $row['id'];
?>
<tr>
<td></td>
<td><?php echo $row['name']; ?></td>
<td>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<?php echo $row['qty']; ?></td>
<td>&nbsp<?php echo number_format($row['retailprice'],2); ?></td>
<?php
$total = $row['qty'] * $row['retailprice'];
?>
<td><?php echo number_format($total,2); ?></td>
</tr>
<?php } ?>
</tr>
</tbody>
</table>
<!-- End of Page SALESTABLE.PHP -->
<!--SALES_COUNT.PHP -->
<?php require_once("../includes/db_connection.php"); ?>
<?php
$count_client= mysqli_query($connection, "SELECT * FROM saleslog");
$count = mysqli_num_rows($count_client);
?>
<?php
$totalsales= mysqli_query($connection, "SELECT SUM(total) AS totalpritems FROM saleslog");
while($totalperitems = mysqli_fetch_array($totalsales)){
$total_sales = $totalperitems['totalpritems'];
}
?>
<table class='table' style="border-style: dotted" id="sales_countid">
<tr class='' style="border-style: dotted">
<td width="50" >Total Items: </td>
<td width="50"align="right"><?php echo $count; ?></td>
<td width="50" >Total: </td>
<td width="50"align="right" >P <?php echo number_format($total_sales,2); ?></td>
</tr>
<tr class='' style="border-style: dotted">
<td width="50">Discount: </td>
<td width="50"align="right">0.00 </td>
<td width="50">Tax: </td>
<td width="50"align="right">0.00 </td>
</tr>
<tr style="border-style: dotted">
<td width>Total Payable: </td>
<td align="right">P <?php echo number_format($total_sales,2); ?></td>
<td></td>
<td></td>
</tr>
</table>
<!--End of Page SALES_COUNT.PHP -->
In your refresh code for table1, you refresh table instead.
table1.load(...) instead of table.load(...) in the code below.
var table1 = $("#sales_countid");
var refresh1 = function() {
table.load("sales_count.php", function() {
setTimeout(refresh1, 1);
});
};

Categories