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
https://forums.phpfreaks.com/topic/8936-php-and-mysql/
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
https://forums.phpfreaks.com/topic/8936-php-and-mysql/#findComment-32858
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
https://forums.phpfreaks.com/topic/8936-php-and-mysql/#findComment-32861
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.