hi all,
i had a page in which list of images can be seen by selecting some date. so now in that table i am having a dropdown of users. so if i select a user and click submit that username, imagename,size,type should be stored in database,but i cant store in my databse. so can any one help me.
Initially page is(check doc0)

1.after selecting a date my page looks like(check doc1).

2.after selecting a user from dropdown i clicked on submit button, now page appears as (check doc2).
so what i need is when click on submit button all that row should get stored.

<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> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;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 value="#"><b>SELECT</b></option>
            <option value="sss">sss</option>
            <option value="john">john</option>
            <option value="jack">jack</option>
            <option value="smith">smith</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 name="assignedto">
            <option value="#"><b>SELECT</b></option>
            <option value="sss">sss</option>
            <option value="john">john</option>
            <option value="jack">jack</option>
            <option value="smith">smith</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 "Bingooooooo";
   // $sql= mysql_query("INSERT INTO assignwork (imageid,name,size,type,assignedto,assignedby) VALUES ($imageid,$name,           $size,$type,$assignedto,$_SESSION[username])");
    // $result = mysql_query($sql) or die ("Error in query: $sql. ".mysql_error());
    // echo "New record inserted with ID ".mysql_insert_id();
}
?>
</form>
</body>
</html>

hi,

where is your ajax page?

do you get any errors?

what are those errors?

where is your ajax code?

Thanks for your response,
This is the code for calling the ajax page.the above one is the useajax.php.

<?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("GET","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 onload="addRowListeners();">
<form action="imageslist.php" method="post">
<table align="right"> 
    <tr> <td></td>
        <td></td><td><a href="logout.php"><h2>Logout</h2></a></td></table>
<div class="demo" align="left">
<h2>Choose Uploaded date <input name="dates" type="text" id="datepicker" onchange="showUser(this.value)">
</h2>
</div>
<br>
<div align="center" id="txtHint"><h1>Images information will be listed here.</h1></div>
<table align="center"><tr><td>  
</table> 
</form>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.