473,395 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Image and others data insertion and retrive from mysql database

20
HEY guys
i can insert datas and image separately into mysql bt now i need to insert images and datas together like image of a laptop, maker. description, price bt it not working it only displaying other datas without the image..plz can someone help me..This is form code to insert and also my insert code.
Thanks in Anticipation


insert code...
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require_once("db_connect.php");
  3. $db=mysqli_connect("$host","$user","$password","$db");
  4.  
  5. $sel="SELECT * FROM products ";
  6.  
  7. $result=mysqli_query($db,$sel);
  8. $num=mysqli_num_rows($result);
  9.  
  10.  
  11. if(!@result)
  12. {
  13.     die('<p>Error Retrieving</br>');
  14. }
  15. ?>
  16.  
  17. <h1>List of our products</h1>
  18.  <table border="5" width="1000">
  19.  
  20. <tr bgcolor="#FF00FF">
  21. <th bgcolor="#FF0000">TITLE</th>
  22. <th>PRODUCT CODE</th>
  23. <th bgcolor="#FF0000">PRODUCT NAME</th>
  24. <th>DESCRIPTION</th>
  25. <th bgcolor="#FF0000">PRICE</th>
  26. <th>IMAGE</th>
  27. <th bgcolor="#FF0000">DETAILS</th>
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34. </tr>
  35.  
  36.  
  37. <?php
  38.  
  39. while($row=mysqli_fetch_array($result)) {
  40. extract($row);
  41.  
  42. echo'<tr bgcolor="yellow">';
  43. echo'<td bgcolor=:green">'.$row['title'].'</td>';
  44. echo'<td>'.$row['product_code'].'</td>';
  45. echo'<td bgcolor=:green">'.$row['product_name'].'</td>';
  46. echo'<td>'.$row['product_desc'].'</td>';
  47. echo'<td bgcolor=:green">'.$row['price'].'</td>';
  48. echo'<td>'.$row['image'].'</td>';
  49.  
  50.  
  51. echo'<td bgcolor=:green">'.("<a href='details.php?action=add&id=$id'>View details</a></br>").'</td>';
  52.  
  53.  
  54.  
  55.  
  56.  
  57. echo'</tr>';
  58.  
  59.  
  60. }
  61.  
  62. ?>
  63. </table>
  64. <p> <?php echo" <span>$num...</span> "?> <strong>Products... </strong></p>
  65.  
  66. </div>
  67.  
  68.  
  69.  
  70.  
  71.  
  72. form to insert...
  73. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  74. <html xmlns="http://www.w3.org/1999/xhtml">
  75. <head>
  76. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  77. <title>Untitled Document</title>
  78. </head>
  79. <h1>LOADIND OF PRODUCTS</h1>
  80.  
  81. <body>
  82.      <table>
  83.            <form enctype="multipart/form-data" method="post" action="insert_script.php"/>
  84.                  <tr>
  85.                      <td>
  86.                          <label>title</label>&nbsp;<th colspan="col"><input name="title" type="text"/></th>
  87.                          </td>
  88.                      </tr>
  89.                      <tr>
  90.                           <td>
  91.                          <label>product name</label>&nbsp;<th colspan="col"><input name="product_name" type="text"/></th>
  92.                          </td>
  93.                       </tr>
  94.                       <tr>
  95.                             <td>
  96.                          <label>roduct code</label>&nbsp;<th colspan="col"><input name="product_code" type="text"/></th>
  97.                          </td>
  98.                       </tr>
  99.                         <tr>
  100.                             <td>
  101.                          <label>description</label>&nbsp;<th colspan="col"><input name="product_desc" type="text"/></th>
  102.                          </td>
  103.                       </tr>
  104.                       <tr>
  105.                            <td>
  106.                          <label>price</label>&nbsp;<th colspan="col"><input name="price" type="int"/></th>
  107.                          </td>
  108.                       </tr>
  109.                       <tr>
  110.                            <td>
  111.                          <label>image</label>&nbsp;<th colspan="col"><input name="image" type="file" accept="image/jpeg"/></th>
  112.                          </td>
  113.                       </tr>
  114.                       <tr>
  115.                            <td>
  116.                          <th colspan="col"><input name="submit" type="submit" title="add to the database" value="LOAD"/></th>
  117.                          </td>
  118.                       </tr>
  119.  
  120.  
  121.  
  122. </body>
  123. </html>
