My page contains a date picker. so when i select a date, a table with list of images uploaded on that date wil be displayed.so for that i used ajax. so here is my problem wen i select a date, table appears and in that table a dropdown of users is present. so wen i select some user and click submit button, the table that is present is disappearing due to page refreshing and i am not getting any value. so can anyone help me please...
Thank u.
<?php
@session_start();
echo "<strong style='color:navy'><h2>Welcome $_SESSION[username].</h2></strong>";
?>
<html>
<script type="text/javascript">
function showUser(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
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("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST","useajax.php?q="+str,true);
xmlhttp.send();
}
</script>
<head>
<link rel="stylesheet" type="text/css" href="css/table.css"/>
<meta charset="UTF-8" />
<link rel="stylesheet" href="css/base.css" type="text/css" media="all" />
<link type="text/css" href="css/jquery.ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="jquery-1.4.2.js"></script>
<script type="text/javascript" src="ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="ui/jquery.ui.datepicker.js"></script>
<link type="text/css" href="css/demos.css" rel="stylesheet" />
<script type="text/javascript">
$(function() {
$("#datepicker").datepicker();
});
</script>
</head>
<body>
<form>
<table align="right">
<tr> <td></td>
<td></td><td><a href="logout.php"><h2>Logout</h2></a></td></table>
<div class="demo" align="center">
<h2>Choose Uploaded date <input name="dates" type="text" id="datepicker" onchange="showUser(this.value)"></h2>
</div>
<br>
<?php
?>
<div align="center" id="txtHint"><h1>Images information will be listed here.</h1></div>
</form>
</body>
</html>
---useajax.php----
<html>
<body>
<link rel="stylesheet" type="text/css" href="css/table.css"/>
<form action="useajax.php" method="post">
<table align="center" id="customers" style="width: 90%">
<tr>
<th>S.no</th>
<th>Imageid</th>
<th>Name</th>
<th>Size</th>
<th>Type</th>
<th>Assigned to</th>
</tr>
<?php
include 'connection.php';
$q=$_GET["q"];
//$query1= mysql_query("select name from users where role in (2,3)");
// mysql_error();
//$result=mysql_query($query1);
//$options="";
//while ($row=mysql_fetch_array($result))
// {
// $assignedto=$row["name"];
// $options.="<option value='".$assignedto."'>".($assignedto == $_POST['assignedto'].'selected="selected"'.'') . $assignedto .'</option>';
//}
$query= mysql_query("SELECT id,imageid,name,size,type from images where uploadeddate='".$q."'");
mysql_error();
$num=mysql_num_rows($query);
if($num==0)
{
echo "<strong style='color:red'><center><h2> NO image uploaded on this date</h2></center></strong> ";
}
else
{
$i=0;
while ($i < $num){
$f1=mysql_result($query,$i,"id");
$f2=mysql_result($query,$i,"imageid");
$f3=mysql_result($query,$i,"name");
$f4=mysql_result($query,$i,"size");
$f5=mysql_result($query,$i,"type");
if($i%2==0)
{
?>
<tr class="">
<td><?php echo $f1;?></td>
<td><?php echo $f2; ?></td>
<td><?php echo $f3; ?></td>
<td><?php echo $f4; ?></td>
<td><?php echo $f5; ?></td>
<td>
<select name="assignedto">
<option><b>SELECT</b></option>
<option>sss</option>
<option>john</option>
<option>jack</option>
<option>rick</option>
</select>
</td>
</tr>
<?php
}
else
{
?>
<tr class="alt">
<td><?php echo $f1;?></td>
<td><?php echo $f2; ?></td>
<td><?php echo $f3; ?></td>
<td><?php echo $f4; ?></td>
<td><?php echo $f5; ?></td>
<td>
<select>
<option><b>SELECT</b></option>
<option>sss</option>
<option>john</option>
<option>jack</option>
<option>rick</option>
</select>
</td>
</tr>
<?php
}
$i++;
}
?>
<br></table>
<table align="center">
<input type="submit" name="btn" value="submit">
</table>
<?php
}
if(isset($_POST['btn']))
{
echo "bingoooo";
}
?>
</form>
</body>
</html>
here wen i click submit button it goes to line 94. i am not getting this echo also..