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">&nbsp;</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>&nbsp;Module naam:</b></td>
<td height="25px" width="60"><b>&nbsp;Status:</b></td>
<td height="25px"width="70"><b>&nbsp;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">&nbsp;</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">&nbsp;</span>Online</a> <? } ?>&nbsp;</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 Like 8 Dislike
Previous forums Next forums
Other forums

Using system() and bringing back the results
I am aware that you can use system() within PHP to execute system commands, but I was wondering if t

SAP FICO learning materials
Hi all,
I am new to this world of SAP FICO. I have taken training on SAP FICO, but was wonderin

Check Date/Time in PHP
What I need the code to check is that $reQuest is 24 hours in the past then return a time based on h

Select all entries from database that include a phrase
I have a database of clubs - one of the categories is meeting time and place
I would like to have

Searching keywords from array
Hello everyone, Im just wondering if someone could help me with another issue im having. Im still le

my login script page is not working on remote computers
hi my login is working on my computer, but when i tried 2 computers from 2 different locations, they

DB2 for z/OS, LUW, iSeries
Hello, In this forum a lot of threads related to other members of the DB2 family than DB2 for z/OS

get url?
how do i get the url of the page i'm currently on, on my website.. i think its get header.. how do i

Blank record injected into database
I always found several blank records inside my database, although $SESSION is required to insert the

Vertical Alligning - Not working in 1 cell?
<?php

echo "<table id="valign" width="60%" style=

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash