using a check box
Posted: Tue Dec 02, 2008 2:34 pm
Hi,
I am still a newbie here
. I have the following, which works at the moment and displays the data ok.
However I need the file to print out a check box after each line of the database. This way when the form is submitted which ever check box is ticked I can display on the next page ready for editing. I think I would need to send a variable with the item selected, but I am not sure, I think the only line I need to change will be the one in bold. Any help gratefully appreciated.
Hope this makes sense. Thank you.
I am still a newbie here
However I need the file to print out a check box after each line of the database. This way when the form is submitted which ever check box is ticked I can display on the next page ready for editing. I think I would need to send a variable with the item selected, but I am not sure, I think the only line I need to change will be the one in bold. Any help gratefully appreciated.
Hope this makes sense. Thank you.
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>STW</title>
<META NAME="Generator" CONTENT="">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="?">
<META NAME="Description" CONTENT="?">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white">
<h1>Your programs</h1>
<?php
include("connection.php");
?>
<?php
//connect to db
if(!($dblink=mysql_connect($server,$user,$password))) {
print "Fail: mysql_connect failed" ;
exit;
}
//error if can't select db
if(!mysql_select_db($db,$dblink)) {
print "Fail: can't select database" ;
exit;
}
// quuery db to get data
$sql = "select * from programmes";
if(!($result = mysql_query($sql,$dblink))) {
print "Fail: invalid query";
exit;
}
//get values post data to update.php
printf("<form action=\"%s\" method=\"%s\">\n", 'addComment.php', 'post');
while ($row = mysql_fetch_row($result))
{
[b]printf("id: %s\n Channel: %s\n Program: %s\n Time: %s\n <br/> <br/>", $row[0], $row[1], $row[2], $row[3]);[/b] }
print "<input type=\"submit\" name=\"mysubmit\" value=\"Add Comment\" />";
print "</form>";
?>
<p><a href="unit6.html">BACK</a>
</body>
</html>