Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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.

MY CODE

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']." ";
}
}
}


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





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