By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,864 Members | 1,324 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,864 IT Pros & Developers. It's quick & easy.

Display Results within results - PHP & MySQL

P: 18
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:
Expand|Select|Wrap|Line Numbers
  1. mysql> desc skylos;
  2. +---------------+------------------+------+-----+---------+----------------+
  3. | Field         | Type             | Null | Key | Default | Extra          |
  4. +---------------+------------------+------+-----+---------+----------------+
  5. | id            | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
  6. | Type          | text             | NO   |     | NULL    |                |
  7. | Name          | text             | NO   |     | NULL    |                |
  8. | Address       | text             | NO   |     | NULL    |                |
  9. | City          | text             | NO   |     | NULL    |                |
  10. | County        | text             | NO   |     | NULL    |                |
  11. | State         | text             | NO   |     | NULL    |                |
  12. | Zip           | text             | NO   |     | NULL    |                |
  13. | Phone         | text             | NO   |     | NULL    |                |
  14. | Email_Exists  | text             | NO   |     | NULL    |                |
  15. | Email_Address | text             | NO   |     | NULL    |                |
  16. | Website       | text             | NO   |     | NULL    |                |
  17. +---------------+------------------+------+-----+---------+----------------+
  18. 12 rows in set (0.00 sec)
4) I am also referencing the extract() function here:

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.

$result = mysql_query("SELECT ID, Phone FROM skylos;");

// Already connected above

while ($row = mysql_fetch_assoc($result)) {
extract($row, EXTR_PREFIX_ALL, "conf");
print "<B>Business answering at $conf_Phone:</B><br />";
$subresult = mysql_query("SELECT ID, Phone FROM skylos WHERE Address = $conf_ID;");

while ($subrow = mysql_fetch_assoc($subresult)) {
extract($subrow, EXTR_PREFIX_ALL, "Address");
print " $Address_Address<br />";

print "<br />";

Thx all in advance for any help.

Oct 20 '08 #1
Share this Question
Share on Google+
2 Replies

Expert 5K+
P: 5,058

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?
Oct 22 '08 #2

P: 18
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 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


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.

Oct 22 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.