Forum Moderators: coopster
I am having an issue in trying to properly display the results of a query where i query two tables...
I think the issue is that both tables have a field named 'id'...
My query seems to return the proper results, and is as follows:
$query = "SELECT * FROM NewLinks2,Newstores WHERE NewLinks2.store = Newstores.advertiser AND DATE_SUB(CURDATE(),INTERVAL 5 DAY) <= entry AND entry <= '$mydate' AND expire > '$today' ORDER BY NewLinks2.id";
However, when I display:
<a href='dealview2.php?id=$id'>$linktext</a>
the value of id is all screwed up?
How do I specify which table the value for id should show up?
thanks!
David
However, you can also do this in the query:
$query = "SELECT `NewLinks2`.`id` AS nl2_id,`Newstores `.`id` AS ns_id,* FROM NewLinks2,Newstores WHERE NewLinks2.store = Newstores.advertiser AND DATE_SUB(CURDATE(),INTERVAL 5 DAY) <= entry AND entry <= '$mydate' AND expire > '$today' ORDER BY NewLinks2.id";
Incidentally, make sure you are escaping any user input (like $mydate) before sending it to the database. :)