944,196 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1334
  • PHP RSS
Nov 13th, 2006
0

search and results question.

Expand Post »
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
php Syntax (Toggle Plain Text)
  1. <!-- SEARCH.PHP -->
  2. <form method="POST" action="results.php">
  3. First Name:<input type="text" name="fname"><BR>
  4. Last Name:<input type="text" name="lname"><FONT COLOR="FF0000" SIZE="-1">(required)</FONT><BR>
  5. <SELECT NAME="regDate">
  6. <OPTION VALUE="">Select an Event Date
  7. <OPTION VALUE="">Month | Year
  8. <OPTION VALUE="">Month | Year
  9. <OPTION VALUE="">Month | Year
  10. <OPTION VALUE="">Month | Year
  11. <OPTION VALUE="">Month | Year
  12. </SELECT>
  13. <BR>
  14. <input type="SUBMIT" value="Search!">
  15. </form>
php Syntax (Toggle Plain Text)
  1. <!-- RESULTS.PHP -->
  2.  
  3. <?php
  4.  
  5. trim($lname);
  6. if (!$lname)
  7. {
  8. echo "<FONT COLOR="FF0000">You have not filled the required fields. Please try again.</FONT>";
  9. exit;
  10. }
  11.  
  12. @ $db = mysql_pconnect("host", "name", "pass");
  13. if(!$db)
  14. {
  15. echo "Error: Could not connect to the database. Please try again later.";
  16. exit;
  17. }
  18.  
  19. mysql_select_db("registryDB");
  20.  
  21. $sql = mysql_query("SELECT * FROM regTable WHERE ". $lname ." LIKE '%". $lname ."%'") or die (mysql_error());
  22. $result = mysql_query($sql);
  23. $num_result = mysql_num_rows($result);
  24.  
  25.  
  26. echo "Number of matches: ". $num_result "<br />";
  27.  
  28. do
  29. {
  30. echo "<TABLE BORDER="1"><TR><TH>Bride</TH><TH>Groom</TH><TH>Event Date</TH><TH>&nbsp;</TH></TR>";
  31. }
  32. while(list($column1, $column2, $column3, $column4) = mysql_fetch_array($sql))
  33. {
  34. for($i=0; $i < $num_result; $i++)
  35. {
  36. $row = mysql_fetch_array($result);
  37. echo "<TR><TD>". $row["brideName"] ." "</TD><TD>". $row["groomName"] ."</TD><TD>". $row["eventDate"] ."</TD><TD>". $row["viewReg"] ."</TD></TR><br />";
  38. }
  39. echo "</TABLE>";
  40. }
  41. ?>
  42.  

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.
Last edited by boo_lolly; Nov 13th, 2006 at 1:38 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Light Poster
boo_lolly is offline Offline
35 posts
since Nov 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Table issue
Next Thread in PHP Forum Timeline: phpmyadmin





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC