PC Help Forum - Free Computer Help, Windows, Hardware, Software and more!
 
Become a Member Today!
Search PC Help Forum for Answers
 
Go Back   PC Help Forum - Free Computer Help, Windows, Hardware, Software and more! > Computing (General) > Programming
Programming - PHP coding Help posted in the Computing (General) forums; I am doing an ecommerce project... can someone tell me how to store images in a database and retrieve same.. and how to retrive data from database about the product ...

REGISTER NOW to remove these Ads

Reply
 
LinkBack Thread Tools Display Modes Language
  #1  
Old 3 Weeks Ago
Joinx's Avatar
Bronze Member
 
Posts: 22
PC Experience: PC Illiterate
Joinx - See this Members User comments on their Profile page
Default PHP coding Help

I am doing an ecommerce project...
can someone tell me how to store images in a database and retrieve same..
and how to retrive data from database about the product ans include a button with it?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #2  
Old 3 Weeks Ago
Cowburn199's Avatar
Moderator
My PC
 
Posts: 1,382
PC Experience: I know a fair amount, always learning
Location: England - Lancashire
Cowburn199 - See this Members User comments on their Profile page Cowburn199 - See this Members User comments on their Profile page Cowburn199 - See this Members User comments on their Profile page Cowburn199 - See this Members User comments on their Profile page Cowburn199 - See this Members User comments on their Profile page Cowburn199 - See this Members User comments on their Profile page
Send a message via MSN to Cowburn199
Default Re: PHP coding Help

PHP Freaks Forums - Index is a good website that should help you do what you want. My mate suggested that.

__________________
Blue Screens of Death's - PCHF Rules -Prework
If someone helped you, please consider clicking rate post

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #3  
Old 3 Weeks Ago
Axephilic's Avatar
Proud PCHF Moderator
My PC
 
Posts: 931
PC Experience: Experienced
Location: Wisconsin, US
Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page
Send a message via AIM to Axephilic Send a message via MSN to Axephilic
Default Re: PHP coding Help

With E-Commerce sites, you might want to try some software. osCommerce, Open Source Online Shop E-Commerce Solutions It is free and good. If you need help adding your own touches to it, please let me know as I do code a bit of PHP.

Regards,
Adam

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #4  
Old 3 Weeks Ago
Joinx's Avatar
Bronze Member
 
Posts: 22
PC Experience: PC Illiterate
Joinx - See this Members User comments on their Profile page
Default Re: PHP coding Help

Thnx for your reply...I have tried the free shopping cart software but the problem is that if i choose that option sure i'll fail my project..so i'm trying forums, books and my own knowledge to build my website..I am succeding just getting stuck some place...
So adam if u can help me with some code..i'll be thankful...
rite now i want to display images in php...i stored the url in the database..
i tried this code it worked only once...
1.i retrieve the url from database and placed in a variable thn i used this variable
$imageurl=$row['product_image']
print '<img src=".$imageurl."/>;'

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #5  
Old 3 Weeks Ago
Axephilic's Avatar
Proud PCHF Moderator
My PC
 
Posts: 931
PC Experience: Experienced
Location: Wisconsin, US
Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page
Send a message via AIM to Axephilic Send a message via MSN to Axephilic
Default Re: PHP coding Help

It's been a while since I've done PHP but, try using echo instead. Something like this:

PHP Code:
 $imageurl = $row['product_image'] ?>
<img src="<?php echo $imageurl?>" />
Regards,
Adam

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #6  
Old 3 Weeks Ago
Joinx's Avatar
Bronze Member
 
Posts: 22
PC Experience: PC Illiterate
Joinx - See this Members User comments on their Profile page
Default Re: PHP coding Help

Oops still not coming.
now instead of an X its coming like a small icon and when i click on it it shows show picture but nothing id happening..i'm really stuck..

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #7  
Old 3 Weeks Ago
Axephilic's Avatar
Proud PCHF Moderator
My PC
 
Posts: 931
PC Experience: Experienced
Location: Wisconsin, US
Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page
Send a message via AIM to Axephilic Send a message via MSN to Axephilic
Default Re: PHP coding Help

