here try this.
PHP Code:
<?php
$host = "host";
$user = "user";
$pass = "password";
$link = mysql_connect($host , $user , $pass);
if($link) {
$db_selected = mysql_select_db("image",$link);
if ($db_selected) {
$image = "images/advert.jpg";
$result = mysql_query("SELECT * FROM table WHERE image='$image' ");
while($I = mysql_fetch_array($result)) {
echo "- entry: ".$I['image']."<br/>";
}
}
}
while($I = mysql_fetch_array($result)) {
$img = sprintf("<img src=\"images/advert.jpg\" width=\"20\" height=\"100\" alt=\"20\">", $I['image']);
echo $img;
}
?>
If you look at this specific line
PHP Code:
$img = sprintf("<img src=\"images/advert.jpg\" width=\"20\" height=\"100\" alt=\"20\">", $I['image']);
The backslashes in font of the quotes are needed to tell php to ignore this quote as the end of the string I'm entering. I believe the proper name for it is escaping.
Just remember that any time you need to use a quote for a normal html like src="", alt="", etc. inside your php echo string or whatever else your entering you need to add the backslash in front of it so php will ignore the quote.
Bookmarks