September 8, 200818 yr Hi guys, I currently have a table displaying items from a mysql database. I would also like to add images to the table. I have an images folder already in the same web directory as all my pages, containing the images I would like to display. What code do I need to use to display these images in the table? My code is currently as follows: <?php // Connect to MYSQL and Select database $dbc = mysql_connect (*********,'****','*********') OR die('Could not connect to MySQL : ' . mysql_error() ); mysql_select_db ('cse') OR die('Could not select the database : ' . mysql_error() ); // Perform SQL query $query = "SELECT * FROM harrison_catergories WHERE Cat_id = 1"; $result = mysql_query ($query); ?> </p> <table width="700" border="1"> <tr> <td width="120" height="32"><strong>Item</strong></td> <td width="412"><strong>Description</strong></td> <td width="70"><strong>Cost</strong></td> <td width="70"><strong>Stock</strong></td> <td width="70"><strong>Purchase</strong></td> </tr> <?php while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { Echo "<tr><td>$row[item]</td><td>$row[Description]</td><td>$row[Cost]</td><td>$row[stock]</td><td><a href = 'purchase.php$row[Purchase]'>Buy</a></td></tr>\n"; } mysql_close(); ?> Cheers guys, hope sum1 can help me out? Jay
September 8, 200818 yr Hi this is how i did it when i first started to learn <td><A href='message.php?id=$getthreads3[postid]'><img src='$getthreads3[image] 'width='100' height='100' border='0'> you would want to remove the link and the post id info [image] been the the root of the image so what i do is upload an image into a folder called upload or what ever you want to call it and while uploading the file put the root and name of the photo into the image colum so the image colum would be upload/photo1.jpg hope it helps i dont have much time tonight but if you carnt get it work i ill write you a script so you can learn from it good luck
September 8, 200818 yr Author Hi this is how i did it when i first started to learn <td><A href='message.php?id=$getthreads3[postid]'><img src='$getthreads3[image] 'width='100' height='100' border='0'> you would want to remove the link and the post id info [image] been the the root of the image so what i do is upload an image into a folder called upload or what ever you want to call it and while uploading the file put the root and name of the photo into the image colum so the image colum would be upload/photo1.jpg hope it helps i dont have much time tonight but if you carnt get it work i ill write you a script so you can learn from it good luck Ok so if I wanted to to convert that code to work for an image called 'rugbyshirt' in a folder called 'images', stord in my website directory, how would I go about it? Cheers, Jay????
September 8, 200818 yr Ok so if I wanted to to convert that code to work for an image called 'rugbyshirt' in a folder called 'images', stord in my website directory, how would I go about it? Cheers, Jay???? this is an actual script i am using for a demo of how to extract images from a database include"connect.php"; $query=mysql_query("SELECT * from fruit"); while ($result=mysql_fetch_array($query,MYSQL_ASSOC)) { print "<table width=70%>"; print "<tr class='mainrow'><td width=25px><b>product number</b><br>$result </td><td width=100px><img src='$result[image]' width='100' height='100'></td><td width=100px><b>Product Name</b><br>$result[name]</td><td width=70px><b>Price</b></br>$result[price]</td><td width=300px><b>Description</b><br>$result[description]</td></tr>"; } print "</table>"; ?> you dond need to change the code just make sure you have a colum in mysql called images and that colum should be upload/rugbyshirt.jpg i am presuming its a jpg extension i can write you a full script if you have difficulty with it and then you can change things to suit your final script
September 8, 200818 yr I'm getting mixed messages here. Is the image stored in a database or a file on your servers file system? To use an image in a table row you use something like <td width="70"><strong><img src="images/rugbyshirt.jpg" alt="Rugby Shirt" /></strong></td>
September 8, 200818 yr Author this is an actual script i am using for a demo of how to extract images from a database include"connect.php"; $query=mysql_query("SELECT * from fruit"); while ($result=mysql_fetch_array($query,MYSQL_ASSOC)) { print "<table width=70%>"; print "<tr class='mainrow'><td width=25px><b>product number</b><br>$result </td><td width=100px><img src='$result[image]' width='100' height='100'></td><td width=100px><b>Product Name</b><br>$result[name]</td><td width=70px><b>Price</b></br>$result[price]</td><td width=300px><b>Description</b><br>$result[description]</td></tr>"; } print "</table>"; ?> you dond need to change the code just make sure you have a colum in mysql called images and that colum should be upload/rugbyshirt.jpg i am presuming its a jpg extension i can write you a full script if you have difficulty with it and then you can change things to suit your final script Brilliant, with a little tweeking, that worked. Thanx heaps!!! Jay.
September 8, 200818 yr Author I'm getting mixed messages here. Is the image stored in a database or a file on your servers file system? To use an image in a table row you use something like <td width="70"><strong><img src="images/rugbyshirt.jpg" alt="Rugby Shirt" /></strong></td> Yeah Gibbs you were right, thats pretty much what I came up with. Thanx.
September 9, 200818 yr I'm getting mixed messages here. Is the image stored in a database or a file on your servers file system? To use an image in a table row you use something like <td width="70"><strong><img src="images/rugbyshirt.jpg" alt="Rugby Shirt" /></strong></td> No i store the image in folder called uploads then store the root of the folder in a varchar images is the name of the folder so you would have in mysql colum called image images/rugbyshirt.jpg i will write you a complet script and send it you
September 9, 200818 yr have you managed to get your images displayed i have a bit more time now i can write you a script and post it for you so that you can acctualy upload the file from your website form
September 12, 200818 yr Author have you managed to get your images displayed i have a bit more time now i can write you a script and post it for you so that you can acctualy upload the file from your website form Yeah got it working fine, thanx 4 all ur help. I do however, have another query, do you know how i would go about sending a completed form in an email? So once the submit button is pressed, the information filled in in the fields, will b emailed. Cheers, Jay.
September 12, 200818 yr Yeah got it working fine, thanx 4 all ur help. I do however, have another query, do you know how i would go about sending a completed form in an email? So once the submit button is pressed, the information filled in in the fields, will b emailed. Cheers, Jay. This is Jems try the link if its not what ya after let me know http://www.jemjabella.co.uk/scripts/free-php-mail-form
Create an account or sign in to comment