Reply to Re: retrieveing vars from mysql join ?

Your name:

Reply:


Posted by Jerry Stuckle on 12/01/06 13:26

= 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@attglobal.net
==================

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация