Jump to content

checkbox insert into table?


Gazz1982

Recommended Posts

I have a check box, when it is ticked I want it to ("insert 'yes' into dispose where (the checkbox is in the same table <td>  </td> bit)")

 

this code needs to be executed in another php file - so it is clicked then a button is pressed which goes (location:file.php) and then that row is deleted using ("delete * from login where ($_POST('varible'))");

 

here is my code so far

 

<?php
$con = mysql_connect("localhost","root","Gnob2007");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("register", $con);

$result = mysql_query("SELECT * FROM login where VALIDATE = 'yes'");







echo "<table border='1'>
<tr>
<th>Delete</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
<th>Password</th>
<th>Company</th>
<th>Address1</th>
<th>Address2</th>
<th>Address3</th>
<th>County</th>
<th>Country</th>
<th>Post Code</th>
<th>Phone Number</th>
<th>Validate</th>


</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td><form class='small' name='login' method='post' action='delete.php?<?php echo SID?>'";
  echo "<input type='checkbox' name='Delete' value='Delete' /></p></td>";
  echo "<td>" . $row['NAME_FIRST'] . "</td>";
  echo "<td>" . $row['NAME_LAST'] . "</td>";
  echo "<td>" . $row['EMAIL'] . "</td>";
  echo "<td>" . $row['PASSWORD'] . "</td>";
  echo "<td>" . $row['COMPANY'] . "</td>";
  echo "<td>" . $row['ADDRESS1'] . "</td>";
  echo "<td>" . $row['ADDRESS2'] . "</td>";
  echo "<td>" . $row['ADDRESS3'] . "</td>";
  echo "<td>" . $row['COUNTY'] . "</td>";
  echo "<td>" . $row['COUNTRY'] . "</td>";
  echo "<td>" . $row['POST_CODE'] . "</td>";
  echo "<td>" . $row['PHONE'] . "</td>";
  echo "<td>" . $row['VALIDATE'] . "</td>";
  
  echo "</tr>";
  }
echo "</table>";

mysql_close($con);
?>

 

thanks for any help

 

 

Link to comment
https://forums.phpfreaks.com/topic/109029-checkbox-insert-into-table/
Share on other sites

Maybe it is because it is Friday, but your question does not seem real clear.

 

One thing I did notice though, is this line

 

echo "<td><form class='small' name='login' method='post' action='delete.php?<?php echo SID?>'";

 

is going to cause a syntax error for a couple reasons...

 

No need to use <?php ?> tags inside of an echo statement... you are already inside php tags :) just put the variable in like

 

echo "<td><form class='small' name='login' method='post' action='delete.php?$SID; '";

 

and also, make sure it has a semicolon

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.