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
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

Link to comment
Share on other sites

sorry

 

I have generated a table using php from a query

 

I've made another column generate a checkbox (not linked to database)

 

I want it so that when this is checked it updates the dispose column with the value: 'yes'

 

is that clearer?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.