corillo181 Posted May 3, 2006 Share Posted May 3, 2006 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.. Quote Link to comment Share on other sites More sharing options...
shortj75 Posted May 3, 2006 Share Posted May 3, 2006 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 dband where pic_name is replace that with the colmn name where your pics names are stored Quote Link to comment Share on other sites More sharing options...
corillo181 Posted May 3, 2006 Author Share Posted May 3, 2006 [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]:Swhat 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? Quote Link to comment Share on other sites More sharing options...
corillo181 Posted May 3, 2006 Author Share Posted May 3, 2006 ok i got it to wotk but now i can't display the picture using it like this[code]<?phpinclude 'config/db.php';$getpic=mysql_query("SELECT name FROM upload2");while($row=mysql_fetch_array($getpic)){echo '<img src="/xml/$row">';}?>[/code] Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted May 3, 2006 Share Posted May 3, 2006 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 Quote Link to comment Share on other sites More sharing options...
corillo181 Posted May 3, 2006 Author Share Posted May 3, 2006 yeah that worked :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.