Jump to content

get array value for variable


samoht

Recommended Posts

hello all,

 

I have an array value in my post array ($_POST['check0'] ) that I am trying to break up into php variables. For some reason if I do this:

$var1 = $_POST['check0'][0];

all I get is the first letter of the string from the first value of the array?

 

Link to comment
Share on other sites

Thanks for the responses,

 

I do have checko0[] in the HTML  - that is why the post value is an array right? The issue is the retrieval of the array values into separate variables. I'm not sure I want to store the values in an array in the db (using serialize) - and since my form asks the end user to select only 2 of 5 options I thought I could save the returned values in separate fields like: looking_for_1; looking_for_2

 

here is some more of my code:

HTML:

			<tr>
			<td align="right" width="17%"><label class="cf_label" style="width: 150px;">What are you looking for in XXX (select top two)</label></td>
			<td align="left" width="27%"><div class="float_left">
										  <input value="Universal image viewer for my images" title="" class="radio" id="check00" name="check0[]" type="checkbox" />
										  <label for="check00" class="check_label">Universal image viewer for my images</label>
										  <br />
										  
										  <input value="A portable image database" title="" class="radio" id="check01" name="check0[]" type="checkbox" />
										  <label for="check01" class="check_label">A portable image database</label>
										  <br />
										  
										  <input value="Spine specific measuring tools" title="" class="radio" id="check02" name="check0[]" type="checkbox" />
										  <label for="check02" class="check_label">Spine specific measuring tools</label>
										  <br />
										  
										  <input value="Surgical Planning tools" title="" class="radio" id="check03" name="check0[]" type="checkbox" />
										  <label for="check03" class="check_label">Surgical Planning tools</label>
										  <br />
										</div></td>
		</tr>

 

processing:

...
$var1 = $_POST['check0'][0];
$var2 = $_POST['check0'][1];
...
//now try the user info save;
$query = '
INSERT INTO `#__vm_user_info` (user_info_id,user_id,user_email,perms,pclear,first_name,last_name,country,speciality,yearsexp,hearabout,keyissue,looking_for_1,looking_for_2,whichsoftware,webex)
	VALUES("'.$strUserinfoID.'", "'.$smuser.'", "'.$smemail.'", "License Owner", "'.$strPassword.'", "'.$smfname.'", "'.$smlname.'", "'.$country.'", "'.$smspeciality.'", "'.$smyearsexp.'", "'.$smhearabout.'", "'.$smkeyissue.'", "'.$var1.'","'.$var2.'", "'.$smwhichsoftware.'", "'.$smwebex.'" )';
$db->setQuery($query);
$db->query();

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.