Re: retrieveing vars from mysql join ?



= poster = wrote:
Hi all ,

I have the following problem :

$some_query = mysql_query(
"SELECT table1.id, table1.category, table1.author, table1.title, table2.title, table2.category FROM table1, table2
WHERE table1.category = table2.category ORDER by table1.id DESC");

while($record = mysql_fetch_array($some_query))
{
$mycategory = ($record['table1.category']);
$mytitle = ($record['table2.title']);

echo"$mycategory";
echo"$mytitle";
}

Does someone know what's wrong here ?
echo don't show the requested values ....


thanks !



A stupid question - but are you actually calling mysql_query() before trying the fetch the results?

Then try the following - and look at your index values:

echo "<pre>\n";
print_r($record);
echo "</pre>\n";

And finally, you can make things easier on yourself with something like:

"SELECT ... table1.category AS tab1category,
... table2.category AS tab2category ...

Also, if a column has a unique name in the tables listed in your FROM clause, just use the column name. You only need the table name when you have duplicate column names, as in category.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.



Relevant Pages

  • Re: Getting ID from a presented table
    ... Jerry Stuckle ... JDS Computer Training Corp. ... PHP echo statement instead. ... I do not know how to do that in HTML. ...
    (comp.lang.php)
  • Re: Getting ID from a presented table
    ... Jerry Stuckle ... JDS Computer Training Corp. ... Same idea - just generated with a PHP echo statement instead. ... I do not know how to do that in HTML. ...
    (comp.lang.php)
  • Re: Getting ID from a presented table
    ... Jerry Stuckle ... JDS Computer Training Corp. ... PHP echo statement instead. ... I do not know how to do that in HTML. ...
    (comp.lang.php)
  • Re: Getting ID from a presented table
    ... Jerry Stuckle ... JDS Computer Training Corp. ... Same idea - just generated with a PHP echo statement instead. ... I do not know how to do that in HTML. ...
    (comp.lang.php)
  • Re: Getting ID from a presented table
    ... Jerry Stuckle ... JDS Computer Training Corp. ... echo statement instead. ... I do not know how to do that in HTML. ...
    (comp.lang.php)