boo_lolly 0 Light Poster

hello all! i am writing a piece of a wedding website in php. this piece of the website is called a bridal registry. when a couple gets married, they tell people that they are registered at my website. this means that the couple came to my website and told them what they wanted people to purchase on their behalf. for example, a newlywed couple (The Smiths) come to me and say they want product1, product2 and product3 as their wedding gifts. friends of the newlyweds can conduct a search on my website for the newlyweds, then click THEIR 'registry', and they will be forwarded to a page with the products that the newlywed couple wants for their wedding gifts. if the couple wants many of product1, it will show how many they want (TOTAL), and how many they still need (purchased - TOTAL). each product can be purchased by anybody that views that newlywed's registry.

so, basically we have 3 pages. search page. results page. registry page. search has a few input fields, only one input field is required to have content. the results page returns the results of the search query. this will be laid out in a table. with each result there will be a link to 'view registry' for each newlywed couple(s) that the search query returned. when somebody clicks 'view registry', they will be taken to THAT couple's registry where all the products they wanted for wedding gifts will be shown. each product will have an 'add to cart' option, when clicked will take them to my 3rd party shopping cart.

here's what i got so far

<!-- SEARCH.PHP -->
<form method="POST" action="results.php">
First Name:<input type="text" name="fname"><BR>
Last Name:<input type="text" name="lname"><FONT COLOR="FF0000" SIZE="-1">(required)</FONT><BR>
<SELECT NAME="regDate">
<OPTION VALUE="">Select an Event Date
<OPTION VALUE="">Month | Year
<OPTION VALUE="">Month | Year
<OPTION VALUE="">Month | Year
<OPTION VALUE="">Month | Year
<OPTION VALUE="">Month | Year
</SELECT>
<BR>
<input type="SUBMIT" value="Search!">
</form>
<!-- RESULTS.PHP -->

<?php

    trim($lname);
    if (!$lname)
    {
    echo "<FONT COLOR="FF0000">You have not filled the required fields. Please try again.</FONT>";
    exit;
    }

    @ $db = mysql_pconnect("host", "name", "pass");
    if(!$db)
    {
    echo "Error: Could not connect to the database. Please try again later.";
    exit;
    }

    mysql_select_db("registryDB");

    $sql = mysql_query("SELECT * FROM regTable WHERE ". $lname ." LIKE '%". $lname ."%'") or die (mysql_error());
    $result = mysql_query($sql);
    $num_result = mysql_num_rows($result);


    echo "Number of matches: ". $num_result "<br />";

    do
    {
    echo "<TABLE BORDER="1"><TR><TH>Bride</TH><TH>Groom</TH><TH>Event Date</TH><TH>&nbsp;</TH></TR>";
    }
    while(list($column1, $column2, $column3, $column4) = mysql_fetch_array($sql))
    {
        for($i=0; $i < $num_result; $i++)
        {
        $row = mysql_fetch_array($result);
        echo "<TR><TD>". $row["brideName"] ." "</TD><TD>". $row["groomName"] ."</TD><TD>". $row["eventDate"] ."</TD><TD>". $row["viewReg"] ."</TD></TR><br />";
        }
    echo "</TABLE>";
    }
?>

i'm sure you'll see some problems with it already. it is being edited as we speak. however, i'm not certain how to keep all the search input data in an array. and then use all the search criteria in results.php to be outputted in a table the way you see above.

registry.php will probably just be a template page, and depending on the variable passed to registry.php, it will show the registry of the newlywed couple that they wanted to see. i figure this could be an $ID variable or something like that, affiliated with each newlywed couple in the database. i'm sure i'd use the $_POST method, but where? how? can anybody shed at least a LITTLE light on this issue? thanks in advanced.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.