I'm a newbie into programming php, and i'm compleatly stuck with my code. I hope I can explain my problem more accurate here.
With dynamic action I mean that the action attributte in the <FORM> tag should be able to send the user to different pages.
I've database which consists of several entries. My webpage lists these entries in a webpage with a checkbox after each entry. From this checkbox you are supposed to select the entry you would like to update,delete or view detailed information about.
Above the listning I've a menu with different choiches(update, delete...). These links are supposed to send the selected (checked values in an array) to a page wich process the data submitted. I'm not sure how this can be done by using this menu?
Problem : How can I make the form action field go to different pages based on my menu selection? I know this code have some missing parts
I guess some of my problem here is passing variables from server-side scripting to klient side script(javascript). :rolleyes:
Code example:
[B]function menu(){
?>
<a href="search.php">Search</a> |
<?php
echo "<a href='delete.php' onClick='this.form.submit();'>Delete</a></span> | "
echo "<a href='edit.php' onClick='this.form.submit();'>Edit</a></span> | "
.........
?><a href="logout.php">Logout</a> |
<?php
}
[B]function display_all_trans($result){[/B]
?>
<form name="form" action="" method="post">
<table class="formBoxStyle" width="95%" cellpadding="2" cellspacing="0">
<?php
$color = "#ffffff";
$num_results = $result->num_rows;
for ($i=0; $i<$num_results; $i++)
{
$row = $result->fetch_assoc();
if ($color == "#ffffff")
$color = "#ccccff";
else
$color = "#ffffff";
echo "<tr bgcolor='$color'><td>$row[id]."</td>";
echo "<td>".$row[Fname]."</td>";
echo "<td>".$row[Lname]."</td>";
echo '<td><a href="mailto:'.$row[Email].'">'.$row[Email].'</td>';
echo "<td><input type='checkbox' name='check[]' value='".$row[trans_id]."'></td>";
echo "</tr>";
}
?></table>
</form>
What I try to achieve is that the check[] array is beeing passed along with the onClick attribute in the menu.
I've a main function that calls these functions pluss footer, header .....
Any help would be appreciated!