PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
phpPain
Forum Newbie
Posts: 10 Joined: Mon Nov 24, 2008 6:14 am
Post
by phpPain » Wed Dec 03, 2008 12:44 pm
Hi all,
I have the following,
Code: Select all
//get values post data to update.php
printf("<form action=\"%s\" method=\"%s\">\n", 'viewProgram.php', 'post');
while ($row = mysql_fetch_row($result))
{
printf("id " . $row[0]);
printf(" Channel:" . $row[1]);
printf(" Program:" . $row[2]);
printf(" Time:" . $row[3] . " ");
printf("<input type=\"submit\" name=\"mysubmit\" value=\"View Comments\" />");
printf("<br/><br/>");
}
print "</form>";
?>
It extracts data from the database, and prints a command button at the end of each row. When I click the button I would the item selected to be displayed on another page any one know now to do this?
Regards.
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Wed Dec 03, 2008 2:43 pm
viewProgram.php needs to know which item to display. Once it does then it's easy.
I'd make a modification to your HTML, something like this:
Code: Select all
printf("<input type=\"submit\" name=\"mysubmit[" . $row[0] . "]\" value=\"View Comments\" />");
To retrieve the ID in the other page, use
phpPain
Forum Newbie
Posts: 10 Joined: Mon Nov 24, 2008 6:14 am
Post
by phpPain » Thu Dec 04, 2008 6:08 am
this is the page that should display the item selected, it wont display th result it comes back with a blank page..
.
Code: Select all
//pass checkedvalue
$id = key($_POST["mysubmit"]);
//$checkedValue = $_POST['checkValue'];
if ($id =! null)
{
$sql = "SELECT programmes WHERE id = $id";
}