User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,821 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,625 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 897 | Replies: 2
Reply
Join Date: Mar 2008
Posts: 42
Reputation: aran87 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
aran87 aran87 is offline Offline
Light Poster

arrays checkboxes, Form submit array

  #1  
Mar 31st, 2008
Hello im new to the world of php, ive been designing a webpage in ma spare time and ive got to a stage where im stuck its basically ticking checkboxes and inserting them into the next page somehow using the $post method not sure how to do it. But the problem i have is the options i want to chose are searched from a database and i want to select an output and then send it to the next page using a submit button. Form Submit array, ive got no idea at all ive done some coding up to adding checkboxes next to each row. heres my coding so far. Also i dont think you can have form in the php section;

<?
<form name="Dates" action=".php" method="post" onsubmit="return checkCheckBoxe();">

// Loop through data and display
while($a_row = mysql_fetch_assoc($result))
{
echo "<tr>".
'<td style="color: red;"><input type="checkbox" name="bookings[]" value="'.$a_row['id'].'"></td>'.
"<td style=\"color:red\">".$a_row['TIME']."</td>".
"<td style=\"color:red\">".$a_row['MONTH']."</td>".
"<td style=\"color:red\">".$a_row['YEAR']."</td>".
"<td style=\"color:red\">".$a_row['DAY']."</td>".
"<td style=\"color:red\">".$a_row['PERSON']."</td>".
"<td style=\"color:red\">".$a_row['SYSTEM']."</td>".
"<td style=\"color:red\">".$a_row['EBAYER']."</td>".
"<td style=\"color:red\">".$a_row['AGE']."</td></tr>";

}
// Close connection ! (please !)
mysql_close($connection);


<input type="submit" name="Submit" value="Submit!" />
</form>

?>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2007
Location: georgia
Posts: 55
Reputation: hunkychop is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 4
hunkychop's Avatar
hunkychop hunkychop is offline Offline
Junior Poster in Training

Re: arrays checkboxes, Form submit array

  #2  
Mar 31st, 2008
first, no, you cant have any html inside of the php tags unless it is in an echo/print . i would put the form and submit buttom outside of the tags.

second, before you try to loop through databaase results, you have to connect to the database and retrieve results.
example:
  1. mysql_connect($dbhost, $dbuser, $dbpasswd) or die(mysql_error());
  2. mysql_select_db($dbname) or die(mysql_error());
  3. $sql = "SELECT * FROM your_db_table";
  4. $result = mysql_query($sql);

and also, the "onsubmit" attribute of the html form tag does not relate to php. that is only if you are submiting the form with javascript.

hope this helps
Last edited by peter_budo : Apr 1st, 2008 at 6:06 am. Reason: Keep It Organized - please use [code] tags
toast
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 238
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: arrays checkboxes, Form submit array

  #3  
Apr 1st, 2008
<form name="Dates" action=".php" method="post" onsubmit="return checkCheckBoxe();">

action=".php" should be action="filename.php".
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 5:48 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC