hi all,
i had a table with image details.so wen i click on submit button that image details should insert into assignwork table.but that is not working.

<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"];
    $query= mysql_query("SELECT id,imageid,name,size,type from images where uploadeddate='".$q."'");
    mysql_error();
    $num=mysql_num_rows($query);
$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>jack</option>
            <option>john</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>jack</option>
            <option>john</option>
            <option>rick</option>
        </select>
    </td>
</tr> 
<?php
}
    $i++;
}
?>
<br></table>
<table align="center">
<input type="submit" name="btn" value="submit">   
</table>
</form>
</body>
</html>
<?php
if(isset($_POST['btn']))
{
     $sql= mysql_query("INSERT INTO assignwork (imageid,name,size,type,assignedto,assignedby) VALUES ($imageid,$name,$size,$type,$assignedto,$_session[username])");
mysql_error();
}
?>

Actually in query for inserting we need to cal the names of that text or anything.but here how can i call them. so please can anyone help me..
Thank u.

Recommended Answers

All 8 Replies

try this

$sql= mysql_query("INSERT INTO assignwork (imageid,name,size,type,assignedto,assignedby) VALUES ('$imageid','$name','$size','$type','$assignedto','$_session[username]')");
Member Avatar for rajarajan2017
// create query 
    $query = "INSERT INTO symbols (country, animal) VALUES ('$country', '$animal')"; 
     
    // execute query 
    $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
	     
    // print message with ID of inserted record 
    echo "New record inserted with ID ".mysql_insert_id();

try this

$sql= mysql_query("INSERT INTO assignwork (imageid,name,size,type,assignedto,assignedby) VALUES ('$imageid','$name','$size','$type','$assignedto','$_session[username]')");

i tried this i am getting the values inserted as $imageid,$name,$size,$type,$assignedto like this.

rajarajan i tried as u said i got the error as query was empty.

put echo . see now all values are coming or not?

$imageid,$name,$size,$type,$assigned

i thing you didnot extrated $_POST any where

i think values are not cuming because i am getting an error as 'query was empty'.

INSERT INTO assignwork (imageid,name,size,type,assignedto,assignedby) VALUES ($imageid,$name,$size,$type,$assignedto,$_session[username])

In the above code '$imageid' should be the name and similarly $name,$type,$assignedto should be the names but i didnt mention any names for them.

Member Avatar for rajarajan2017

you came closer,

$query = "INSERT INTO symbols (country, animal) VALUES ('$country', '$animal')";

form your query as above then put the echo $query after that, now you get the result of the $query in the browser, then copy and paste the result in your sql editor of phpadmin and check whether it is running or not.

Paste your echo $query ouput here?

hi all,
i had a table with image details.so wen i click on submit button that image details should insert into assignwork table.but that is not working.

<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"];
    $query= mysql_query("SELECT id,imageid,name,size,type from images where uploadeddate='".$q."'");
    mysql_error();
    $num=mysql_num_rows($query);
$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>jack</option>
            <option>john</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>jack</option>
            <option>john</option>
            <option>rick</option>
        </select>
    </td>
</tr> 
<?php
}
    $i++;
}
?>
<br></table>
<table align="center">
<input type="submit" name="btn" value="submit">   
</table>
</form>
</body>
</html>
<?php
if(isset($_POST['btn']))
{
     $sql= mysql_query("INSERT INTO assignwork (imageid,name,size,type,assignedto,assignedby) VALUES ($imageid,$name,$size,$type,$assignedto,$_session[username])");
mysql_error();
}
?>

Actually in query for inserting we need to cal the names of that text or anything.but here how can i call them. so please can anyone help me..
Thank u.

Hello,

Just echo your query after insert query execution with using die(), And than provide that query string to us for more understanding your problem :-)

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.