Could you post your full source code please (take out passwords and usernames for database connections though).

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #8  
Old 3 Weeks Ago
Joinx's Avatar
Bronze Member
 
Posts: 22
PC Experience: PC Illiterate
Joinx - See this Members User comments on their Profile page
Default Re: PHP coding Help

$colname_brand = "-1";
if (isset($_GET['category_id'])) {
$colname_brand = $_GET['category_id'];
}
mysql_select_db($database_JaceyConn, $JaceyConn);
$query_brand = sprintf("SELECT product_id, product_name, product_price, product_image FROM product WHERE category_id = %s", GetSQLValueString($colname_brand, "int"));
$brand = mysql_query($query_brand, $JaceyConn) or die(mysql_error());
$row_brand = mysql_fetch_assoc($brand);
$totalRows_brand = mysql_num_rows($brand);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<meta name="description" content="description"/>
<meta name="keywords" content="keywords"/>
<meta name="author" content="author"/>
<link rel="stylesheet" type="text/css" href="bntemplate590/images590/default.css"/>
<title>Jacey</title>
<style type="text/css">
<!--
body,td,th {
font-size: 9pt;
}
-->
/* Tabs Menu */

#tabsE {
float:left;
width:100%;
font-size:70%;
line-height:normal;
}
#tabsE ul {
margin:0;
padding:10px 10px 0 50px;
list-style:none;
}
#tabsE li {
display:inline;
margin:0;
padding:0;
}
#tabsE a {
float:left;
background:url(../Tab/tableftE.gif) no-repeat left top;
margin:0;
padding:0 0 0 4px;
text-decoration:none;
}
#tabsE a span {
float:left;
display:block;
padding:5px 15px 4px 6px;
color:#FFF;
background-image: url(../Tab/tabrightE.gif);
background-repeat: no-repeat;
background-position: right top;
}
/* Commented Backslash Hack hides rule from IE5-Mac \*/
#tabsE a span {float:none;}
/* End IE5-Mac hack */
#tabsE a:hover span {
color:#FFF;
}
#tabsE a:hover {
background-position:0% -42px;
}
#tabsE a:hover span {
background-position:100% -42px;
}
.style5 {color: #FF0000}
</style>
</head>

<body>
<div class="main">
<div class="main_left">

<div class="header">
<h1 align="center">Jacey Computers</h1>
</div>
<div class="link_menu">
<a href="main.php" accesskey="1">Home</a>
<a href="category.php" accesskey="2">Product</a>
<a href="support.php" accesskey="3">Support & Help</a>
<a href="contact.php" accesskey="4">Contact Us</a> </div>
<div class="content">


<p>&nbsp;</p>
<table align="center" border="2">
<?php

while($row = mysql_fetch_array($brand)) {?>
<?php $imageurl = $row['product_image'] ?>

<tr>
<td width="307">
<p><img src="<?php echo $imageurl; ?>" />
<?php echo $row['product_name']."<br><font color=red>Price/font>Rs".$row['product_price'];?></p>
<form id="form1" method="details.php" action="POST">
<input name="product_id" type="hidden" value="%s"/>
<a href="details.php">More Info</a>
</form>
<form name="form" action="showcart.php" method="POST">
<input name="product_id" type="hidden" value="%s"/>
<input type="submit" value="Add To cart">
<input type="hidden" name="MM_insert" value="form" />
</form>
</form></td>
</tr>
<?php } ?>
</table>

</div>

</div>
<div class="footer">
<div align="center">&copy; www.jacey.mu </div>
</div>
</div>
<br style="clear: both;" />
</body>
</html>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #9  
Old 3 Weeks Ago
Axephilic's Avatar
Proud PCHF Moderator
My PC
 
Posts: 931
PC Experience: Experienced
Location: Wisconsin, US
Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page Axephilic - See this Members User comments on their Profile page
Send a message via AIM to Axephilic Send a message via MSN to Axephilic
Default Re: PHP coding Help

Give this a shot:

PHP Code:
$colname_brand = "-1";
if (isset($_GET['category_id'])) {
  $colname_brand = $_GET['category_id'];
}
mysql_select_db($database_JaceyConn, $JaceyConn);
$query_brand = sprintf("SELECT product_id, product_name, product_price, product_image FROM product WHERE category_id = %s", GetSQLValueString($colname_brand, "int"));
$brand = mysql_query($query_brand, $JaceyConn) or die(mysql_error());
$row_brand = mysql_fetch_assoc($brand);
$totalRows_brand = mysql_num_rows($brand);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<meta name="description" content="description"/>
<meta name="keywords" content="keywords"/> 
<meta name="author" content="author"/> 
<link rel="stylesheet" type="text/css" href="bntemplate590/images590/default.css"/>
<title>Jacey</title>
<style type="text/css">
<!--
body,td,th {
 font-size: 9pt;
}
-->
/* Tabs Menu */
 
    #tabsE {
      float:left;
      width:100%;
      font-size:70%;
      line-height:normal;
      }
    #tabsE ul {
 margin:0;
 padding:10px 10px 0 50px;
 list-style:none;
      }
    #tabsE li {
      display:inline;
      margin:0;
      padding:0;
      }
    #tabsE a {
      float:left;
      background:url(../Tab/tableftE.gif) no-repeat left top;
      margin:0;
      padding:0 0 0 4px;
      text-decoration:none;
      }
    #tabsE a span {
 float:left;
 display:block;
 padding:5px 15px 4px 6px;
 color:#FFF;
 background-image: url(../Tab/tabrightE.gif);
 background-repeat: no-repeat;
 background-position: right top;
      }
    /* Commented Backslash Hack hides rule from IE5-Mac \*/
    #tabsE a span {float:none;}
    /* End IE5-Mac hack */
    #tabsE a:hover span {
      color:#FFF;
      }
    #tabsE a:hover {
      background-position:0% -42px;
      }
    #tabsE a:hover span {
      background-position:100% -42px;
      }  
