sonofjack
09-01-2011, 02:53 PM
Hi
I can't find any solution to this one but hopefully someone on here might know.
I have a page that displays a list of gigs and I want one field to show up as a link only if something has been entered into that field.
I can set it up so it shows the field data which relates to the filename it links to, but I want it to display an image or something else of my choice (eg 'SETLIST') with the entered data acting as a hyperlink as I have it now.
I wondered about a if ...else statement in here to say if the SETLIST field has something in it then display this code... otherwise display this code.
But I can't work it out
Can anyone help please?
[gigsetlist] is the SQL field that I type 19950830 into it so it links to a file called 19950830.php and opens accordingly. But some of these in the list won't have anything so I don't want to a link to appear.
However I don't want the link to be displayed as 19950830 but instead SETLIST or an icon.
Hope that makes sense. Can anyone help please?
$sql = "SELECT id, gigdate, date_format(gigdate,'%d %M') as d, gigshortdesc, gigsetlist FROM gigs WHERE gigdate
BETWEEN '1995-01-01' AND '1995-12-31' ORDER BY gigdate ASC";
print '<table>';
foreach($dbh->query($sql) as $row)
{
print '<tr>
<td width=100>' . $row['d'] . ' </td>
<td> ' . $row['gigshortdesc'] . '</td>
<td> <a href="sets/' . $row['gigsetlist'] . '.php" onclick="return openWin(this.href, this.target, 480, 480, 1, 0, 0, 0, 0, 1);"
target="_setlist">' . $row['gigsetlist'] . '</a></td>
</tr>';
}
print '</table>';
$dbh = null;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
?>
Many thanks
sonofjack
I can't find any solution to this one but hopefully someone on here might know.
I have a page that displays a list of gigs and I want one field to show up as a link only if something has been entered into that field.
I can set it up so it shows the field data which relates to the filename it links to, but I want it to display an image or something else of my choice (eg 'SETLIST') with the entered data acting as a hyperlink as I have it now.
I wondered about a if ...else statement in here to say if the SETLIST field has something in it then display this code... otherwise display this code.
But I can't work it out
Can anyone help please?
[gigsetlist] is the SQL field that I type 19950830 into it so it links to a file called 19950830.php and opens accordingly. But some of these in the list won't have anything so I don't want to a link to appear.
However I don't want the link to be displayed as 19950830 but instead SETLIST or an icon.
Hope that makes sense. Can anyone help please?
$sql = "SELECT id, gigdate, date_format(gigdate,'%d %M') as d, gigshortdesc, gigsetlist FROM gigs WHERE gigdate
BETWEEN '1995-01-01' AND '1995-12-31' ORDER BY gigdate ASC";
print '<table>';
foreach($dbh->query($sql) as $row)
{
print '<tr>
<td width=100>' . $row['d'] . ' </td>
<td> ' . $row['gigshortdesc'] . '</td>
<td> <a href="sets/' . $row['gigsetlist'] . '.php" onclick="return openWin(this.href, this.target, 480, 480, 1, 0, 0, 0, 0, 1);"
target="_setlist">' . $row['gigsetlist'] . '</a></td>
</tr>';
}
print '</table>';
$dbh = null;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
?>
Many thanks
sonofjack