i am used to reading in data from a database and echoing it out, if it meets certain criteria... for example...


DATA tommy|4|red|apples jed|5|blue|apples mark|4|yellow|apples


SUDO-SCRIPT


while ($number == "4")
{
echo $name . "is " . $number . "and likes " . $color . " " . $fruit . ".";
}



will NOT print out the entire database, it will only print the first and third entry. i have a hang of this.


BUT, what if i want to proceed this script with a web form where i will allow the user to select which information they want the scrip to "search" the database with?

making the form have one option, either...

        1.      name
        2.      number
        3.      color
        4.      fruit


...and allowing the user to cheese just one... is also easy, doing...


SUDO-SCRIPT

while ($selection_type == "selection_value")
{
echo $name . "is " . $number . "and likes " . $color . " " . $fruit . ".";
}



BUT, what if i want the user to be able to select as many or as few options as they want? meaning that they can select "name + color" or "name + number + fruit" or any combination?


they best that i have come up with is something like this...

SUDO SCRIPT

if (isset($_POST['name']))
        {
                $search01 = $_POST['name'];
                $data01 = $name_DB
        }

if (isset($_POST['number']))
        {
                $search02 = $_POST['number'];
                $data02 = $number_DB
        }

if (isset($_POST['color']))
        {
                $search03 = $_POST['color'];
                $data03 = $color_DB
        }

if (isset($_POST['fruit']))
        {
                $search04 = $_POST['fruit'];
                $data04 = $fruit_DB
        }

while ( $search01 == $data01 &&
$search02 == $data02 &&
$search03 == $data03 &&
$search04 == $data04 )
{
echo $name . "is " . $number . "and likes " . $color . " " . $fruit . ".";
}



...but it isn't working.


it seems like it should. even though i have all four comparisons in the "while" before the print... but even though i am not using them... they shouldn't hang it up... because if the variables aren't "set," they shouldn't do anything... right?

am i making this more complicated than i need to? am i going about this entirely wrong?

-wade



_______________________________________________
newbies mailing list
[EMAIL PROTECTED]
http://phantom.byu.edu/cgi-bin/mailman/listinfo/newbies

Reply via email to