Jump to content

php and mysql


corillo181

Recommended Posts

what i'm looking for is how i can put some images in a directory and have their name in mysql to pull it from mysql, if that makes sense..

i'm lost my self..

but i been looking for putting pictures in mysql and everywhere it say is a bad idea and i'm looking for a way to put them in a folder but still work with them threw mysql..
Link to comment
Share on other sites

you can run your uploadfile and at the bottom of the same page have a mysql query insert just the name into you bd and just call the name up later when you want to display the pic like so

[code]
<?
your upload code here....
$pic=$_POST['pic_name'];
mysql_query("insert into your_table(pic_name)values('$pic')");
?>
[/code]

that is to insert the name into db

[code]

<?
$getpic=mysql_query("select * from your_table");
while($getpic2=mysql_fetch_array($getpic)){
echo "<img src=../your_pic_directory/$getpic2[pic_name]>";
}
?>

[/code]
and that is to pull the pic name up from the db
and where pic_name is replace that with the colmn name where your pics names are stored
Link to comment
Share on other sites

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]:S

what i dont get is.. how i'ma put the picture in the directory and the name in the database and when i call it from the data base how is it going to know where to look for the picture.[/quote]

ok i think i know the src gets the directory and the $pic is the fecth name form my sql..

but can this be done..

make a upload bottom to make the picture go to the directory and mysql?
Link to comment
Share on other sites

Variables inside single quotes are not expanded. Also the variable $row is an array. The index "name" of that array should contain the picture's filename. Try this:
[code]<?php echo '<img src="/xml/' . $row['name'] . '">'; ?>[/code]

Ken
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.