In the second row php echo's my users perfectly ($test variable) but the mysql_query won't work. Maybe this is not possible, I don't know🙂Thanks for your help."> SOLVED: Images from Joomgallery - Forums

Forums

SOLVED: Images from Joomgallery

Invidia 10 Aug, 2012
Hello,

I want to view images from different users, so they are saved in different directories.
I placed this code in the Body in CC.

<td><img src="images/joomgallery/thumbnails/
<?php
$test="{user}"; 
$result = mysql_query("SELECT * FROM yaeth_joomgallery_catg
WHERE name='".$test."'");
while($row = mysql_fetch_array($result))
{
$map=$row['catpath'];
}
echo "$map"; ?>/{foto1}" height="120" width="160" /></td>
<td><?php 
echo "$test"; ?><td>
<td>


In the second row php echo's my users perfectly ($test variable) but the mysql_query won't work. Maybe this is not possible, I don't know🙂

Thanks for your help.
GreyHead 11 Aug, 2012
Hi Invidia,

You can't use the curly brackets syntax in PHP like this $test="{user}"; because the curly brackets are replaced after the PHP runs. Use the data array instead; I think that it needs to be $test = $row['user'];

Bob
Invidia 11 Aug, 2012
That's the problem I have. {user} is in a my default table of CC. yaeth_joomgallery_catg is a different one. The script needs to search for the folder name of joomgallery, every user has a different folder.
Max_admin 11 Aug, 2012
Hi Invidia,

You are doing this wrong, first, please use Bob's suggestion, you should not use {field_name} inside php, use the php variable instead, $row['field_name']

Don't use the var $row in your code since its already used.

Don't do an extra query, actually you are doing a query per row, which is wrong, you should simply associate your 2nd table to the main table under the "multi tables" tab, table name should be "yaeth_joomgallery_catg", model id "CATG", Join rule: CATG.name=MAIN_MODEL_ID.user, foreign key should be "user", you should do it this way if possible.

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
Invidia 11 Aug, 2012
Great, got it working with the Multiple tables.

Thanks !
This topic is locked and no more replies can be posted.