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);
});
Related
PHP beginner here, probably bind to this mistake. Got a crud function going on here, trying to get the delete button to work. Users would currently be on the /crud/view.php. It's currently asking "do you want to delete" followed by the screen refreshing and nothing happening.
<?php
session_start();
if(isset($_SESSION['u_uid'])){
$uid = $_SESSION['u_id'];
require_once('connect.php');
$ReadSql = "SELECT * FROM `contact` WHERE users_id=$uid ORDER BY Name";
$res = mysqli_query($connection, $ReadSql);
?>
<!DOCTYPE html>
<html>
<head>
<title>Motoko</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js">
</script>
</head>
<body>
<div class="container">
<div class="row">
<table class="table">
<tr>
<th><strong>Extras</strong></th>
</tr>
<?php
while($r = mysqli_fetch_assoc($res)){
?>
<tr>
<td>Edit
</td>
<td><input type="button" onClick="deleteme(<?php echo
$r['u_uid']; ?>)" name="Delete" value="Delete"></td>
</tr>
<script language="Javascript">
function deleteme(delid)
{
if(confirm("Are you sure you want to Delete?")){
window.location.href='delete.php';
}
}
</script>
<?php } ?>
</table>
</div>
</body>
</html>
<?php
}else{
header("Location: http://motoko.sorainsurance.com.au");
}
?>
With the /delete.php being:
<?php
if(isset($_SESSION['u_uid'])){
require_once('connect.php');
$select = "DELETE from contact where id='".$_GET['del_id']."'";
$query = mysqli_query($connection, $select) or die($select);
}else{
header("Location: http://motoko.sorainsurance.com.au/crud/view.php");
}
?>
Change these lines
<input type="button" onClick="deleteme('<?php echo
$r['u_uid']; ?>')" name="Delete" value="Delete">
function deleteme(delid){
if(confirm("Are you sure you want to Delete?")){
window.location.href='delete.php?del_id='+delid;
}
}
Always preferred to write you php code at top of HTML script
<?php
session_start();
if(!isset($_SESSION['u_uid'])){
header("Location: http://motoko.sorainsurance.com.au");
}
$uid = $_SESSION['u_id'];
require_once('connect.php');
$ReadSql = "SELECT * FROM `contact` WHERE users_id=$uid ORDER BY Name";
$res = mysqli_query($connection, $ReadSql);
?>
<!DOCTYPE html>
<html>
<head>
<title>Motoko</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js">
</script>
</head>
<body>
<div class="container">
<div class="row">
<table class="table">
<tr>
<th>
<strong>Extras</strong>
</th>
</tr>
<?php while($r = mysqli_fetch_assoc($res)){ ?>
<tr>
<td>
Edit
</td>
<td>
<input type="button" onClick="deleteme('<?php echo $r['u_uid']; ?>')" name="Delete" value="Delete">
</td>
</tr>
<?php } ?>
</table>
</div>
</body>
</html>
<script language="Javascript">
function deleteme(delid){
if(confirm("Are you sure you want to Delete?")){
window.location.href='delete.php?del_id=delid';
}
}
</script>
<form>
<input type="button" value="Search Contact 1.0" onclick="window.location.href='http://motoko.sorainsurance.com.au/crud/searchone.php'" />
</form>
<form>
<input type="button" value="Search Contact 2.0" onclick="window.location.href='http://motoko.sorainsurance.com.au/crud/search.php'" />
</form>
<html>
<head>
<title>Motoko</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<table class="table">
<tr>
<th><strong>Name</strong></th>
<th><strong>Company</strong></th>
<th><strong>Title</strong></th>
<th><strong>Phone</strong></th>
<th><strong>Email</strong></th>
<th><strong>Address</strong></th>
<th><strong>Extras</strong></th>
</tr>
<?php
while($r = mysqli_fetch_assoc($res)){
?>
<tr>
<td><?php echo $r['Name']; ?></td>
<td><?php echo $r['Company']; ?></td>
<td><?php echo $r['Title']; ?></td>
<td><?php echo $r['Phone']; ?></td>
<td><?php echo $r['Email']; ?></td>
<td><?php echo $r['Address']; ?></td>
<td>Edit</td>
<td> <input type="button" onClick="deleteme(<?php echo $r['u_uid']; ?>)" name="Delete" value="Delete">
</tr>
<script language="Javascript">
function deleteme(delid) {
if(confirm("Are you sure you want to Delete?")){
window.location.href='delete.php?del_id='+delid;
}
}
</script>
<?php } ?>
</table>
</div>
</body>
</html>
<?php
}else{
header("Location: http://motoko.sorainsurance.com.au");
}
?>
Could you try ?
$select = "DELETE from contact where id='".$_GET['u_uid']."'";
I want to desing an e-music php web base application and i want to achive the forllowing:
1. on cliking on the download button the file should be downloaded
2. The number of downloads of that file should be incremented by 1
The following code show list of music i.e new releases and top downloads
<?php
$hostname_conn = "localhost";
$database_conn = "e-music";
$username_conn = "root";
$password_conn = "";
$conn = mysqli_connect($hostname_conn, $username_conn, $password_conn, $database_conn) or trigger_error(mysqli_error());
$sql="SELECT * from music INNER JOIN artist on music.a_id=artist.a_id INNER JOIN category on music.cat_id=category.cat_id order by upload_date Desc limit 0,3";
$Result= mysqli_query($conn,$sql) or die('Cannot Retrive Record' . mysqli_error());
$sql1="SELECT * from music INNER JOIN artist on music.a_id=artist.a_id INNER JOIN category on music.cat_id=category.cat_id order by downloads Desc limit 0,3";
$Result1= mysqli_query($conn,$sql1) or die('Cannot Retrive Record' . mysqli_error());
?>
<table align="center" class="table table-striped table-hover ">
<thead>
<tr>
<th colspan="3" align="center"> <h3>New Releases </h3></th>
</tr>
</thead>
<tbody>
<?php while ($row=mysqli_fetch_assoc($Result)) { ?>
<tr>
<td class="col-md-6"> <div class="col-md-2"><img src="uploads/<?php echo $row['artist_image']; ?>" class="img-responsive ims" alt="Image" >
</div>
<label> Artist: <?php echo $row['artist_name'] ?></label> <br/>
<label> Title: <?php echo $row['m_title'] ?></label> <br/>
<label>Category: Wakoin <?php echo $row['cat_name'] ?></label>
</td>
<td>
<a class="btn btn-xs btn-primary" href="download.php?did=<?php echo $row['mid'];?>"> Downloader</a>
</td>
<td class="col-md-2">
Format:<?php echo $row['m_format']; ?>
</td>
<td class="col-md-2">
File Size: <?php echo round($row['size']/1048576,2); ?> MB
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<table align="center" class="table table-striped table-hover">
<thead>
<tr>
<th colspan="3" align="center"> <h3>Top Downloads </h3></th>
</tr>
</thead>
<tbody>
<?php while ($row=mysqli_fetch_assoc($Result1)) { ?>
<tr>
<td class="col-md-6"> <div class="col-md-2"><img src="uploads/<?php echo $row['artist_image']; ?>" class="img-responsive ims" alt="Image" >
</div>
<label> Artist: <?php echo $row['artist_name'] ?></label> <br/>
<label> Title: <?php echo $row['m_title'] ?></label> <br/>
<label>Category: Wakoin <?php echo $row['cat_name'] ?></label>
</td>
<td class="col-md-2">
<a class="btn btn-xs btn-primary" href="download.php?did=<?php echo $row['mid'];?>"> Downloader</a>
</td>
<td class="col-md-2">
Format: <?php echo $row['m_format']; ?>
</td>
<td>
File Size :<?php echo round($row['size']/1048576,2); ?> MB
</td>
</tr>
<?php
}
?>
</tbody>
</table>
The code i tried for the downloads on cliking the "downloader" Button which redirects to download.php file is below:
$hostname_conn = "localhost";
$database_conn = "e-music";
$username_conn = "root";
$password_conn = "";
$conn = mysqli_connect($hostname_conn, $username_conn, $password_conn, $database_conn) or trigger_error(mysqli_error());
$did=$_GET['did'];
$sql="SELECT target from music where mid='$did'";
$Result= mysqli_query($conn,$sql) or die('Cannot Retrive Record' . mysqli_error());
$row = mysqli_fetch_assoc($Result);
// the target filed contains the directory and file name of the file to be downloaded e.g uploads/Akon_Sorry Blame.mp3
echo "<a href=". $row['target'] ." > download</a>";
$sql1="update music set download=download+1 where mid='$did";
$Result= mysqli_query($conn,$sql1) or die('Cannot Increment number of downloads' . mysqli_error());
After research on my project i am able to solve my problem using ajax. Here is the code i used to achieve my objectives
//index page
<!DOCTYPE html>
<html>
<head>
<title>E-music</title>
<link href="includes/Style.css" rel="stylesheet" type="text/css"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<script src="jQuery/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="bootstrap-3.3.7-dist/js/bootstrap.min.js" type="text/javascript"></script>
<script src="bootstrap-3.3.7-dist/js/site.js" type="text/javascript"></script>
<?php
require_once("includes/connection.php");
$sql="SELECT * from music INNER JOIN artist on music.a_id=artist.a_id INNER JOIN category on music.cat_id=category.cat_id order by upload_date Desc limit 0,3";
$Result= mysqli_query($conn,$sql) or die('Cannot Retrive Record' . mysqli_error());
$sql1="SELECT * from music INNER JOIN artist on music.a_id=artist.a_id INNER JOIN category on music.cat_id=category.cat_id order by downloads Desc limit 0,3";
$Result1= mysqli_query($conn,$sql1) or die('Cannot Retrive Record' . mysqli_error());
?>
<div id="nav">
Search For Music Audio
<p>Wakokin Hausa Na Gargajiya
</p>
</div>
<div id="section">
<table align="center" class="table table-striped table-hover ">
<thead>
<tr>
<th colspan="3" align="center"> <h3>New Releases </h3></th>
</tr>
</thead>
<tbody>
<?php while ($row=mysqli_fetch_assoc($Result)) { ?>
<tr>
<td class="col-md-6"> <div class="col-md-2"><img src="uploads/<?php echo $row['artist_image']; ?>" class="img-responsive ims" alt="Image" >
</div>
<label> Artist: <?php echo $row['artist_name'] ?></label> <br/>
<label> Title: <?php echo $row['m_title'] ?></label> <br/>
<label>Category: Wakoin <?php echo $row['cat_name'] ?></label>
</td>
<td>
<a href="<?php echo $row['target'] ?>" d="<?php echo $row['mid'] ?>" class="dload btn btn-xs btn-primary" download>Download</a>
</td>
<td class="col-md-2">
Format:<?php echo $row['m_format']; ?> <br>
Total Download: <?php echo $row['downloads']; ?>
</td>
<td class="col-md-2">
File Size: <?php echo round($row['size']/1048576,2); ?> MB
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<table align="center" class="table table-striped table-hover">
<thead>
<tr>
<th colspan="3" align="center"> <h3>Top Downloads </h3></th>
</tr>
</thead>
<tbody>
<?php while ($row=mysqli_fetch_assoc($Result1)) { ?>
<tr>
<td class="col-md-6"> <div class="col-md-2"><img src="uploads/<?php echo $row['artist_image']; ?>" class="img-responsive ims" alt="Image" >
</div>
<label> Artist: <?php echo $row['artist_name'] ?></label> <br/>
<label> Title: <?php echo $row['m_title'] ?></label> <br/>
<label>Category: Wakoin <?php echo $row['cat_name'] ?></label>
</td>
<td class="col-md-2">
<a href="<?php echo $row['target'] ?>" d="<?php echo $row['mid'] ?>" class="dload btn btn-xs btn-primary" download>Download</a>
</td>
<td class="col-md-2">
Format: <?php echo $row['m_format']; ?>
Total Download: <?php echo $row['downloads']; ?>
</td>
<td>
File Size :<?php echo round($row['size']/1048576,2); ?> MB
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
//Site.js an ajax file to handle download incrementation
$(function() {
$(".dload").click(function(){
var id = $(this).attr("d");
$.ajax({
type: "POST",
url: "count.php",
data: {id:id},
success: function(info)
{
},
error: function(){
}
});
});
});
//conut.php to handle the databae update
<?php
require_once("includes/connection.php");
$id = $_POST["id"];
$Result= mysqli_query($conn,"SELECT downloads as total FROM music WHERE mid='$id'");
$Res = mysqli_fetch_assoc($Result);
$re = $Res['total'] + 1;
$updateCount = mysqli_query($conn, "UPDATE music SET downloads= '$re' WHERE mid=$id ");
?>
I have a code :
<?php
getPriceListHeader();
function getPriceListDetail($PriceListCode)
{
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = "SELECT * FROM pricelisdetail where pricelist_code='".$PriceListCode."'";
$results = $readConnection->fetchAll($query);
echo "<table id='tbdata'>
<thead>
<tr>
<th>Price List Code</th>
<th>Price List Name</th>
<th>Effective From</th>
<th>Effective To</th>
</tr>
</thead>
<tbody> ";
foreach ($results as $row)
{
echo "<tr>";
echo "<td> ".$row[entity_id];
echo "<td> ".$row[sku];
echo "<td> ".$row[sku];
echo "<td> ".$row[sku];
};
echo " </tbody>
</table> ";
}
function getPriceListHeader()
{
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = 'SELECT * FROM pricelistheader';
$results = $readConnection->fetchAll($query);
echo "
<h2>Price List</h2>
<div>
<h3>Please select Price List</h3>
<div>
<select class='element select large' id='pricelist' name='element_2'>";
foreach ($results as $row)
{
echo '<option value="' . $row[entity_id]. '">' . $row[sku] . '</option>';
}
echo "</select>
</div>
<input type='button' class='button' name='insert' value='Get Data' onclick='getPriceListDetail(pricelist.value)'/>
";
getPriceListDetail('');
}
?>
I have a dropdown list, a button, a table
When I select a value from dropdown list, then I click button , table will be filled data again. There are 2 method, getPriceListHeader(): load data header when load the page, getPriceListDetail : load data detail when click a button. I try to put event getPriceListDetail(value) to button, but when I click, nothing happens
Please help me how to do this.
Yes, you can call php via ajax request to server like this (very simple):
Note that the following code uses jQuery
jQuery.ajax({
type: "POST",
url: 'my_php_function.php',
dataType: 'name_the_data_type',
success: function (data) {
// here you will get the response your function
}
});
and my_php_function.php like this:
<?php
// here is your php code or function
?>
from the source How can I call PHP functions by JavaScript?
You can't attach PHP function to HTML. PHP is server-side language, so after it's displayed in users browser you can't refer to PHP again, unless you reload page.
There are 3 options I think you can do:
Reload page after changing select page and using GET prepare new data.
Send all data to user browser and than show only part of it related to selected option.
Use AJAX and ask server for new data in background.
Finally, I found out the way.It works for me. Now, I do not understand the code , I am trying to read and get it clearly.
Thanks all for your comments.
$to="";
$from="";
$show_order_statuses = 0;
$orserstatus = "";
$result_order = 0;
//var_dump($results);
//return;
if(!empty($_REQUEST['filter_type']))
{
$orders_row = array();
$filter_type = $_REQUEST['filter_type'];
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = " SELECT * FROM pricelistitem where pricelist_code='".$filter_type."' ";
// $query = 'SELECT * FROM pricelistheader1';
$results = $readConnection->fetchAll($query);
foreach ($results as $rowid)
{
$result_order=10;
$orders_row[]=array($rowid['pricelist_code'],$rowid['product_code'],number_format( $rowid['unitprice'],2),$rowid['UOM']);
// $orders_row[]=array(1,1,1,1,1);
}
}
?>
<div id="anchor-content" class="middle">
<div id="page:main-container">
<div class="content-header">
<table cellspacing="0">
<tbody>
<tr>
<td style="width:50%;"><h3 class="icon-head head-report-sales-sales"><?php echo $this->__("Price List");?></h3></td>
<td class="form-buttons"><button style="" onclick="filterFormSubmit.submit()" class="scalable " type="button" id="id_<?php echo Mage::getSingleton('core/session')->getFormKey() ?>"><span>Show Report</span></button></td>
</tr>
</tbody>
</table>
</div>
<div>
<div class="entry-edit">
<form method="get" action="<?php echo Mage::helper('core/url')->getCurrentUrl();?>" id="filter_form">
<?php /*?><input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" /><?php */?>
<div class="entry-edit-head">
<h4 class="icon-head head-edit-form fieldset-legend">Filter</h4>
<div class="form-buttons"></div>
</div>
<div id="sales_report_base_fieldset" class="fieldset">
<div class="hor-scroll">
<table cellspacing="0" class="form-list">
<tbody>
<tr>
<td class="label"><label for="sales_report_filter_type">Filter By <span class="required">*</span></label></td>
<td class="value">
<select class="required-entry select" name="filter_type" id="sales_report_filter_type" onchange="myFunction();">
<?php
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = " SELECT * FROM pricelistheader ";
$results = $readConnection->fetchAll($query);
$so=1;
foreach ($results as $row)
{
$selected='';
if ($filter_type==$row[pricelist_code])
$selected= ' selected=selected';
else
$selected='';
echo '<option value="' . $row[pricelist_code]. '" '.$selected.' >' . $row[pricelist_name].' '. $row[pricelist_code] . '</option>';
}
?>
</select>
</tr>
<tr>
<td class="label"><label for="effect_from">Effect From </label></td>
<td class="value">
<?php
foreach ($results as $row)
{
if ($filter_type==$row[pricelist_code])
echo $row[pricelist_fromdate];
}
?>
</td>
</tr>
<tr>
<td class="label"><label for="effect_from">Effect To </label></td>
<td class="value">
<?php
foreach ($results as $row)
{
if ($filter_type==$row[pricelist_code])
echo $row[pricelist_todate];
}
?>
</td>
</tr>
</tbody>
<script>
function myFunction() {
// document.getElementById("tbdata").deleteRow(1);
var rowCount = tbdata.rows.length;
for (var i = rowCount - 1; i > 0; i--) {
tbdata.deleteRow(i);
}
srt.value=pricelist.options[pricelist.selectedIndex].value;
";
//$('#tbdata').empty();
}
</script>
</table>
</div>
</div>
</form>
</div>
<script type="text/javascript">
//<![CDATA[
var filterFormSubmit = new varienForm('filter_form');
//]]>
</script>
<script type="text/javascript"> new FormElementDependenceController({"sales_report_order_statuses":{"sales_report_show_order_statuses":"1"}}); </script>
<style type="text/css">
.no-display{display:none;}
</style>
</div>
<div>
<?php if($result_order>0){?>
<table cellspacing="0" class="actions">
<tbody>
<tr>
<td class="pager"> </td>
<td class="export a-right">
<form method="post" action="<?php echo $this->getUrl('*/*/exportCsv')?>" id="csv_form_customer">
<input name="form_key_customer" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
</form>
<script type="text/javascript">
//<![CDATA[
var csvFormSubmitcustomer = new varienForm('csv_form_customer');
//]]>
</script>
</td>
<td class="filter-actions a-right">
<img class="v-middle" alt="" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);?>skin/adminhtml/default/default/images/icon_export.gif"> Export to:
<select style="width:8em;" id="sales_order_grid_export_customer" name="sales_order_grid_export_customer">
<option value="<?php echo $this->getUrl('*/*/exportCsv')?>">CSV</option>
</select>
<button onclick="csvFormSubmitcustomer.submit()" class="scalable task" type="button"><span>Export</span></button>
</td>
</tr>
</tbody>
</table>
<?php } ?>
<div id="id_customer<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" class="print_customer<?php echo Mage::getSingleton('core/session')->getFormKey() ?>">
<div class="grid">
<div class="hor-scroll">
<table cellspacing="0" id="id_customer<?php echo Mage::getSingleton('core/session')->getFormKey() ?>_table" class="data">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr class="headings">
<th class=" no-link"><span class="nobr">Price List Code</span></th>
<th class=" no-link"><span class="nobr">Cust Code</span></th>
<th class=" no-link"><span class="nobr">Cust Name</span></th>
</tr>
</thead>
<tbody id="">
<?php
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = " SELECT * FROM " . $resource->getTableName('catalog/product');;
$customercount=0;
$customerresults = $readConnection->fetchAll($query);
$customerresults = Mage::getModel('customer/customer')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('erp_pricelistcode_1', $filter_type)
// ->addFieldToSelect (array('created_at','customer_id','increment_id','updated_at','status','entity_id','state'))
;
// ->addAttributeToFilter('erp_pricelistcode_1','00')->load();
$so=1;
foreach ($customerresults as $row) {
$customercount++;
}
// var_dump(#$customerresults);
if($customercount>0){
foreach($customerresults as $singlerows){
$cot=0;
{
echo "<tr>";
{
$cot++;
?>
<td>
<?php
echo $singlerows->getData('erp_pricelistcode_1');
?>
</td>
<td>
<?php
echo $singlerows->getFirstname();
?>
</td>
<td>
<?php
echo $singlerows->getName();
?>
</td>
<?php
}
echo "</tr>";
}
}
}else{
?>
<tr class="even">
<td colspan="13" class="empty-text a-center">No records found.</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
<div>
<?php if($result_order>0){?>
<table cellspacing="0" class="actions">
<tbody>
<tr>
<td class="pager"> </td>
<td class="export a-right">
<form method="post" action="<?php echo $this->getUrl('*/*/exportCsv')?>" id="csv_form">
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
</form>
<script type="text/javascript">
//<![CDATA[
var csvFormSubmit = new varienForm('csv_form');
//]]>
</script>
</td>
<td class="filter-actions a-right">
<img class="v-middle" alt="" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);?>skin/adminhtml/default/default/images/icon_export.gif"> Export to:
<select style="width:8em;" id="sales_order_grid_export" name="sales_order_grid_export">
<option value="<?php echo $this->getUrl('*/*/exportCsv')?>">CSV</option>
</select>
<button onclick="csvFormSubmit.submit()" class="scalable task" type="button"><span>Export</span></button>
</td>
</tr>
</tbody>
</table>
<?php } ?>
<div id="id_<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" class="print_<?php echo Mage::getSingleton('core/session')->getFormKey() ?>">
<div class="grid">
<div class="hor-scroll">
<table cellspacing="0" id="id_<?php echo Mage::getSingleton('core/session')->getFormKey() ?>_table" class="data">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead>
<tr class="headings">
<th class=" no-link"><span class="nobr">Price List Code</span></th>
<th class=" no-link"><span class="nobr">Product Code</span></th>
<th class=" no-link"><span class="nobr">Unit Price</span></th>
<th class=" no-link"><span class="nobr">UOM</span></th>
</tr>
</thead>
<tbody id="">
<?php
$cot=0;
if(count($orders_row)>0){
foreach($orders_row as $singlerows){
$cot=0;
if(!empty($singlerows)){
echo "<tr>";
foreach($singlerows as $value){
$cot++;
?>
<td>
<?php
if ($cot==3 )
echo "<div style='float:right;width:30%;'>";
echo $value;
echo "</div>";
?>
</td>
<?php
}
echo "</tr>";
}
}
}else{
?>
<tr class="even">
<td colspan="13" class="empty-text a-center">No records found.</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
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
I've got a search done with jQuery..
<script type="text/javascript" src="ajax.js"></script>
<div style="width:400px; margin:auto;">
<form action="clientes.php" method="post">
<legend>Procurar cliente</legend>
<input type="text" id="nome" name="nome" value="<?php echo $nome; ?>" style="width: 280px; height: 23px;" /><input type="button" name="btnPesquisar" value="Pesquisar" onclick="getDados();"/></form>
</div>
<div id="resultado"></div>
and getDados returns the results from another page, which is:
<?php
header('Content-Type: text/html; charset=utf-8');
include "conexao.php";
if ($_GET['nome']) {
$nome = $_GET['nome'];
$result = mysql_query("SELECT * FROM cliente WHERE nome LIKE '%".$nome."%' OR cpf LIKE '%".$nome."%' ORDER BY nome ASC") or die('Invalid query: ' . mysql_error());
$num_rows = mysql_num_rows($result);
}
if ($num_rows != 0) {
?>
<head><script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"> </script></head>
<script type="text/javascript">
$(document).ready(function() {
$('.hideme td').hide();
});
</script>
<table border=4 width="800px" align="center">
<tr><th>Cliente</th> <th>CPF</th> <th>Telefone</th> <th> Aniversário </th><th> Endereço </th></tr>
<?php
$i = "1";
while ($row = mysql_fetch_assoc($result)) {
?>
<TR>
<td width="220px" align="center"> <?php echo $row['nome']; ?> </td>
<td width="80px" align="center"> <?php echo $row['cpf']; ?> </td>
<td width="120px" align="center"><?php echo $row['telefone'] ?> </td>
<td width="120px" align="center"><?php echo $row['dataNascimento']; ?></a></td>
<td width="270px" align="center"><?php echo $row['endereco']; ?></td>
</TR>
<tr class="hideme"><td><form id="nomepost<?php echo $i; ?>" action="agrupaclienteteste.php" method="post">
<input type="hidden" name="nome" value="<?php echo $row['nome']; ?>"></form></td</tr>
<?php
$i++;
}
}
else{
if ($nome) { echo "Não há dados cadastrados em nosso sistema."; }
}
?>
Now.. the thing is, if I run the page of the results by itself.. lets say
result.php?nome=I
it hides the tr class=hideme...
if I access the search page and search for nome = I, it shows the results but it doesn't hide the tr class=hideme ...
Can anyone help me?
Why don't just use style="display:none;" as attribute value, since you are trying to hide onload itself