PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 20th, 2000, 02:31 PM
fishindex fishindex is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 7 fishindex User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I have two separate tables in my database - one with information and one with photos. I would like to link the two of these tables together. So when you go to an information page there is a small link that has a link to a photo for that fish. And vise versa when you go to the photos page.

The way I am going to have to link the tables together is by their scientific name. Because that is the only thing that they have in common. I tired something like this:

$result16 = mysql_query("SELECT * FROM photos WHERE $id=id",$db);
$result17 = mysql_query("SELECT * FROM info WHERE $result16=scientific_name",$db);
while ($myrow = mysql_fetch_array($result17)) {
printf("More information about <a href=$info_php?id=%s&author=%s><b>%s</b></a>?", $myrow["id"], $myrow["author_id"], $myrow["common_name"]);
}

I keep getting a 0 result when I do this.

I only want the link to show up if there is information about the fish in the other table. Also, the fields that I am tiring to link have multiple words because they are scientific names.

Does anyone know a better way for me to do this?

Off the subject - In my script I used "SELECT * FROM table". Does it kill a server if you use this A LOT. Sometimes when the script is loading it is being used 6-7 times.

------------------


[This message has been edited by fishindex (edited June 20, 2000).]

Reply With Quote
  #2  
Old June 20th, 2000, 02:37 PM
scollo scollo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 1999
Posts: 114 scollo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 44 sec
Reputation Power: 15
I'm not sure I got it completely, but it looks like you need some sort of join:

select * from info, photos where info.id=photo.id;

Reply With Quote
  #3  
Old June 20th, 2000, 03:00 PM
fishindex fishindex is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 7 fishindex User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I probably wasn't too clear. I want to match table1 to table2 if any row in column1 is the same in the both of the tables. BUT in column1 all the records are something like "Foo foo." I think I can't get it to work because there are two words.

Would I use the join thing for something like this?

------------------

Reply With Quote
  #4  
Old June 21st, 2000, 02:00 AM
vijayvenkataraman vijayvenkataraman is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 3 vijayvenkataraman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hello fishindex..

Please give full details of table with fields so that I can help U well.

vijay

Reply With Quote
  #5  
Old June 21st, 2000, 10:08 PM
Sepodati's Avatar
Sepodati Sepodati is offline
Banned (not really)
Dev Shed God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 1999
Location: Brussels, Belgium
Posts: 14,628 Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)  Folding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced Folder
Time spent in forums: 3 Months 6 Days 2 h 39 m 6 sec
Reputation Power: 4375
Send a message via ICQ to Sepodati Send a message via Yahoo to Sepodati
select photo.picture as picture, info.scientificname as s_name, info.author as author, info.commonname as c_name from photo,info where photo.scientificname = info.scientificname;

I think that will work.

---John Holmes
---www.SepodatiCreations.com

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Matching up tables

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap