littlepeg Posted September 1, 2007 Share Posted September 1, 2007 Hi, everybody, would you please tell me that what should I do if I want to output images using php code ? Any help would be grateful. Thank you Quote Link to comment https://forums.phpfreaks.com/topic/67516-solved-output-image/ Share on other sites More sharing options...
pocobueno1388 Posted September 1, 2007 Share Posted September 1, 2007 <?php echo '<img src="URL">'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/67516-solved-output-image/#findComment-339006 Share on other sites More sharing options...
Fadion Posted September 1, 2007 Share Posted September 1, 2007 If u told what u want to do then u could get some more help. A pretty simple example using the GD library: $imagePath = 'myimage.jpg'; $img = imagecreatefromjpeg(); //create the image resource from the file header('Content-type: image/jpeg'); //set the header so it outputs the image imagejpeg($img); //output the image It actually does nothing, just gets an existing image and outputs it to the browser. Look for GD at the php manual and you'll find a lot u can do with images. Quote Link to comment https://forums.phpfreaks.com/topic/67516-solved-output-image/#findComment-339007 Share on other sites More sharing options...
littlepeg Posted September 1, 2007 Author Share Posted September 1, 2007 Hi, I have a row of pictures (emoticons) at the top of the web page. And I want to output a story from my sql database underneath these pictures. Then I would like another row of the same pictures followed by another story from the database. Then I would like to continue repeating this sequence until all of the stories from the database are on this web page. How can I do this using php codes? I would be grateful for any help. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/67516-solved-output-image/#findComment-339011 Share on other sites More sharing options...
Fadion Posted September 1, 2007 Share Posted September 1, 2007 $connect = mysql_connect('hostname', 'username', 'password'); mysql_select_db('myDB'); $query = mysql_query("SELECT * FROM stories"); while($values = mysql_fetch_array($query)){ echo "<img src=\"emoticons.jpg\" /><br />"; echo $values['story']; echo "<br /><br />"; } mysql_close($connect); If u know some simple database handling u shouldnt have problems with what u want. Quote Link to comment https://forums.phpfreaks.com/topic/67516-solved-output-image/#findComment-339014 Share on other sites More sharing options...
littlepeg Posted September 1, 2007 Author Share Posted September 1, 2007 Hi GuiltyGear, thank you for your reply. However, you showed me how to output one pictures, but how would I output several pictures in a row? Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/67516-solved-output-image/#findComment-339019 Share on other sites More sharing options...
Fadion Posted September 1, 2007 Share Posted September 1, 2007 In the same way echo "<img src=\"emoticon1.jpg\" /><img src=\"emoticon2.jpg\" /><br />"; Quote Link to comment https://forums.phpfreaks.com/topic/67516-solved-output-image/#findComment-339021 Share on other sites More sharing options...
littlepeg Posted September 1, 2007 Author Share Posted September 1, 2007 Thank you very much. I will try it now. :) Quote Link to comment https://forums.phpfreaks.com/topic/67516-solved-output-image/#findComment-339023 Share on other sites More sharing options...
Fadion Posted September 1, 2007 Share Posted September 1, 2007 Nah the above code will output images below each other. U can use an html table for simply hanging this out: echo "<table> <tr> <td><img scr=\"emoticon1.jpg\" /></td> <td><img scr=\"emoticon2.jpg\" /></td> <td><img scr=\"emoticon3.jpg\" /></td> </tr> </table>"; Quote Link to comment https://forums.phpfreaks.com/topic/67516-solved-output-image/#findComment-339025 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.