Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 26th, 2011, 02:17 PM
Registered User
Join Date: Jan 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default repeating checkboxes problem

Hi Folks,

I am looping through a recordset ($result) containing different languages which I convert to values of html checkboxes, I want to compare the recordset values to array values ($arr_languages_spoken) and check the checkboxes that match. I think I am close, the code I have checks the right boxes but also duplicates every value from the recordset so I have 2 of each checkbox, any help would be appreciated, thanks.


while($row = mysql_fetch_array($result))
foreach ($arr_languages_spoken as $value)
if ($value == $row['language'])
echo "<input type=checkbox name=languages_spoken_1 value=".$row['language']." CHECKED/>".$row['language']." ";
else if ($value != $row['language'])
echo "<input type=checkbox name=languages_spoken_1 value=".$row['language']." />".$row['language']." ";
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with submiting and checkboxes Paula222 Classic ASP Basics 3 October 30th, 2006 02:39 PM
problem with checkboxes with submittion Paula222 Classic ASP Basics 0 October 30th, 2006 12:42 PM
problem with foreach loop in Checkboxes datagrid mbge9pjb .NET Framework 2.0 2 December 20th, 2005 10:03 AM
Problem Pre Selecting CheckBoxes in a CheckBoxLis sandersbr ASP.NET 1.0 and 1.1 Basics 2 August 13th, 2004 08:14 AM

All times are GMT -4. The time now is 06:42 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.