By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,501 Members | 2,805 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,501 IT Pros & Developers. It's quick & easy.

help with image name to match with DB table record

P: 37
hi, i have this code and i wanted to match a record field name i.e. primary key with a image name, but i cant get it to work, i cant think of anything else how to do it

heres the code
[PHP]
<?php
include "db.private";
header("Content-type: image/jpg");
$name = $_REQUEST["name"];
$connection = mysql_connect($hostname,$username,$password);
mysql_select_db($databaseName);
$sql = "SELECT image FROM images WHERE name = '".$name."'";
$result = mysql_query($sql);
$nrows = mysql_num_rows($result);
if($nrows == 1) {
$row = mysql_fetch_array($result);
echo $row["image"];
}
?>

[/PHP]
"db.private" here is my login details which has passwords and all that

i cant get this to work and match it with a feild name and then display the image
[PHP]$sql = "SELECT carID FROM car_name WHERE name = '".$name."'";[/PHP]


and im using this code here...
[HTML]print "<img src=getImg.php?name=" . $name . ">";[/HTML]
to display on anther php php file
Jan 4 '08 #1
Share this Question
Share on Google+
1 Reply


brettl
P: 41
I'm not sure if this will help but I think you should want this
Expand|Select|Wrap|Line Numbers
  1. print "<img src=getImg.php?name=" . $name . ">";
  2.  
to look like this
Expand|Select|Wrap|Line Numbers
  1. echo '<img src="getImg.php?name='.$name.'" alt="'.$name.'"/>';
  2.  
Jan 4 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.