logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 12-05-2011, 07:52 PM   #1
NerdArmy
 
Join Date: Nov 2011
Location: Chicago
Posts: 9
Default Sql Problems, Same Field Names In Multiple Mysql Tables?

I have a keyword search that searches multiple DB tables for thumbnail images using UNION ALL. I have two pages, results.php, and view.php. My goal is to able to click a thumbnail image on results.php and be directed to a larger version of that same image on view.php. The problem is each image in all my tables uses the field name "id" so when I click a thumbnail on results.php I get two different images with the same id from different tables. I tried changing the id's to different names, but when it was time to pass url parameters I can only choose 1 value. (if you can choose more than 1 I don't know how). So my question is why are my id's from different tables being grouped together, and how can I change this?


Image Results Page (which works perfect):

SELECT *
FROM table1
WHERE keyword LIKE %colname% OR id LIKE %colname%
UNION ALL
SELECT *
FROM table2
WHERE keyword LIKE %colname% OR id LIKE %colname%



View Image Page (having problems here):

SELECT *
FROM table1
WHERE id = colname
UNION ALL
FROM table2
WHERE id = colname
NerdArmy is offline   Reply With Quote
Old 12-05-2011, 11:59 PM   #2
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

how is the link passed from results page to view.php?
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 12-06-2011, 12:09 AM   #3
NerdArmy
 
Join Date: Nov 2011
Location: Chicago
Posts: 9
Default

url parameters: viewtest.php?id=<?php echo $row_Recordset1['id']; ?>
NerdArmy is offline   Reply With Quote
Old 12-06-2011, 01:36 AM   #4
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

ok first check what is being passed
echo $_GET['id']:
im assuming that is a unique value, i doubt (guessing here) that you need to select from both tables then in view.php.
so select from that table that supplies the large size link. if this is over simplifying the problem maybe try a join based on two unique matching values.
It a little hard to say with out knowing the whole structure

are table1.id the same as table2.id ?
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas

Last edited by edbr; 12-06-2011 at 01:44 AM..
edbr is offline   Reply With Quote
Old 12-06-2011, 02:21 AM   #5
NerdArmy
 
Join Date: Nov 2011
Location: Chicago
Posts: 9
Default

yes they're the exact same.
NerdArmy is offline   Reply With Quote
Old 12-06-2011, 02:31 AM   #6
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

$where=$_GET['id'];


SELECT * FROM table1 JOIN table2 ON table1.id=table2.id where table1 = $where;

should be ok then image src ="images/ <?echo <?php echo $row_Recordset1['link']; ?>

or what ever the link field is called . tell me if im not getting the structure thouh
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Reply


Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:42 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com