Mar 26 '14 #1
4 1846
Dormilich
8,658 Expert Mod 8TB
that’s because images are displayed using the <img> tag.
Mar 27 '14 #2
oriola1
20
Thanks Dormilich for ur rep[ly so i do i include <img> in the select. can u plz post it for me.
i wil b so much grateful
Mar 29 '14 #3
Dormilich
8,658 Expert Mod 8TB
that’s quite simple:
Expand|Select|Wrap|Line Numbers
  1. <img width="…" height="…" alt="…" src="image.php?id=<?php echo $image_id ?>">
Mar 29 '14 #4
oriola1
20
Thanks for your reply
But the code u send didnt echo the imagge stil and again i dont understand src="image.php" is this where i stored the images bcos if u check frm my previous question i store the images inside image folder in my htdos and do my insertion through the form where i insert other datas belonging to the image
This is my insert form[/b]
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. </head>
  7. <h1>LOADIND OF PRODUCTS</h1>
  8.  
  9. <body>
  10.      <table>
  11.            <form enctype="multipart/form-data" method="post" action="insert_script.php"/>
  12.                  <tr>
  13.                      <td>
  14.                          <label>title</label>&nbsp;<th colspan="col"><input name="title" type="text"/></th>
  15.                          </td>
  16.                      </tr>
  17.                      <tr>
  18.                           <td>
  19.                          <label>product name</label>&nbsp;<th colspan="col"><input name="product_name" type="text"/></th>
  20.                          </td>
  21.                       </tr>
  22.                       <tr>
  23.                             <td>
  24.                          <label>roduct code</label>&nbsp;<th colspan="col"><input name="product_code" type="text"/></th>
  25.                          </td>
  26.                       </tr>
  27.                         <tr>
  28.                             <td>
  29.                          <label>description</label>&nbsp;<th colspan="col"><input name="product_desc" type="text"/></th>
  30.                          </td>
  31.                       </tr>
  32.                       <tr>
  33.                            <td>
  34.                          <label>price</label>&nbsp;<th colspan="col"><input name="price" type="int"/></th>
  35.                          </td>
  36.                       </tr>
  37.                       <tr>
  38.                            <td>
  39.                          <label>image</label>&nbsp;<th colspan="col"><input name="image" type="file" accept="image/jpeg"/></th>
  40.                          </td>
  41.                       </tr>
  42.                       <tr>
  43.                            <td>
  44.                          <th colspan="col"><input name="submit" type="submit" title="add to the database" value="LOAD"/></th>
  45.                          </td>
  46.                       </tr>
  47.  
  48.  
  49.  
  50. </body>
  51. </html>
If u check the image firld u wil see that it gives me browse option which make to go into the htdos to pick the particular image linl.e.g laptop.jpeg sp plz wht am i doing wrong that the image is not showing
Thanks in Anticipation
Apr 11 '14 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Wild Child | last post by:
Hi, I am trying to find ways to retrieve data by date from a mysql database. What I would like to do is to have the option for people to retrieve a file that was entered in the week before the...
0
by: samuel | last post by:
Hi, My machine was down before, fortunately I have back up the whole /usr/local/mysql directory. Now I have setup a new mysql on a new machine, how can I import the old data back to the new...
4
by: Bryan Powell | last post by:
Is it possible to grab data from a MySQL database and print it on the screen with VC++? The database is on a linux server if that would make any difference.
1
by: hansyin | last post by:
HI, I got a problem about restoring data in mysql: I have 2 or more PCs installed with mysql database, with same or almost same table structure, but with different data. Can I combine those data...
3
by: Alina Ghergu | last post by:
Hi there, I'm currently developing a GUI for a network monitor. I have to plot data taken from a MySQL database. For GUI I use wxPython, for plotting Matplotlib. The plotting has to be realtime,...
2
by: asenthil | last post by:
Hai, i'm a beginner to java... just now i had tried to read and write files using java... and then i had tried to connect a database using jdbc... now i want to export the data's from a...
6
by: msmjsuarez | last post by:
how can i display both image and other information in the web page using php? i'm using mysql database. I do displaying the image only but i want to display both other information from the database...
6
bethifUL13
by: bethifUL13 | last post by:
Hi, I am currently developing a website for our school project that is connected to the mySQL database. I am now creating a search page that will display the title of research papers stored in the...
1
by: rasha1489 | last post by:
import data from a long xml file into my mysql database using php and xslt file give me errors i have a long xml containing information that i need to import them into my mysql database. to do so...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.