Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Populating/Checking Checkbox Values Based on Lookup
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Reha Sterbin  
View profile  
 More options Jul 18 2002, 6:22 pm
Newsgroups: alt.php, comp.lang.php
Followup-To: comp.lang.php
From: Reha Sterbin <rster...@force.stwing.upenn.edu>
Date: 18 Jul 2002 22:22:08 GMT
Local: Thurs, Jul 18 2002 6:22 pm
Subject: Re: Populating/Checking Checkbox Values Based on Lookup

In article <JhnZ8.569709$cQ3.52707@sccrnsc01>, Jeff Donnici wrote:
> Ok, so assuming I run both queries, I've now got two result-sets. I iterate
> through the ALL result set and create a checkbox for each color. But, at
> each stop, I'd like to search the MAPPED result set to see if the ID value
> appears in it (in the COLOR_ID column)... If so, add the word 'CHECKED' to
> the HTML to pre-check the box.

> This is the part I can't seem to find a simple function for. I know I could
> loop through the MAPPED result set each time to find a match, but that seems
> awfully inefficient. The IN_ARRAY function looks like just the ticket except
> that it doesn't seem to like being given a MySQL result set instead of an
> array. Ok, so maybe I create an array from the MAPPED result set... but it
> doesn't look like EXPLODE will do that for me, so I'm back at looping
> through the MAPPED result set and creating an array of all the values.
> Surely there must be a better way.

You might want to think of the MySQL result resource as directions to the next
row of your results, rather than as an array[1].  Of course, if you want an
array, it's pretty easy to make one (see below).

If I were in your shoes, I'd go get the user's color_ids first and put them
into an array:

while ($row = mysql_fetch_assoc($result)){
        $users_colors[] = $row['color_id'];

}

Then, when you go circling through your ALL colors results, you can use
in_array() on $users_colors to make your check marks as you go.

Hope this helps.

-Reha

[1] - What the result resource is, precisely, is not really something I know
much about.  Perhaps someone else could clear it up?
--
/(bb|[^b]{2})/ ...THAT is the question.
=======================================
http://www.stwing.upenn.edu/~rsterbin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.