/    Sign up×
Community /Pin to ProfileBookmark

matching up values from arrays

i’m creating an array using $_POST[‘cb’] to find which images are selected. each image has 2 textfields holding the file path to the big pic and the thumbnail respectively.

i can print $_POST[‘cb’] array and it returns the selected images correctly…but when i print $_POST[‘bigpath’] or $_POST[‘tmbpath’] it returns all the values regardless of the number of images selected.

which makes sense, so how can i get the correct or associated file paths to match up with their selected images? (all the values are being pulled from a database)

[CODE]

<input type=”checkbox” name=”cb[]” value=”$pID[$i]_$pstatus[$i]” class=”showhide_cb” id=”$pID[$i]”>
<input type=”hidden” value=”$bigs[$i];” name=”bigpath[]”>n
<input type=”hidden” value=”$thumbs[$i];” name=”tmbpath[]”>n

[/CODE]

thanks!!

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@ss1289Mar 11.2008 — i'm creating an array using $_POST['cb'] to find which images are selected. each image has 2 textfields holding the file path to the big pic and the thumbnail respectively.

i can print $_POST['cb'] array and it returns the selected images correctly...but when i print $_POST['bigpath'] or $_POST['tmbpath'] it returns all the values regardless of the number of images selected.

which makes sense, so how can i get the correct or associated file paths to match up with their selected images? (all the values are being pulled from a database)


[CODE]

<input type="checkbox" name="cb[]" value="$pID[$i]_$pstatus[$i]" class="showhide_cb" id="$pID[$i]">
<input type="hidden" value="$bigs[$i];" name="bigpath[]">n
<input type="hidden" value="$thumbs[$i];" name="tmbpath[]">n

[/CODE]


thanks!![/QUOTE]


You could include the paths for both images within the value of the cb[] field and then after getting $_POST['cb'], parse out the path names somehow. I'm not sure if that's the best way but that idea was just off the top of my head.

or

You could associated the path names to the image name within your database and when that image is selected, SELECT the path names from the database that are associated to that image.
Copy linkTweet thisAlerts:
@kreddauthorMar 11.2008 — hey thanks...i thot about that too but also wasn't sure if it was the best way. i tried it out using a "_" to separate the values in the cb[] field and then use split() to break them back up BUT there are "_" in the image's file names (ex: this_file_name.jpg) so it's splitting up the file names too... ?

any ideas for a better delimter to use for the cb[] values????
Copy linkTweet thisAlerts:
@HuevoosMar 12.2008 — The simplest way is to find the values you need in the paths array
<i>
</i>&lt;input type="checkbox" name="cb[$i]" value="$pID[$i]_$pstatus[$i]" class="showhide_cb" id="$pID[$i]"&gt;
&lt;input type="hidden" value="$bigs[$i];" name="bigpath[]"&gt;n
&lt;input type="hidden" value="$thumbs[$i];" name="tmbpath[]"&gt;n

[code=php]
foreach($_POST['cb'] as $key => $value){
$thumb = $_POST['tmbpath'][$key];
$big = $_POST['bigpath'][$key];
//Work your magic
}
[/code]
Copy linkTweet thisAlerts:
@kreddauthorMar 12.2008 — ahhhh, thanks man!
×

Success!

Help @kredd spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.9,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...