Thanks thats worked!
I'm still having a little trouble with the next bit.
I have a search field that searches a small database and returns the results in a table:
Code: Select all
<?php
mysql_connect ("localhost", "MyUsername", "MyPassword") or die (mysql_error());
mysql_select_db ("enquiries");
$search1 = $_POST['search1'];
$sql = mysql_query("select * FROM enquiry WHERE surname LIKE '%$search1%'");
echo "Your search for '<u><strong>$search1</strong></u>' returned the following results:<br />";
echo "<br />";
print ('<table style="border-width: thin; border-style: solid; border-color: grey; cellpadding=1; border-width: 2px;">');
print '<tr bgcolor="grey">';
print '<td width="3%"><t><strong>ID</strong></t></td>';
print '<td width="9%"><t><strong>ENTRY DATE</strong></t></td>';
print '<td width="4%"><t><strong>TITLE</strong></t></td>';
print '<td width="9%"><t><strong>FIRST NAME</strong></t></td>';
print '<td width="8%"><t><strong>SURNAME</strong></t></td>';
print '<td width="8%"><t><strong>DOB</strong></t></td>';
print '<td width="10%"><t><strong>ADDRESS 1</t></strong></td>';
print '<td width="10%"><t><strong>ADDRESS 2</t><strong></td>';
print '<td width="10%"><t><strong>ADDRESS 3</t></strong></td>';
print '<td width="10%"><t><strong>POST CODE</t></strong></td>';
print '<td width="20%"><t><strong>EMAIL</t></strong></td>';
print '<td width="11%"><t><strong>SELECT</t></strong></td>';
print '</tr>';
print '<form action="update.php" method="post">';
while ($row = mysql_fetch_array( $sql ))
{
print '<tr bgcolor="lightgrey">';
print '<td width="3%"><t>'.$row['id'].'</t></td>';
print '<td width="9%"><t>'.$row['date'].'</t></td>';
print '<td width="4%"><t>'.$row['title'].'</t></td>';
print '<td width="9%"><t>'.$row['firstname'].'</t></td>';
print '<td width="8%"><t>'.$row['surname'].'</t></td>';
print '<td width="8%"><t>'.$row['dob'].'</t></td>';
print '<td width="10%"><t>'.$row['address1'].'</t></td>';
print '<td width="10%"><t>'.$row['address2'].'</t></td>';
print '<td width="10%"><t>'.$row['address3'].'</t></td>';
print '<td width="10%"><t>'.$row['postcode'].'</t></td>';
print '<td width="20%"><t>'.$row['email'].'</t></td>';
print '<td width="11%" align="center"><input type="checkbox" name="check[' . $row['id'] . ']"> </td>';
}
print '</table><br />';
print '<input name="edit" type="submit" value="Edit" />';
print '<input name="letter" type="submit" value="Create Letter" /></form>';
?>
In the results table i have a check box on the end column. I want to be able to tick one checkbox from the results, click a button called "update" which will then take me to another page where the row that i have just checked will be shown on its own.
My code so far is this:
Code: Select all
<?php
mysql_connect ("localhost", "MyUsername", "MyPassword") or die (mysql_error());
mysql_select_db ("enquiries") or die (mysql_error());
foreach($_POST['check'] as $chk) echo $chk;
?>
But i just get the letters "on" echo'd to the screen.
Can you point me in the right direction please?
