Hello all
Just starting out in PHP/MySQL so bare with me here!
I have a form sending the values of 4 variables ($name,$email,$url,$story) to a database. The script I'm using to show the data is below.
<?php
$conn=mysql_connect("localhost","jamie","*******") or
die(mysql_error());
$database=mysql_select_db("jamie_scribble",$conn)or die(mysql_error());
$sql="SELECT * FROM scribbles ORDER BY id DESC LIMIT 10";
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
echo"<h4 class=\"title\">"
.strftime('%d/%m/%Y %I:%M %p',strtotime($row["date"]));
if (??????){
echo" | <a href=\"mailto:" .stripslashes($row["email"]); echo"\">" .stripslashes($row["name"])."</a></h4>";
} elseif (??????){
echo" | <a href=\"" .stripslashes($row["url"]); echo"\">" .stripslashes($row["name"])."</a></h4>";
} else {
echo" | " .stripslashes($row["name"])."</h4>";
}
echo"<div class=\"post\">";
echo nl2br(stripslashes($row["story"]));
echo"</div>";
}
mysql_close($conn);
?>
I'm trying to show the NAME as a link which will either be pointed at the users EMAIL or URL depending which they entered. So if they entered either one of them, that would be used, if they entered both of them URL would be used and if they didn't enter either, the name just wouldn't be a link at all.
The problem I'm having is the condition of the if and else if statement. I've been trying stuff like if ($email!="") blah blah but to no effect.
Any ideas?
TIA
Jamie