Stuart Felenstein wrote:
--- Jochem Maas <[EMAIL PROTECTED]> wrote:

don't be sorry, be pro-active and rewrite it until
its idiot proof. its in your own best interest - the clearer you state
your problem the greater the chance someone will/can help you.

I don't know about anyone else, but I haven't got a clue as to what the problem is. I know I'm fairly intelligent but I can't work it out.

Well I've started with a clean slate. Meaning I

always a good plan!

ditched what was starting to look like spaghetti and
started over with a lot of print_r's.

My select statement in the (intended)update page has 3

is it an update script or a selection/view script or both?

parameters in the where statement, that are passed
over from the link using $GET_VARS.  1- is the
recordID, 2-the userID 3-an encrypted code tied to the

so you start with a page that submits three values to another page.... which works so that not the problem...

All those parameters show up fine (print_r) on said
update page.

The first problem I'm having is getting the update
page to show which values currently exist.

what values are you talking about? currently exist where?

This is
the multi select box and the (adodb) recordset listing
all the options.  I'm lacking something in the page
though that allow it to see which values are already
chosen in the database:

<select name="inds[]" size="8" multiple id="inds[]"> <?php while(!$rsInds->EOF){ ?> <option value="<?php echo rsInds->Fields('CareerIDs')?>"> <?php if (count($IndID) > 0 AND is_array($IndID)) {

use && not AND unless you know what your doing! they are different. also you check the count() on $IndID before you check its an array!

another thing:

$IndID and $rsInds are pretty meaningless to the rest of the world, and they will be to you as well in 6 months time! use a few extra chars and give the vars meaningfully, easily idenfiable names (helps us guess what you are doing too!)

foreach ($IndID as $ind) { ?>
<?php if ($rsInds->Fields('IndID')== $ind) {echo
"SELECTED";} } }?>
<?php echo

that looks evil; seeing as I a still have no idea what your actually stuck on I'll give you a quick lesson in writing neater/better code:

//---- begin code sample ---

$opts  = array();
$IndID = (array) $IndID;

while (!$rsInds->EOF) {
        /* is this option selected? */
        $selected = in_array($rsInds->Fields('IndID'), $IndID)
                  ? 'selected="selected"'
                  : ''; 

        /* build the option */
        $opts[] = sprintf('<option value="%s" %s>%s</option>',

/* output the complete select element,
 * you don't have to output directly!!!
 * you could stuff the strings into another
 * var and echo it out later (e.g. after all
 * processing has been done)
echo '<select name="inds[]" size="8" multiple id="inds[]">';
echo join("\n", $opts);
echo '</select>';


//---- end code sample ---

excuse the strange layout
a, I like short lines.
b, I find tertiary if statements very readable when spread across multiple lines.
c, I'm try to avoid nasty linewrap due to mail setups.

BTW - the above is not syntax checked.

anyone care to say this is _not_ more readable?

I've added this in the script, which prints out fine
once I've submitted the page. Not sure if I need
something similar for the records that already exist ?

neither do I!

if (count($inds) > 0 AND is_array($inds)) { $ind = "'".implode("','", $inds)."'"; }

looks like you want to do a select statement with $ind in the form of "SELECT * FROM yourtable WHERE yourfield IN ($inds)"

heh why not!


-- PHP Database Mailing List ( To unsubscribe, visit:

Reply via email to