when searching I want a line to print if nothing is found. I've added a if/else into my original if/elseif statement but am getting an error -
Parse error: syntax error, unexpected T_ELSE in /home/content/a/r/t/art2294/html/ifElse.php on line 62
Things look ok to me but I am very new at this and perhaps I can't do a nested if/else?
I'm 100% on the ($result != "0") either, it makes sense that if nothing is found it would be set to 0.
$field=$_POST["field"];
$search=trim($_POST["find"]);
if ($field == "artist")
{
echo "<b>Names of Artist(s)</b> <br><br>";
$result = mysql_query("SELECT * FROM artist WHERE fullName LIKE '%$search%'");
if ($result != "0")
{
$count = count(0);
while ($r=mysql_fetch_array($result))
{
$fullName=$r["fullName"];
echo $count++; echo ". ".$fullName." <br>";
}
else
{
echo "Nothing found.";
}
}
}
elseif ($field == "artwork")
{
echo "<b>Titles</b> <br><br>";
$result = mysql_query("SELECT image.imgid, image.title, image.artid, image.dt, artist.artid, artist.fullName FROM image LEFT JOIN artist ON artist.artid = image.artid WHERE image.title LIKE '%$search%' ORDER BY title") or die(mysql_error());
$count = count(0);
while ($r=mysql_fetch_array($result))
{
$title=$r["title"];
$imgid=$r["imgid"];
$dt=$r["dt"];
$artid=$r["artid"];
$fullName=$r["fullName"];
echo $count++;
echo ". <a href='image.php?imgid=$r[imgid]'><img src=\"image/$imgid\" border=0 ></a>, <i>".$title."</i>, ".$dt." by <a href='artist.php?artid=$r[artid]'>".$fullName."</a><br>";
}
}
elseif ($field == "keywords")
{
echo "I will check all keywords.";
}
else
{
echo "I will search everywhere.";
}