mark103 Posted July 8, 2011 Share Posted July 8, 2011 hi guys, i need your help. i has been searching through on google as i am looking for a php code where i can just stored the images link in the mysql database table, and then display the images. Most of the search results on google they are for stored the images in mysql which is a pretty bad idea. I just want to store the images link in mysql and display the images in php. I can't find it, please can you help? Cheers. Quote Link to comment https://forums.phpfreaks.com/topic/241441-how-to-display-images-when-stored-link-in-mysql-database/ Share on other sites More sharing options...
jkewlo Posted July 8, 2011 Share Posted July 8, 2011 Just real fast call the mysql record with the path normally my paths are like img/img hardcoded like and for the record I have the image name.. say jkewlo.png <img src=\"". $row['img_path'] ."\"> Quote Link to comment https://forums.phpfreaks.com/topic/241441-how-to-display-images-when-stored-link-in-mysql-database/#findComment-1240243 Share on other sites More sharing options...
mark103 Posted July 8, 2011 Author Share Posted July 8, 2011 Thanks for your quick replied jkewlo and thanks for your help, do you know how I can set the description text next to the images without set them under the images? something got to do with this line: echo "<img src ='".$image_path."'>", "<p id='text_description'>", $row['text_description'] . "</p>" ; here's the current code: <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'mydbusername'); define('DB_PASSWORD', 'mydbpassword'); define('DB_DATABASE', 'mydbname'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($var){ return mysql_real_escape_string(strip_tags($var)); } $username = clean($_GET['user']); $pass = clean($_GET['pass']); if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo implode('<br />',$errmsg_arr); } else { $insert = array(); if(isset($_GET['user'])) { $insert[] = 'username = \'' . clean($_GET['user']) .'\''; } if(isset($_GET['pass'])) { $insert[] = 'pass = \'' . clean($_GET['pass']) . '\''; } if (count($insert)>0) { $names = implode(',',$insert); if($username) { $qrytable1="SELECT username, images, text_description FROM user_list WHERE username='$username'"; $result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error()); while ($row = mysql_fetch_array($result1)) { $image_path = $row['images']; echo "<img src ='".$image_path."'>", "<p id='text_description'>", $row['text_description'] . "</p>" ; } } } } ?> Any help would be much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/241441-how-to-display-images-when-stored-link-in-mysql-database/#findComment-1240286 Share on other sites More sharing options...
$php_mysql$ Posted July 8, 2011 Share Posted July 8, 2011 whts ur error? Quote Link to comment https://forums.phpfreaks.com/topic/241441-how-to-display-images-when-stored-link-in-mysql-database/#findComment-1240287 Share on other sites More sharing options...
mark103 Posted July 8, 2011 Author Share Posted July 8, 2011 there is no error, i have got the image on the top and the text description which are on below. I just want to know how to set them next to the images? Quote Link to comment https://forums.phpfreaks.com/topic/241441-how-to-display-images-when-stored-link-in-mysql-database/#findComment-1240288 Share on other sites More sharing options...
jcbones Posted July 8, 2011 Share Posted July 8, 2011 You could use CSS to just float that image to the right or left. Quote Link to comment https://forums.phpfreaks.com/topic/241441-how-to-display-images-when-stored-link-in-mysql-database/#findComment-1240296 Share on other sites More sharing options...
Eiolon Posted July 8, 2011 Share Posted July 8, 2011 You can use CSS. Just put the image in a DIV, the text in a second DIV, and place the DIV's next to each other. Or you can use tables and place them in each in their own cell next to each other on the same row. Quote Link to comment https://forums.phpfreaks.com/topic/241441-how-to-display-images-when-stored-link-in-mysql-database/#findComment-1240298 Share on other sites More sharing options...
$php_mysql$ Posted July 8, 2011 Share Posted July 8, 2011 this helps? echo "<img src ='".$image_path."' align=\"left\">", "<p id='text_description'>", $row['text_description'] . "</p>" ; Quote Link to comment https://forums.phpfreaks.com/topic/241441-how-to-display-images-when-stored-link-in-mysql-database/#findComment-1240299 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.