Display Results within results - PHP & MySQL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • trochia
    New Member
    • Oct 2008
    • 19

    #1

    Display Results within results - PHP & MySQL

    Hello all, I am fairly new to php etc, and I have a database

    1) I have already did a search for: "Results within results" on this site, in PHP & MySQL forums ( I think) properly...and one search resulted in over 100 pages etc.

    From the below structure of my DB, I would like to get the code from the below URL working on my existing data I have, but I am having trouble and I am just getting flustered....

    I would eventually like to have the user "select" first a $State and then $County from a "drop down" for now, and eventually a "map" but the "drop down" for these (2) will be a must have....but I am just trying to use this function first.

    At present, I am unable to even get proper printed results, and I know it has to do with something on the variable call end that is screwing me up.

    2) This is what I am using (learning) from:



    3) This is my mySQL db structure:
    Code:
    mysql> desc skylos;
    +---------------+------------------+------+-----+---------+----------------+
    | Field         | Type             | Null | Key | Default | Extra          |
    +---------------+------------------+------+-----+---------+----------------+
    | id            | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
    | Type          | text             | NO   |     | NULL    |                |
    | Name          | text             | NO   |     | NULL    |                |
    | Address       | text             | NO   |     | NULL    |                |
    | City          | text             | NO   |     | NULL    |                |
    | County        | text             | NO   |     | NULL    |                |
    | State         | text             | NO   |     | NULL    |                |
    | Zip           | text             | NO   |     | NULL    |                |
    | Phone         | text             | NO   |     | NULL    |                |
    | Email_Exists  | text             | NO   |     | NULL    |                |
    | Email_Address | text             | NO   |     | NULL    |                |
    | Website       | text             | NO   |     | NULL    |                |
    +---------------+------------------+------+-----+---------+----------------+
    12 rows in set (0.00 sec)
    4) I am also referencing the extract() function here:
    Import variables into the current symbol table from an array


    5) Here is the code I presently am playing with, as I want to for now just print out Phone, Name Address for now to get my feet wet with this function call.

    [PHP]
    $result = mysql_query("SE LECT ID, Phone FROM skylos;");

    // Already connected above

    while ($row = mysql_fetch_ass oc($result)) {
    extract($row, EXTR_PREFIX_ALL , "conf");
    print "<B>Busines s answering at $conf_Phone:</B><br />";
    $subresult = mysql_query("SE LECT ID, Phone FROM skylos WHERE Address = $conf_ID;");

    while ($subrow = mysql_fetch_ass oc($subresult)) {
    extract($subrow , EXTR_PREFIX_ALL , "Address");
    print " $Address_Addres s<br />";
    }

    print "<br />";
    }
    ?>
    [/PHP]

    Thx all in advance for any help.

    jim
    Last edited by Atli; Oct 20 '08, 07:15 PM. Reason: Added [code] tags to your MySQL output and fixed the php.net link
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    Those queries don't really make sense to me. They are both basically the same, except you try to filter the second one by matching the "Address" field to the "ID" field of the current row from the first query (which doesn't really make sense either).

    What is it exactly that you want this code to print?
    Could you show us an example?

    Comment

    • trochia
      New Member
      • Oct 2008
      • 19

      #3
      Atli, first of all I thank-you very much for the reply, and also again the "advanced search" search link you gave me. That will help a lot here on this site.

      1) I am building a site to donate to the planet, as 9/12/08 my dog was stolen. (Sorry for this info, but it is a life priority for me now) and trying to build a collective site, as www.petfinder.c om is no longer really maintained for the past year, and there is no way to search/locate and narrow things down precisely

      2) In my database, I presently have (2) tables but there will be 3 (at least) one to contain the above information which will be for Veterinarians, Kennels & Shelters. For now, this is what I am learning-practicing with.

      For now, I would would like the user come to a page, and first select from a populated drop-down or radio button (or for now) just enter $State 2 letter abbreviation ( here, they will be able to select only 1 ) of where they are located in.

      I will then "pull to display" $County (in which they live in, and also surrounding areas - so this could be multpile radio/drop-down), but here on this page it will ask if you are a :

      BUYER ( I have lost, found or missing a pet)

      SUPPLIER ( A Vet Hospital, Kennel or Animal Shelter will be located in only (1) physical location established. )

      Once this question is answered, we branch off like this:

      Buyer = User who has either LOST or FOUND a Pet (flagged in table) and they will be able to select multiple $County to search/post in. (locations), hence the my post topic of: "Display Results within results" to be able to then pull "listings" of either:

      $lost OR $found as it stands now, and this will display for them.

      $lost = Multiple radio for $County, City for $search

      If they have $found they will then be moved to a page for database entry:

      $enter > $found >$pet_type > $date

      Supplier = This will be used two-fold. $search + $enter (to above table in example)

      a: Buyer(user) selects $State, $County and depending on $Search will display one of the following

      $vet
      $shelter
      $kennel

      This is then used (displayed) for use for them (BUYER) to Contact (SUPPLIER) via $supplier [data]

      Sorry if this is too much information, but this is the flow.

      Thx again!! And I am enjoying this site.

      Jim

      Comment

      Working...