Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Data Integration / May 2008



Tip: Looking for answers? Try searching our database.

images in database

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
fsl2227 - 09 May 2008 14:04 GMT
Is there a tutorial somewhere that tells/shows how to display an image from a
db.  I have my image paths in a mysql db and I am using php to display my other
text fields.  I just haven't been able to get my images to show. Below is the
code that I am using so far.  Here is my actual goal, I am trying to have a
flash document the has a list in the datagrid that is connected to a mysql db.
I have successfully done this. When a user clicks on a product in the datagrid
it populates the details below the grid and I have done so successfully. What I
now need is to show a picture of the product in the details section. I would
also like to see how to show different images for different vendors, each
vendor has its own image size, so if I put just one image placeholder then some
of the images will be scewed. I need something that shows image in placeholder
1 if company=1, show image in placeholder 2 if company=2, etc.

/*This defines the location of the files we are going
to use in this program. */
_global.mypath = "http://www.producttestsite.com/flash/"
//This defines the datagrid columns
import mx.controls.DataGrid;
import mx.controls.gridclasses.DataGridColumn;
var column = new DataGridColumn("j1");
column.headerText = "Product Name";
column.width = 200;
tf.align = "center";
products.addColumn(column);
var column = new DataGridColumn("j2");
column.headerText = "Price";
column.width = 60;
products.addColumn(column);
var column = new DataGridColumn("j3");
column.headerText = "Color";
column.width = 75;
products.addColumn(column);
var column = new DataGridColumn("j4");
column.headerText = "Interior Color";
column.width = 150;
products.addColumn(column);
products.addEventListener("headerRelease", headerListener);
products.dataProvider = r_string;
products.scrollToTop();
products.dataProvider = r_string;
//set Column text property
//var tf = new TextFormat ();
//tf.italic = False;
//tf.bold = False;
//tf.align
// This reads the data from the PHP script and populates the datagrid.
var sendData = new LoadVars();
var r_string = new LoadVars();
r_string.onLoad = getResponse;
sendData.addr = propDgrid.selectedItem.j2
job_id_num=custDgrid.selectedItem.cust_id;
mypath89 =_global.mypath + "products.php";
sendData.sendAndLoad(mypath89, r_string, "post");
function getResponse(result){
if (result == true) {
var r_string = new Array();
for (var i:Number=0; i < this.n; i++) {
r_string.push(
{ productid:this["productid"+i],
j1:this["model"+i],
j2:this["price"+i],
j3:this["color"+i],
j4:this["interiordesc"+i]
})};
}
products.dataProvider = r_string;
}
//Populate the form
//==============Show Customer Details=========================
custf=function(){
var sendData = new LoadVars();
var recData = new LoadVars();
recData.onLoad = getResponse1;
sendData.productid = products.selectedItem.productid;
mypath81 =_global.mypath + "productform.php";
sendData.sendAndLoad(mypath81, recData, "post");
}
function getResponse1(result){
if (result == true) {
model.text = this['model'];
price.text = this['price'];
material.text = this['material'];
interiordesc.text = this['interiordesc'];
this.ref['holder_mc'+i].loadMovie(this['picture'+i])
picture.text = this['picture'];
feature1.text = this['feature1'];
feature2.text = this['feature2'];
feature3.text = this['feature3'];
feature4.text = this['feature4'];
}
}
products.addEventListener("cellPress",custf);
/*I have not shown all fields in the database on the form but if you wanted to
show more of the fields you would just add then to the list above.*/
Andrew_Bower - 12 May 2008 17:11 GMT
This is how we got it to work. I am no PHP expert, but this does pull the
variable and place the image.

                    <?php $isImage = $row_Recordset1['Image'];
            if ($isImage != 0) { // Show if recordset not empty ?>
                  </span></p>
               
                  <table width="120" height="120" align="left" >
              <tr>
                <td width="10" height="21"></td>
                <td width="98"><span class="header"><img src="images/<?php
echo $row_Recordset1['Image']; ?>"></span></td>
              </tr>
            </table>
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.