Multiple submit forms inside a mysql array page
Posted on
16th Feb 2014 07:03 pm by
admin
Hi all,
Im having trouble to get the beneath script to work the thing i can't seem to get workin is the following.
The page requests the data from a mysql table using mysql array so there are mutliple row's every row has 3 data
colloms 1 id (auto increment) 2 Module name 3 status. after every row the is a submit button so you can submit data from that row (basilcy a on and off button) when i have more than 1 row it doesnt work.
With 1 row it works but have to press the submitt buton twice.
Any help will be appreciated
Regards Djunity
<div class="content">
<br />
<a href="?page=view">Module overzicht</a> <br />
<br / >
<p><a href="?page=add" class="button"><span class="ui-icon ui-icon-plusthick"> </span>Module toevoegen </a></p>
<table id="myTable" class="tablesorter" style="width: 100%;" border="0" cellpadding="0" cellspacing="1" > <thead>
<tr>
<td height="25px" width="120"><b> Module naam:</b></td>
<td height="25px" width="60"><b> Status:</b></td>
<td height="25px"width="70"><b> Actie:</b></td>
</tr>
</thead>
<?
// get results from database
$result = mysql_query("SELECT * FROM Wefact_Modules ORDER BY id")
or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
$form = $row['module'];
$id = $row['id'];
?>
<tbody>
<form method="post" name="form" action="?page=view">
<input type="hidden" name="id" value="<?php echo $id; ?>"/>
<input type="hidden" name="action2" value="action">
<tr class="hover">
<td height="35px"><? echo $row['module']; ?></td>
<td height="35px"><? if ($row['status'] == 1) {
echo "<font color='#00FF00'>Online</font>";
}else if ($row['status'] == 0){
echo "<font color='#FF0000'>Offline</font>"; } ?></td>
<td height="35px">
<? if ($row['status'] == 1) { ?>
<input type="hidden" name="status" value="0" /><a href="javascript: document.form.submit();" class="button"><span class="ui-icon ui-icon-minusthick"> </span>Offline</a> <?
}else if ($row['status'] == 0){ ?>
<input type="hidden" name="status" value="1" /><a href="javascript: document.form.submit();" class="button"><span class="ui-icon ui-icon-plusthick"> </span>Online</a> <? } ?> </td>
</form>
</tbody>
<? } ?>
<?
$status = $_POST['status'];
if($_REQUEST['action2'] == 'action') {
$sql = "UPDATE Wefact_Modules SET status='$status' WHERE id='$id'";
$result = mysql_query($sql);
} ?>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>
No comments posted yet
Your Answer:
Login to answer
228
8
Other forums
Apple's revamped lineup arrives
I'm personally curious about the magic mouse.. a multi-touch concept sounds like it could be nea
dinamic "textboxes"?
Ey all, my first post here, i hope its not a hard one
I display mysql results in a table
Is STL important?
I'm just starting programming and I've made it until the Standart Template Library. But the chapter
Email logic not working
I would like to send an email using the php email() function then if it does execute i.e sends i wou
login from external site
Hi my new experience begins, Now what i am trying to do is i make three pages, login.php logout.php
$action = "insert"; //$action = $_GET['action'];
$action = "insert";
//$action = $_GET['action'];
why is this invalid type? I am
Trouble checking SESSION cookie
I am trying to use $_SESSION cookies to verify admin privileges .
I don't understand why this is
problems with php variables in mysql query
i can't seem to get the following query to work.
select $q1c from $vote_rate where id = $re
Extract specific information from a PHP Multidimensional Array
Howdy! I've racked my brain over this for 24 hours now. I think it's time I asked for help. I'm lear
Floating Point Precision Loss
I'm writing a program to draw a three-dimensional cube (with a corner cut off) without using any 3D