You are here: Re: Checkbox array « PHP Programming Language « IT news, forums, messages
Re: Checkbox array

Posted by Kimmo Laine on 03/06/06 13:02

"Paul Morrison" <nospam@nospam.com> wrote in message
news:duh3rd$lt2$1@oheron.kent.ac.uk...
> Hi,
>
> I have a checkbox array containing the id of a record in a MySQL database.
> The checkboxes are created dynamically depending on what is stored in the
> database. I want to send the checkbox array to my stop_subscriptions.php
> file, running the code on all checked boxes, however I dont seem to be
> able to actually send the array, I was hoping that someone could steer me
> in the right direction.
>

The problem is not that you are submitting an array, the problem is with the
form tags. See comments below.

>
> <?php
> $sql = "SELECT i.type, i.title , s.inj_id FROM inj_subscription s,
> injustices i WHERE s.member_id = '$user' AND i.inj_id = s.inj_id AND
> s.inj_id IS NOT null" ;
> $result = mysql_query($sql);
> $row = mysql_fetch_assoc($result) ;
> if ($row) {
> echo "<div><span>Specific Subsriptions:</span><br/>" ;
> $table_start ='<table width="90%" table name="table2"
> align="center" cellspacing="0" border="0">
> <tr>
> <form method="post" action="stop_subscription.php">
> <th width="20%">Type</th>
> <th width="70%">Title</th>
> <th width="10%"></th>
> <input type="submit" name="Submit" value="Submit"
> style="font-size:10px"/><p>
> <input type="hidden" name="stop_subscription"
> value="1"/>
> </form>

The form ends here in the </form> tag

> </tr>';
> echo $table_start;
> $rownum = 0;
> while($row) {
> $rownum++;
> $style = rowcolor($rownum);
> $table_rows .= '<td id="td" align="center"

then you begin another form here, apparently each checkbox gets their own
form since it's inside the while loop.

> style="'.$style.';padding:5px;" >'."\n".'<form><input type="checkbox"
> name="deletethis[]" value="'.$row['inj_id'] . '"></form></td>'."\n\t";
> echo "<tr>" . $table_rows . "</tr>";
> $row = mysql_fetch_assoc($result) ;
> }
> echo '</table><Br/></div><br/>';
> }
> ?>


All fields that you want to post must be within the SAME <form>...</form>
range, any fields outside that range, or fields inside another form are not
posted when a form is submitted. Change the code so that you generate just
one form, and all your form fields are inside that same form.

--
"En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviφ
spam@outolempi.net | Gedoon-S @ IRCnet | rot13(xvzzb@bhgbyrzcv.arg)

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация