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
- <?php
- require_once("db_connect.php");
- $db=mysqli_connect("$host","$user","$password","$db");
- $sel="SELECT * FROM products ";
- $result=mysqli_query($db,$sel);
- $num=mysqli_num_rows($result);
- if(!@result)
- {
- die('<p>Error Retrieving</br>');
- }
- ?>
- <h1>List of our products</h1>
- <table border="5" width="1000">
- <tr bgcolor="#FF00FF">
- <th bgcolor="#FF0000">TITLE</th>
- <th>PRODUCT CODE</th>
- <th bgcolor="#FF0000">PRODUCT NAME</th>
- <th>DESCRIPTION</th>
- <th bgcolor="#FF0000">PRICE</th>
- <th>IMAGE</th>
- <th bgcolor="#FF0000">DETAILS</th>
- </tr>
- <?php
- while($row=mysqli_fetch_array($result)) {
- extract($row);
- echo'<tr bgcolor="yellow">';
- echo'<td bgcolor=:green">'.$row['title'].'</td>';
- echo'<td>'.$row['product_code'].'</td>';
- echo'<td bgcolor=:green">'.$row['product_name'].'</td>';
- echo'<td>'.$row['product_desc'].'</td>';
- echo'<td bgcolor=:green">'.$row['price'].'</td>';
- echo'<td>'.$row['image'].'</td>';
- echo'<td bgcolor=:green">'.("<a href='details.php?action=add&id=$id'>View details</a></br>").'</td>';
- echo'</tr>';
- }
- ?>
- </table>
- <p> <?php echo" <span>$num...</span> "?> <strong>Products... </strong></p>
- </div>
- form to insert...
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Untitled Document</title>
- </head>
- <h1>LOADIND OF PRODUCTS</h1>
- <body>
- <table>
- <form enctype="multipart/form-data" method="post" action="insert_script.php"/>
- <tr>
- <td>
- <label>title</label> <th colspan="col"><input name="title" type="text"/></th>
- </td>
- </tr>
- <tr>
- <td>
- <label>product name</label> <th colspan="col"><input name="product_name" type="text"/></th>
- </td>
- </tr>
- <tr>
- <td>
- <label>roduct code</label> <th colspan="col"><input name="product_code" type="text"/></th>
- </td>
- </tr>
- <tr>
- <td>
- <label>description</label> <th colspan="col"><input name="product_desc" type="text"/></th>
- </td>
- </tr>
- <tr>
- <td>
- <label>price</label> <th colspan="col"><input name="price" type="int"/></th>
- </td>
- </tr>
- <tr>
- <td>
- <label>image</label> <th colspan="col"><input name="image" type="file" accept="image/jpeg"/></th>
- </td>
- </tr>
- <tr>
- <td>
- <th colspan="col"><input name="submit" type="submit" title="add to the database" value="LOAD"/></th>
- </td>
- </tr>
- </body>
- </html>