.style5 {color: #FF0000}
</style>
</head>

<body>
<div class="main">
 <div class="main_left">
  
<div class="header">
   <h1 align="center">Jacey Computers</h1>
   </div>
  <div class="link_menu">
   <a href="main.php" accesskey="1">Home</a>
   <a href="category.php" accesskey="2">Product</a>
   <a href="support.php" accesskey="3">Support & Help</a>
   <a href="contact.php" accesskey="4">Contact Us</a>  </div>
  <div class="content">
       
      
   <p>&nbsp;</p>
   <table align="center" border="2">
         <?php 

 
while($row mysql_fetch_array($brand)) {
 
$imageurl $row['product_image'
?>
 
<tr>
<td width="307">
<p><img src="<?php echo $imageurl?>" />
    <?php echo $row['product_name']."<br><font color=red>Price</font>Rs".$row['product_price'];?></p>
<form id="form1" method="details.php" action="POST">
<input name="product_id" type="hidden" value="%s"/>
  <a href="details.php">More Info</a>
</form>
<form name="form" action="showcart.php" method="POST">
<input name="product_id" type="hidden" value="%s"/>
<input type="submit" value="Add To cart">
<input type="hidden" name="MM_insert" value="form" />
</form>
</form></td>
</tr>
 <?php ?>
   </table>
    
         </div>
 
</div>
<div class="footer">
  <div align="center">&copy; www.jacey.mu </div>
</div>
</div>
 <br style="clear: both;" />
</body>
</html>
If this doesn't work then I am stumped and you should probably ask at phpfreaks. They will know a little better then me.

Thanks,
Adam

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #10  
Old 2 Weeks Ago
Joinx's Avatar
Bronze Member
 
Posts: 22
PC Experience: PC Illiterate
Joinx - See this Members User comments on their Profile page
Default Re: PHP coding Help

Still not working..
But now i think i knw how to do it...
i have to trim the url before inserting it to the img tag..so now trying to know how to do that..
thnxk a lot..

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply


Go Back   PC Help Forum - Free Computer Help, Windows, Hardware, Software and more! > Computing (General) > Programming




Thread Tools