Forum Moderators: coopster
If theme02 is empty then I only want theme01 so show up, else both of them.
if(empty($row['theme02'])) {
$themes = "{$row['theme01']}";
}
else {
$themes = "{$row['theme01']} {$row['theme01']}";
} I manage to get by adapting free php scripts etc., but I'm no expert, so I'd appreciate any help.
Thanks
I don't get an error message, the page loads as it should, but no themes come up. This is the code in full. Maybe I'm using $themes wrongly?
$query = "SELECT * FROM films";
$result = mysql_query($query);if(empty($row['theme02'])) {
$themes = "{$row['theme01']}";
}
else {
$themes = "{$row['theme01']} {$row['theme01']}";
}
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
echo " $themes";
if(empty($row['theme02'])) {
$themes = "{$row['theme01']}";
}
else {
$themes = "{$row['theme01']} {$row['theme01']}";
}
echo $themes;
if(empty($row['theme02'])) {
$themes = $row['theme01'];
}
else {
$themes = $row['theme01']." ".{$row['theme01']};
}
echo $themes;
if(empty($row['theme02'])) {
$themes = "{$row['theme01']}";
}
else {
$themes = "{$row['theme01']} {$row['theme02']}";
}echo $themes;
But when I try to put it in the whole code, which is this
$query = "SELECT * FROM films";
$result = mysql_query($query);if(empty($row['theme02'])) {
$themes = "{$row['theme01']}";
}
else {
$themes = "{$row['theme01']} {$row['theme02']}";
}while($row = mysql_fetch_array($result, MYSQL_ASSOC))
echo "
<div class=ficinfo><a href=\"javascript:Start('../_films/{$row['link']}')\";>{$row['title']}</a><br>
[b]$themes[/b] - {$row['rating']} - {$row['length']}mins - {$row['date']} - by {$row['director']}<br>
{$row['summary']}</div>";
no value for $themes shows up.
I probably should have put the whole code in my first post. I think I have things in the wrong order and place. I'm happy that the if statement technically works though, it's the first php thing I've ever written from scratch. :)
$query = "SELECT * FROM films";
$result = mysql_query($query);while($row = mysql_fetch_assoc($result)) {
if(empty($row['theme02'])) {
$themes = "{$row['theme01']}";
}
else {
$themes = "{$row['theme01']} {$row['theme02']}";
}echo "
<div class=ficinfo><a href=\"javascript:Start('../_films/{$row['link']}')\";>{$row['title']}</a><br>
$themes - {$row['rating']} - {$row['length']}mins - {$row['date']} - by {$row['director']}<br>
{$row['summary']}</div>"; }