Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 10 Jun 2012, 15:47
m002.p's Avatar
m002.p m002.p is offline
 
Join Date: Jan 2007
Real name: Matt
Retrieving checkbox values from MYSQL

Hello everyone.

I am tearing my hair out with this one and I sort of know the reason why it wont work, being a loop issue but I cant see where I am going wrong.

I have checkboxes as seen in the $a_offenses array. I want the script to check the MYSQL table row 'offenses' which contains an array of those selected checkboxes in the format 'VALUE 1, VALUE 2, VALUE 4, VALUE 6' for example.

The problem comes where the first value eg. VALUE 1 is ticked in the list of checkboxes but the others are not and left unchecked.

Any ideas?

PS - The $c counter is used to ensure only 3 checkboxes are displayed per row ie. formatting only nothing else

Thanks in advance.

Matt


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
www.sog-team.co.uk
Reply With Quote
  #2  
Old 10 Jun 2012, 16:22
kh99's Avatar
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Originally Posted by m002.p View Post

The problem comes where the first value eg. VALUE 1 is ticked in the list of checkboxes but the others are not and left unchecked.

And what happens when that's the case?
__________________
Please don't PM me - post your questions in the appropriate forum.
Please don't PM me to ask me to read your thread.
Reply With Quote
  #3  
Old 10 Jun 2012, 16:43
m002.p's Avatar
m002.p m002.p is offline
 
Join Date: Jan 2007
Real name: Matt
Hi, thanks for your response.

I dont follow what you mean.

Heres an example.

Row 'offenses' for ID 4; Team Killing, Spamming, ROE Violations

Out of all the checkbox possibilities as displayed with array $a_offenses, only the first value "Team Killing" is checked and not the other 2 in the example using the code posted.

Hope that answers your query?

Matt
__________________
www.sog-team.co.uk
Reply With Quote
  #4  
Old 10 Jun 2012, 16:54
kh99's Avatar
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Oh, I get it now. I thought you meant some problem was happening if you checked only one box.

Anyway, I think your problem is that explode(',', array) splits by comma but doesn't take away the extra spaces. Try this:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
Please don't PM me - post your questions in the appropriate forum.
Please don't PM me to ask me to read your thread.
Reply With Quote
  #5  
Old 10 Jun 2012, 17:22
m002.p's Avatar
m002.p m002.p is offline
 
Join Date: Jan 2007
Real name: Matt
Genius, works like a charm. Thank you, something so simple but so simply overlooked.

Matt
__________________
www.sog-team.co.uk
Reply With Quote
  #6  
Old 10 Jun 2012, 17:31
kh99's Avatar
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Yeah, sometimes it just takes a fresh pair of eyes.
__________________
Please don't PM me - post your questions in the appropriate forum.
Please don't PM me to ask me to read your thread.
Reply With Quote
  #7  
Old 29 Jul 2012, 17:46
m002.p's Avatar
m002.p m002.p is offline
 
Join Date: Jan 2007
Real name: Matt
Hi Kh99,

I know its been a while since I had this issue, but I have since been trying using another method.

Instead of using the old method:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I am now retrieving this array from a MYSQL table.

Example:

$a_offenses = $db_offenses['list'];

Value stored in MYSQL column 'list' is the array eg. "Team Killing, Team Tazing, Team Nading" etc.

Now the problem is back again. I removed your first solution to simply:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

and it partially works. When I say partially, multiple boxes are ticked but for some elements of the array the box remains unticked.

Eg.

Offenses listed in DB; Team Killing, Team Tazing, Rambo Gameplay

Checkboxes ticked: Team Killing, Rambo Gameplay

So some are missed from the stored values. I looked at how both arrays are stored in the DB and cant see any extra spaces.

Can you help?

--------------- Added 29 Jul 2012 at 17:59 ---------------

Dont worry, forgot to pass both variables through array_map.

Thanks once again!
__________________
www.sog-team.co.uk
Reply With Quote
Reply


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

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


New To Site? Need Help?

All times are GMT. The time now is 09:21.

Layout Options | Width: Wide Color: