RE: Drawing checkboxes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If I understand you, calling the function like so :

/**/
$value1 = "coffee";
$value2 = "coffee pots";
$returned = estrstr($value1, $value2);
/**/

returns the string "coffee". Well, I just ran that exact piece of code you
see above, and received the expected NULL value.  I don't see how you are
getting what you are getting.

If, one the other hand, you are searching for value "coffee" expecting to
get back only "coffee pots," then you misunderstand how the function works.

Hope this helps,

Scott



-----Original Message-----
From: Mike [mailto:mike@xxxxxxxxxxxx]
Sent: Tuesday, December 07, 2004 3:11 PM
To: PHP List
Subject:  Drawing checkboxes




Hello,

I am having a hard time figuring this one out, maybe someone here (with
fresh eyes) can offer a suggestion?

Here is the function...

// Draw Checkbox Menu
function draw_checkbox_menu($name, $values, $default = false, $parameters =
false) {



    for ($i=0; $i<sizeof($values); $i++) {
        $field .= '<input type="checkbox" name="'.$name.'" value="' .
$values[$i]['id'] . '"';
        if(strstr($default, $values[$i]['id'])) {
            $field .= ' CHECKED';
        }
        $field .= '> ' . $values[$i]['text'] . '<br>
        ';
    }

    return $field;
}

This function is passed the name of the checkbox list($name), the values
that are available($values = array) along with the ones that should be
checked ($default). Parameters too , but not important.


The problem is this. The Values are formatted like this...

value1|value2|value3...etc...

I use the strstr() function to check against the $default so I can check it
if so.

Well it works great..BUT, lets say the product has a category of "Coffee
Pots", but the one of the values available is "Coffee".

In this case both "Coffee" AND "Coffee Pots" get checked when only "Coffee
Pots" should.

What can I do to this function eliminate this?

Thanks




+--------------------------------------------+
Mike Yrabedra
Mac@xxxxxxxx
Your Mac Intelligence Resource
+--------------------------------------------+
W: http://www.macagent.com/
E: agenty@xxxxxxxxxxxx

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux