Jump to content

get array value for variable


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:


			<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 />



$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.'" )';

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • 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.