How to hide image object, if image not found? in php mysql
g7920453
Status: New User - Welcome
Joined: 23 Aug 2009
Posts: 3
Reply Quote
Hi ,

I am new in web programming. I am extracting questions and answers from data bases (php mysql) . Question table also contains a column (image id's) from table "image". Some of the questions have no images (blank in image_id column) . Now when i run the form if the image is present it shows fine but if not present it shows me an "icon".

I want to hide the icon of images.

Here is my big code :


<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php session_start(); ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


<link href="/m-games/css/main.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
-->
</style>
<link href="/m-games/css/main2.css" rel="stylesheet" type="text/css" />


</head>

<body>
<div id="container">
<div id="logo"><a href="/"><img src="/m-games/image/FMD.gif" alt="logo" width="90" height="40" border="0" align="left" longdesc="http://...co.uk" /></a></div>
<div class="bar"></div>
<div id="title">
<p>Quiz</p>
</div>
<div id="1"> <?php include '.../m-games/script/connection.php'; ?>
<div id="a2" style="display:hide;">
<?php
$questionid = $_POST['question'];
if($questionid == "") {
$questionid = "5";
}
$query = "SELECT * FROM question where id = " . $questionid;
$result = mysql_query($query)or die(mysql_error());
$row = mysql_fetch_assoc($result);
if( $row['image_id'] != "") {
$queryImage = "SELECT * FROM image where id = " . $row['image_id'] ;
$resultImage = mysql_query($queryImage)or die(mysql_error());
$rowImage = mysql_fetch_assoc($resultImage);
echo "<image src=\"" . $rowImage['url'] . "\"/></br></br>";
}
echo $row['display'] . "</br></br>";

?>
</div>
<div id="3">
<form id = "questionid" action="/m-games/check.php" method="post">
<?php
$result2 = mysql_query("select * from answer where question_from = ". $questionid) or die(mysql_error());
"</br></br>";
while ($row = mysql_fetch_array($result2, MYSQL_ASSOC)) {
printf(" <input type=\"radio\" name=\"question\" value=\"%s\"> %s<br>\n", $row["question_to"], $row["display"]);
}
mysql_close();
?>
</div>

<br />
<input name="submit" type="submit" value="submit" />
</form>
</div>
<div id="upper_portion">

<div class="bar"></div>
</div>
<div id="lower_portion">
<div class="image_div" id="wrapped">
<div class="lower_image"><a href="/home"><img src="/m-games/image/Home_01.gif" alt="home" width="42" height="42" border="0" /></a>
<div class="lowe_image_text"><a href="/home">home</a></div>
</div>
<div class="lower_image"><a href="/login"><img src="/m-games/image/Login_01.gif" alt="login" name="login" width="42" height="42" border="0" align="baseline" id="login" /></a>
<div class="lowe_image_text"><a href="/login">login</a></div>
</div>
<div class="lower_image"><a href="/score"><img src="/m-games/image/score.gif" alt="score" name="score" width="42" height="42" border="0" align="baseline" id="score" /></a>
<div class="lowe_image_text"><a href="templates/score">score</a></div>
</div>
<div class="lower_image"><a href="/comment"><img src="/m-games/image/New_01.gif" alt="comment" name="new" width="42" height="42" border="0" align="baseline" id="new" /></a>
<div class="lowe_image_text style1"><a href="templates/new">new</a></div>
</div>
<div class="lower_image"><a href="/new"><img src="/m-games/image/score.gif" alt="new" name="comment" width="42" height="42" border="0" align="baseline" id="comment" /></a>
<div class="lowe_image_text"><a href="templates/top score">top</a></div>
</div>
<div class="lower_image"><a href="/top"><img src="/m-games/image/Comments_01.gif" alt="top_score" name="comment" width="42" height="42" border="0" align="baseline" id="comment" /></a>
<div class="lowe_image_text"><a href="templates/comment">comment</a></div>
</div>
<div></div>
</div>
</div>
<div class="bar"></div>
</div>
</body>
</html>
Back to top
Display posts from previous:   

All times are GMT - 8 Hours