I have a php page to present in a table characteristics after you select a name in a dropbox. But when you make a selection all the page is reloaded and dublicate the upper div that I have.
<?php include("datalogin.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ιατρείο Πόνου</title>
<!-- Add jQuery library -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<!-- Add fancyBox -->
<link rel="stylesheet" href="fancybox/source/jquery.fancybox.css?v=2.1.5" type="text/css" media="screen" />
<script type="text/javascript" src="fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
<!-- Optionally add helpers - button, thumbnail and/or media -->
<link rel="stylesheet" href="fancybox/source/helpers/jquery.fancybox-buttons.css?v=1.0.5" type="text/css" media="screen" />
<script type="text/javascript" src="fancybox/source/helpers/jquery.fancybox-buttons.js?v=1.0.5"></script>
<script type="text/javascript" src="fancybox/source/helpers/jquery.fancybox-media.js?v=1.0.6"></script>
<link rel="stylesheet" href="fancybox/source/helpers/jquery.fancybox-thumbs.css?v=1.0.7" type="text/css" media="screen" />
<script type="text/javascript" src="fancybox/source/helpers/jquery.fancybox-thumbs.js?v=1.0.7"></script>
<link href="template.css" rel="stylesheet" type="text/css" />
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js?ver=1.4.2"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/interface.js"></script>
<script>
function showDetails(id)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("details").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","patients.php?q="+id,true);
xmlhttp.send();
}
</script>
<?php
date_default_timezone_set("Europe/Athens");
?>
<script type="text/javascript">
function checkWindowSize() {
if ( $(window).height() > 800 ) {
document.getElementById('sidebar').class="large");
$('sidebar').addClass('large');
}
else {
$('body').removeClass('large');
}
}
$(window).resize(checkWindowSize);
</script>
<!--[if lt IE 7]>
<style type="text/css">
div, img { behavior: url(iepngfix.htc) }
</style>
<![endif]-->
</head>
<body onload="checkWindowSize();">
<div>
<div id="sidebar">
<p align="center" style="font-size:21px">Ιατρείο Πόνου<br/>Σελίδα Διαχείρισης</p>
<?php if( (session_is_registered("username")) ) {?>
<p align="center" style="font-size:19px;">Καλως ήλθες <b><span class="yellow"><?php echo $_SESSION['username'];?></span></b>. <br/> Αποσύνδεση</p>
<?php } ?>
<ul id="main-nav">
<li>Ασθενείς </li>
<li>Επιτυχόντες </li>
<li>Σχέδια </li>
<li>Ρυθμίσεις Λογαριασμού</li>
</li>
</ul>
<div id="top_menu">
<ul id="links" class="clear">
<li>Η ΣΧΟΛΗ ΜΑΣ</li>
<li>ΑΡΧΙΤΕΚΤΟΝΙΚΗ-ΤΕΙ</li>
<li>ΚΑΛΩΝ ΤΕΧΝΩΝ</li>
<li>PORTFOLIO</li>
<li>ΣΧΕΔΙΑ</li>
<li>ΣΧΟΛΕΣ ΜΕ ΣΧΕΔΙΟ</li>
<li>ΑΝΑΚΟΙΝΩΣΕΙΣ</li>
<li>ΕΠΙΤΥΧΟΝΤΕΣ</li>
<li>FAQ</li>
<li>ΕΠΙΚΟΙΝΩΝΙΑ</li>
</ul>
</div>
</div>
<div id="main-content">
<div class="dock" id="dock">
<div class="dock-container">
<a class="dock-item" href="patients.php"><img src="images/announcement.png" alt="Ανακοινώσεις" /><span>Ανακοινώσεις</span></a>
<a class="dock-item" href="success.php"><img src="images/success.png" alt="Επιτυχόντες" /><span>Επιτυχόντες</span></a>
<a class="dock-item" href="gallery.php"><img src="images/gallery.png" alt="Σχέδια" /><span>Σχέδια</span></a>
<a class="dock-item" href="settings.php"><img src="images/settings.png" alt="Ρυθμίσεις Λογαριασμού" /><span>Ρυθμίσεις Λογαριασμού</span></a>
</div>
</div>
<script type="text/javascript">
$(document).ready(
function()
{
$('#dock').Fisheye(
{
maxWidth: 64,
items: 'a',
itemsText: 'span',
container: '.dock-container',
itemWidth: 50,
proximity: 90,
halign : 'center'
}
)
}
);
</script>
<h2>Ασθενείς</h2>
<div align="right"><table><tr><td align="center"><img src="images/new.png" alt="Νέα Ανακοίνωση"/></td></tr><tr><td>Νέος Ασθενής</td></tr></table></div>
<p></p>
<div align="center" id='details'>Επιλέξτε Ασθενή:
<select name="users" onchange="showDetails(this.value)">
<option value="result">Select</option>
<?php
$id=$_GET['q'];
echo $result = mysql_query("SELECT pa_id, pa_surname, pa_name FROM patient ORDER BY pa_surname");
while ($row = mysql_fetch_array($result))
{
echo "<option value='".$row["pa_id"]. "'";
if($row["pa_id"]==$id) { echo " selected";}
echo ">".$row["pa_surname"]." ".$row["pa_name"]."</option>";
}?>
</select>
</div>
<?php
$details_query= mysql_query("SELECT * FROM patient WHERE pa_id='".$id."'");
while ($details = mysql_fetch_array($details_query))
{ ?>
<p></p>
<div align="center">
<table width="100%" class="box-table-a">
<tr>
<th colspan="5"><div align="center">Στοιχεία Ασθενή</div></th>
</tr>
<tr>
<td>Όνομα :</td>
<td><?php echo $details['pa_name'];?></td>
</tr>
<tr>
<td>Επίθετο :</td>
<td><?php echo $details['pa_surname'];?></td>
</tr>
<tr>
<td>Φύλλο :</td>
<td>
<?php
$sex_query= mysql_query("SELECT * FROM sex WHERE sex_id='".$details['sex_id']."'");
$sex1 = mysql_fetch_array($sex_query);
echo $sex1['sex_name'];?></td>
</tr>
<tr>
<td>Ημερ/νία Γέννησης :</td>
<td>
<?php
$phpdate = strtotime( $details['pa_birth'] );
$mysqldate = date( 'd-m-Y', $phpdate );
echo $mysqldate;
echo " ";
$bday = new DateTime($details['pa_birth']);
// $today = new DateTime('00:00:00'); - use this for the current date
$today = new DateTime(); // for testing purposes
$diff = $today->diff($bday);
printf('( %d Ετών )', $diff->y);
?>
</td>
</tr>
<tr>
<td >Διεύθυνση κατοικίας :</td>
<td><?php echo $details['pa_address'];?></td>
</tr>
<tr>
<td>Περιοχή :</td>
<td><?php echo $details['pa_area'];?></td>
</tr>
<tr>
<td>Πόλη :</td>
<td><?php echo $details['pa_city'];?></td>
</tr>
<tr>
<td>Τ.Κ. :</td>
<td><?php echo $details['pa_tk'];?></td>
</tr>
<tr>
<td>Τηλέφωνο :</td>
<td><?php echo $details['pa_tel'];?></td>
</tr>
<tr>
<td>Κινητό :</td>
<td><?php echo $details['pa_tel2'];?></td>
</tr>
<tr>
<td>E mail :</td>
<td><?php echo $details['pa_mail'];?></td>
</tr>
<tr>
<td>Ταμείο :</td>
<td>
<?php
$asfalisi_query= mysql_query("SELECT * FROM asfalisi WHERE asfalisi_id='".$details['asfalisi_id']."'");
$asfalisi1 = mysql_fetch_array($asfalisi_query);
echo $asfalisi1['asfalisi_name'];?></td>
</tr>
<tr>
<td>Παραπέμπων Ιατρός:</td>
<td><?php echo $details['doctor_come'];?></td>
</tr>
<tr>
<td>Ιστορικό :</td>
<td><?php echo $details['pa_history'];?></td>
</tr>
<tr>
<td>Φάρμακα που έπερνε :</td>
<td><?php echo $details['pa_farmaka'];?></td>
</tr>
<tr>
<td>Σχόλια :</td>
<td><?php echo $details['pa_com'];?></td>
</tr>
<tr>
<td>Πάθηση :</td>
<td>
<?php
$pathisi1= mysql_query("SELECT path_id FROM meeting WHERE pa_id= 1 ORDER BY path_id DESC LIMIT 1");
$pathisi2 = mysql_fetch_array($pathisi1);
$pathisi_query= mysql_query("SELECT * FROM pathiseis WHERE path_id='".$pathisi2['path_id']."'");
$pathisi = mysql_fetch_array($pathisi_query);
echo $pathisi['path_name'];?></td>
</tr>
<tr>
<td>Θεραπεία :</td>
<td>
<?php
$therapy1= mysql_query("SELECT ther_id FROM meeting WHERE pa_id= 1 ORDER BY ther_id DESC LIMIT 1");
$therapy2 = mysql_fetch_array($therapy1);
$therapy_query= mysql_query("SELECT * FROM therapy WHERE ther_id='".$therapy2['ther_id']."'");
$therapy = mysql_fetch_array($therapy_query);
echo $therapy['ther_name'];?></td>
</tr>
</table>
<p></p>
<table width="100%" class="box-table-a">
<tr>
<th colspan="2"><div align="center">Εξετάσεις</div></th>
</tr>
<?php
$result1 = mysql_query("SELECT * FROM document WHERE pa_id='".$id."'");
while ($row = mysql_fetch_array($result1)) {
?>
<tr>
<td><?php echo "<li><a href='eggrafa/".$id."/".$row['document_link']."' target='blank'>".$row['document_title']."</a></li> ";?></td>
<?php } ?>
</tr>
</table>
<p></p>
<table width="100%" class="box-table-a">
<tr>
<th colspan="2"><div align="center">Επισκέψεις</div></th>
</tr>
<?php
$result2 = mysql_query("SELECT * FROM meeting WHERE pa_id='".$id."' ORDER BY meet_id ASC ");
while ($row2 = mysql_fetch_array($result2)) {
?>
<tr>
<td colspan="2"><?php echo "<li><a href='meeting.php?id=".$row2['meet_id']."' class='fancybox'>";$phpdate = strtotime( $row2['meet_date'] );
$mysqldate = date( 'd-m-Y', $phpdate );
echo $mysqldate;"</a></li> ";?></td>
<?php } ?>
</tr>
<tr>
<th colspan="2"><div align="center">Επόμενο ραντεβού</div></th>
</tr>
<?php
$result3 = mysql_query("SELECT * FROM meeting WHERE pa_id='".$id."' ORDER BY meet_id DESC LIMIT 1" );
$result4 = mysql_fetch_array($result3);{
?>
<tr>
<td width="20%">Ημερομηνία:</td>
<td><?php $phpdate2 = $result4['next_date'] ;
if(($result4['next_date'])=='0000-00-00')
{
$mysqldate3 ='Δεν έχει καθοριστεί επόμενο ραντεβού';
echo $mysqldate3;
}
else
{
$mysqldate3 = date('d-m-Y', strtotime($result4['next_date']));
echo $mysqldate3;
}
?>
</td>
</tr>
</tr>
<tr>
<td width="20%">Τοποθεσία :</td>
<td>
<?php
$company_query8= mysql_query("SELECT * FROM mplace WHERE mp_id='".$result4['mp3_id']."'");
$company8 = mysql_fetch_array($company_query8);
echo $company8['mp_name'];?></td>
</tr>
<?php } ?>
</table>
</div>
<?php } ?>
<p></p>
<p></p>
</div>
</div>
</body>
</html>
so i want to reload after the "Επιλέξτε Ασθενή:"
help please
Related
Hi i want to implement DataTable in the table to populate data from my db in my php page, the below code i used, but its not working, not getting the data table, instead i am getting the normal table only -
<head>
<link rel="stylesheet" type="text/css" href="../DataTables-1.10.7/media/css/jquery.dataTables.min.css">
<script src="../DataTables-1.10.7/media/js/jquery.dataTables.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="../DataTables-1.10.7/extensions/Responsive/css/dataTables.responsive.css">
<script src="../DataTables-1.10.7/extensions/Responsive/js/dataTables.responsive.js" type="text/javascript"></script>
</head>
<div id="example_wrapper" class="dataTables_wrapper" role="grid">
<div class="fg-toolbar ui-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix">
<?php
$sql="select product_id,product_name,original_price,offer_price,product_rating,image_main,stock_in_hand from niad_products order by product_id desc";
$result=$linkID1->query($sql);
$c=#mysqli_num_rows($result);
if($c>=1){?>
<script>
$(document).ready(function() {
$('#example').DataTable( {
responsive: true
} );
} );
</script>
<div id="printable">
<table id="example" class="display" cellspacing="0" width="100%" style="color:#FFF">
<thead>
<tr>
<th>Image</th>
<th>Product Name</th>
<th>Original Price</th>
<th>Offer Price</th>
<th>Rating</th>
<th>Stock</th>
</tr>
</thead>
<tbody>
<?php while($row=mysqli_fetch_array($result)){?>
<tr>
<td>
<?php echo "<img width='100' height='100' src=../product-images/".$row['image_main'] ." />"; ?></td>
<td>
<?php echo $row['product_name']; ?>
</td>
<td>
<?php echo $row['original_price']; ?>
</td>
<td>
<?php echo $row['offer_price']; ?>
</td>
<td>
<?php echo $row['product_rating']; ?>
</td>
<td>
<?php echo $row['stock_in_hand']; ?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<?php } else {echo "No records";} ?>
</div>
</div>
Can anyone guide me with my mistake. It will be very helpful. Thanks
I am trying to echo more than one item on an invoice for the same customer. I am able to echo them from the database, but instead of each item being echoed on the same invoice (on different rows), it echoes the full invoice 2 times (or more depending on how many items are on the invoice) with each item on each invoice. Below is my code (I have not yet cleaned the code up. I am leaving that step once the code works).
<?php include "database_connection.php" ?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>DPB quote</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex, nofollow">
<link rel="stylesheet" href="css/bootstrap.min.css"><!--erase this link once the app is completed-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel='stylesheet' type='text/css' href='css/style2.css' />
<link rel='stylesheet' type='text/css' href='css/print.css' media="print" />
<script type='text/javascript' src='js/jquery-1.3.2.min.js'></script>
<script type='text/javascript' src='js/example.js'></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.dataTables.min.js"></script>
<script src="js/dataTables.bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css"><!--search pagination and delete reference link-->
<script type="text/javascript" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script><!--search pagination and delete reference link-->
</head>
<body>
<?php
$statement = $connect->prepare("
SELECT * FROM tbl_order
WHERE order_id = :order_id
LIMIT 1
");
$statement->execute(
array(
':order_id' => $_GET["id"]
)
);
$result = $statement->fetchAll();
foreach($result as $row)
{
?>
<script>
$(document).ready(function(){
$('#order_no').val("<?php echo $row["order_no"]; ?>");
$('#order_date').val("<?php echo $row["order_date"]; ?>");
$('#order_receiver_name').val("<?php echo $row["order_receiver_name"]; ?>");
$('#address_line_1').val("<?php echo $row["address_line_1"]; ?>");
$('#address_line_2').val("<?php echo $row["address_line_2"]; ?>");
$('#city').val("<?php echo $row["city"]; ?>");
$('#state').val("<?php echo $row["state"]; ?>");
$('#zip_code').val("<?php echo $row["zip_code"]; ?>");
$('#phone_number').val("<?php echo $row["phone_number"]; ?>");
$('#email').val("<?php echo $row["email"]; ?>");
$('#notes').val("<?php echo $row["notes"]; ?>");
});
</script>
<form method="post" id="invoice_form">
<div class="container">
<?php
$statement = $connect->prepare("
SELECT * FROM tbl_order_item
WHERE order_id = :order_id
");
$statement->execute(
array(
':order_id' => $_GET["id"]
)
);
$item_result = $statement->fetchAll();
$m = 0;
foreach($item_result as $sub_row)
{
$m = $m + 1;
?>
<!--QUOTATION APP 2 STARTS HERE-->
<div id="page-wrap">
<textarea id="header">Quotation</textarea>
<div id="identity">
<textarea id="address">Discount Plastic Bags
7750
Suite
Irving
Phone: </textarea>
<div id="logo">
<div id="logohelp">
(max width: 540px, max height: 300px)
</div>
<img id="image" src="images/dpblogo3.png" alt="logo" />
</div>
</div>
<div style="clear:both"></div>
<div id="customer">
<!--<form id="quote_date" class="" action="index.php" method="post">-->
<tr>
<td><textarea placeholder="Enter Customer Information" id="address" name="company_info"></textarea></td>
</tr>
<table id="meta">
<tr>
<td class="meta-head">Invoice #</td>
<td><textarea>000123</textarea></td>
</tr>
<tr>
<td class="meta-head">Date</td>
<td><textarea placeholder="enter quotation date" name="quote_date"></textarea></td>
</tr>
<tr>
<td class="meta-head">Amount Due</td>
<td><textarea placeholder="enter amount due" name="amount_due"></textarea></td>
</tr>
</table>
</div>
<table id="items">
<tr>
<th>SKU</th>
<th>Description</th>
<th>Quantity</th>
<th>Unit Cost</th>
<th>Price</th>
</tr>
<tr class="item-row">
<!--<td><span id="sr_no"><?php //echo $m; ?></span></td>-->
<td><input type="text" name="sku[]" id="sku<?php echo $m; ?>" class="item-name" value="<?php echo $sub_row["sku"]; ?>" /></td>
<td><input type="text" name="item_name[]" id="item_name<?php echo $m; ?>" class="description" value="<?php echo $sub_row["item_name"]; ?>" /></td>
<td><input type="text" name="order_item_quantity[]" id="order_item_quantity<?php echo $m; ?>" data-srno="<?php echo $m; ?>" class="qty" value = "<?php echo $sub_row["order_item_quantity"]; ?>" /></td>
<td><input type="text" name="order_item_price[]" id="order_item_price<?php echo $m; ?>" data-srno="<?php echo $m; ?>" class="cost" value="<?php echo $sub_row["order_item_price"]; ?>" /></td>
<td><input type="text" name="order_item_final_amount[]" id="order_item_final_amount<?php echo $m; ?>" data-srno="<?php echo $m; ?>" readonly class="price" value="<?php echo $sub_row["order_item_final_amount"]; ?>" /></td>
</tr>
<tr>
<td colspan="2" class="blank"></td>
<td colspan="2" class="total-line">Subtotal</td>
<td class="total-value"><textarea id="subtotal" name="subtotal"></textarea></td>
</tr>
<tr>
<td colspan="2" class="blank"></td>
<td colspan="2" class="total-line">Total</td>
<td class="total-value"><textarea name="total" id="total"></textarea></td>
</tr>
<tr>
<td colspan="2" class="blank"> </td>
<td colspan="2" class="total-line">Amount Paid</td>
<td class="total-value"><textarea id="paid">$0.00</textarea></td>
</tr>
<tr>
<td colspan="2" class="blank"> </td>
<td colspan="2" class="total-line balance">Balance Due</td>
<td class="total-value balance"><textarea name="balance_due" class="due"> </textarea></td>
</tr>
</table>
<div id="terms">
<h5>Notes</h5>
<textarea name="notes" placeholder="enter quotation notes" rows="12" style="font-size: 15pt"></textarea>
</div>
</div>
</form>
</body>
</html>
<?php
}
}
?>
I would do something like this. This is not tested and just an example of how I do it. There are a few other ways but this works best for me
// other needed code above
$results = sqlsrv_query($link, $query);
//query returns one value for these
echo "<table>";
echo "<tr> ";
echo "<td>".$name."</td>";
echo "<td>".$store."</td>";
echo "</tr>";
//start your multiple items row
while($row=sqlsrv_fetch_array($results))
{
$items = $row['items'];
echo "<tr> ";
echo "<td>".$items."</td> ";
echo "</tr>";
}
echo "<tr> ";
echo "<td>".$cost."</td>";
echo "<td>".$other."</td>";
echo "</tr>";
echo "</table> ";
//other code for the rest of the page below
Result would be:
Bob Bob's Store
ITEM
ITEM
ITEM
$50.00 other
This is very quick.
I have a form that when submitted should add user input into my DB. I have had a similar form working well but for some reason this one is not working.
Please excuse my sloppy code but here is the whole page. For some reason 'observation' will not take the user input and display it on the next page (showOne.php). The next page simply shows a blank space for observation and I checked the DB and there was nothing in the observation field of course.
Is it something simple that I can't see? I've been at this for days since it is identical to another form I have that works well on another page.
Thank you for any insight.
<?php
//including the database connection file
include("config.php");
$activePage = "start.php";
if(isset($_POST['update'])) {
$id = $_POST['id'];
$observation = $_POST['observation'];
$result = mysqli_query($mysqli, "UPDATE tasks SET observation='$observation' WHERE id=$id");
header("Location: showOne.php?id=$id");
}
//getting id from url
$id = $_GET['id'];
//selecting data associated with this particular id
$result2 = mysqli_query($mysqli, "SELECT * FROM users WHERE id=$id ORDER BY id ASC");
$result = mysqli_query($mysqli, "SELECT * FROM tasks ORDER BY taskNumber ASC");
include_once "nav.php";
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Pathfinder - A User Testing Dashboard</title>
<meta name="description" content="Pathfinder - A User Testing Dashboard">
<meta name="author" content="James Stables - Thurs April 13th 2017">
<link rel="stylesheet" href="core.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600,700" rel="stylesheet">
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"> </script>
<![endif]-->
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
</head>
<body>
<header>
<h1 class="logo"><img src="images/logo.png">Pathfinder</h1>
<h4>User Testing Dashboard</h4>
</header>
<section class="nonav">
<div class="showAllUsers">
<table border='0'>
<tr>
<?php while($res = mysqli_fetch_array($result2))
{ ?>
<td class="widthHundred no-border left"><h2><?php echo $res['nameFirst']; ?></h2></td>
<?php } ?>
</tr>
</table>
<table border='0'>
<thead>
<tr>
<th>Image</th>
<th>Category</th>
<th>Task Number</th>
<th>Task Name</th>
<th>Observation</th>
<td> </td>
<td> </td>
<td> </td>
</tr>
</thead>
<tbody>
<form name="start" method="post" action="start.php" enctype="multipart/form-data">
<tr>
<td><a href="<?php echo $res['$image'];?>" data-lightbox="example-1" data-title="Task Number <?php echo $res['taskNumber'];?>">
<img id="imageResize" src="<?php echo $res['image'];?>" /></a></td>
<td><?php echo $res['category'];?></td>
<td><?php echo $res['taskNumber'];?></td>
<td><?php echo $res['taskName'];?></td>
<td><input type="text" name="observation" value="<?php echo $res['observation'];?>"></td>
<td> </td>
<td> </td>
<td> </td>
<?php } ?>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><input type="hidden" name="id" value="<?php echo $_GET['id'];?>"><input type="submit" class="buttonUpdate right" name="update" value="Update"></td>
<td><a class="buttonCancel right" href="tasks.php" onClick="return confirm('Cancel and go back?')">Cancel</a></td>
</tr>
</form>
</tbody>
</table>
</div>
</section>
<script src="js/lightbox-plus-jquery.min.js"></script>
<script>
lightbox.option({
'resizeDuration': 200,
'showImageNumberLabel': false,
'fitImagesInViewport': true
})
</script>
</body>
</html>
I'm trying to insert Bootstrap pagination to my dynamic table content which I extract from my database as below, but nothing works:
<?php
$sn = $_POST["SN"];
$Reference = $_POST["Reference"];
$Libelle = $_POST["Libelle"];
$NOMENCLATURE = $_POST["NOMENCLATURE"];
$matricule = $_POST["matricule"];
include "./Connections/localhost.php";
$sqlTous = "
select mat.SN, mat.NOMENCLATURE, mat.ID_materiel, mat.Reference, mat.Date_affectation, mat.libelle, mat.Date_Acquisition, mat.Fournisseur,mat.commentaire, mat.Contrat from materiel mat
left join user usr on usr.ID_User = mat.ID_User ";
?>
<div>
<form method="post" action="./consultation.php" id="formClient">
<h4 class="widgettitle" width="10%" >Résultat</h4>
<br/>
<table class="table table-striped" id="example" class="display">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<?php
$reponse3 = mysql_query($sqlTous);
while ($rowMat1 = mysql_fetch_array($reponse3)) { ?>
<tbody class="table table-striped" id="example" class="display">
<tr>
<td><?php echo $rowMat1['SN']; ?></td>
<td><?php echo $rowMat1['NOMENCLATURE']; ?></td>
<td><?php echo $rowMat1['Reference']; ?></td>
<td><?php echo $rowMat1['libelle']; ?> </td>
<td><?php echo $rowMat1['Date_Acquisition']; ?></td>
<td><?php echo $rowMat1['Date_affectation']; ?></td>
</tr>
</tbody>
<?php } ?>
</table>
</form>
<script>
$(document).ready(function() {
$('#example').DataTable();
} );
</script>
In addition, i have included the following js and css files:
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Recherche matériel</title>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.10/css/dataTables.bootstrap.min.css" type="text/css" />
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.10/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.10/js/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/jquery-migrate-1.1.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.9.2.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
There are some problems with your code:
tbody element shouldn't have id and class attributes and should be outside of the while loop.
You're including jquery-1.9.1.min.js twice.
<tbody>
<?php
$reponse3 = mysql_query($sqlTous);
while ($rowMat1 = mysql_fetch_array($reponse3)) { ?>
<tr>
<td><?php echo $rowMat1['SN']; ?></td>
<td><?php echo $rowMat1['NOMENCLATURE']; ?></td>
<td><?php echo $rowMat1['Reference']; ?></td>
<td><?php echo $rowMat1['libelle']; ?> </td>
<td><?php echo $rowMat1['Date_Acquisition']; ?></td>
<td><?php echo $rowMat1['Date_affectation']; ?></td>
</tr>
<?php } ?>
</tbody>
I have a problem. I want to display every "subject" (titles) in the page and not only the first one like now. When I add a new message, index only displays the first one, and only when I click on the "open" button I can see all the messages.
Any suggestion?
Many thanks.
This is de code:
<?php
require_once("config.php");
if (isset($_SESSION['username']) === FALSE){
header('location:login.php');
exit();
}
$where = "";
$searchCriteria = "";
if (isset($_GET['search']) && $_GET['search'] != '') {
$searchCriteria = mysql_real_escape_string($_GET['search']);
$where = " WHERE subject LIKE '%" . $searchCriteria . "%'";
$where .= " OR message like '%" . $searchCriteria . "%'";
}
$sql = "SELECT * FROM notes " . $where . " LIMIT 30";
$result = mysql_query($sql);
?>
<!DOCTYPE html>
html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
</head>
<body>
Logout<br/><br/>
<div id="wrapper">
<div id="add-message">
<img src="images/add.png" title="Add"> Add a New Message
</div>
<br>
<?php
while ($row = mysql_fetch_assoc($result)) {
?>
<?php echo $row['subject']; ?>
<input type="button" id="opener" value="Open"/>
<div id="playbox">
<table id="general">
<thead>
<tr>
<th class="general-header"></th>
<th class="general-subject">Subject</th>
<th class="general-message">Message</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4" class="general-foot"><input type="button" id="closer" value="Close"/></td>
</tr>
</tfoot>
<tbody>
<tr>
<td>
<img src="images/edit.png" title="Edit"> Edit
|
<img src="images/delete.png" title="Delete"> Delete
</td>
<td class="subject"><?php echo $row['subject']; ?></td>
<td><?php if ($row['filename']!=''){?>
<img align="right" width="300px" src="<?php echo $row['filename']; ?>" />
<?php } ?>
<?php echo $row['message']; ?>
</td>
</tr>
</tbody>
<?php
}
?>
</table>
</div>
</div>
</body>
</html>
<script>
$(document).ready(function(){
$("#playbox").hide();
$("#opener").click(function(){
$("#playbox").slideDown(600);
});
$("#closer").click(function(){
$("#playbox").slideUp(600);
});
});
</script>
I think you should use mysql_num_rows for that and you don't have need that you create many open and close buttons in while loop, just add this once like if you records then, for that you have to add if condition like if(mysql-num_rows($result))
Full Code
<?php
require_once("config.php");
if (isset($_SESSION['username']) or $_SESSION['username']=== FALSE){
header('location:login.php');
exit();
}
$where = "";
$searchCriteria = "";
if (isset($_GET['search']) && $_GET['search'] != '') {
$searchCriteria = mysql_real_escape_string($_GET['search']);
$where = " WHERE subject LIKE '%" . $searchCriteria . "%'";
$where .= " OR message like '%" . $searchCriteria . "%'";
}
$sql = "SELECT * FROM notes " . $where . " LIMIT 30";
$result = mysql_query($sql);
?>
<!DOCTYPE html>
html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
</head>
<body>
Logout<br/><br/>
<div id="wrapper">
<div id="add-message">
<img src="images/add.png" title="Add"> Add a New Message
</div>
<br>
<?php
if(mysql_num_rows($result))
{
?>
<input type="button" id="opener" value="Open"/>
<div id="playbox">
<table id="general">
<thead>
<tr>
<th class="general-header"></th>
<th class="general-subject">Subject</th>
<th class="general-message">Message</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4" class="general-foot"><input type="button" id="closer" value="Close"/></td>
</tr>
</tfoot>
<?php
while ($row = mysql_fetch_assoc($result)) {
?>
<?php echo $row['subject']; ?>
<tbody>
<tr>
<td>
<img src="images/edit.png" title="Edit"> Edit
|
<img src="images/delete.png" title="Delete"> Delete
</td>
<td class="subject"><?php echo $row['subject']; ?></td>
<td><?php if ($row['filename']!=''){?>
<img align="right" width="300px" src="<?php echo $row['filename']; ?>" />
<?php } ?>
<?php echo $row['message']; ?>
</td>
</tr>
</tbody>
<?php
}
?>
</table>
</div>
<?php
}
?>
</div>
</body>
</html>
<script>
$(document).ready(function(){
$("#playbox").hide();
$("#opener").click(function(){
$("#playbox").slideDown(600);
});
$("#closer").click(function(){
$("#playbox").slideUp(600);
});
});
</script>
If you want to toggle it separately then you have to code like,
HTML
Let there are two records Create the HTML like using while loop
<div class="contentSubject">
<input type="button" class="btnOpener" value="Open" />
<div class="playbox">
<!--your table goes here-->
</div>
</div>
<div class="contentSubject">
<input type="button" class="btnOpener" value="Open" />
<div class="playbox">
//your table goes here
</div>
</div>
SCRIPT
<script>
$(document).ready(function(){
$(".playbox").hide();
$(".btnOpener").click(function(){
$(this).closest('.contentSubject')
.find(".playbox").slideDown(600);
});
// same code for close
});
</script>
please try that code
$("#opener").live("click",function(){
$("#playbox").slideDown(600);
});