This topic is locked

show picture in orderdetails list and edit (using MySQL)

3/16/2007 12:29:40 PM
PHPRunner General questions
D
dlpirl author

My orderdetails table uses the product code to reference the product. I also want to show a picture of the product. I know how to create a view that will do this, but I have learned that a limitation of mySQL is that the underlying table(s) is(are) not edited when I edit the view. How can I display a picture of the product in list, edit, view, and add screens of my orderdetails table?

J
Jane 3/19/2007

Donald,
to display product image on the Edit page use EditOnLoad event on the Events tab. Here is a sample:

global $where,$conn,$strTableName;

$str = "select ProductID from ".$strTableName." where ".$where;

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);

echo "<img src=\"Products_imager.php?field=ProductImage&key1=".$data["ProductID"]."\" border=0>";



where ProductID, ProductImage are your actual field names, Products is your actual table name.
To display product image on the List/View pages create custom view on the Datasource tables tab, join image field on the Edit SQL query tab and check off this field on the List and View pages only on the Choose fields tab.

D
dlpirl author 3/20/2007

Donald,

to display product image on the Edit page use EditOnLoad event on the Events tab. Here is a sample:

...


Thanks, Jane. I am not sure what I did wrong, but it didn't work. (I get a broken image icon.)
Here is my code for EditOnLoad...

function EditOnLoad()

{

global $where,$conn,$strTableName;

// Parameters:

// $where - string with WHERE clause pointing to record to be edited

//** Custom code ****

// put your custom code here

$str = "select PrdCode from ".$strTableName." where ".$where;

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);

echo "<img src=\"sunnycloprod_imager.php?field=Photo&key1=".$data["PrdCode"]."\" border=0>";

}

J
Jane 3/21/2007

It's difficult to tell you what's happening without seeing actual data.

Try to display $data["PrdCode"] on the page before the image:

$data = db_fetch_array($rs);

echo $data["PrdCode"];


If it doesn't help publish your application on Demo Account and post a URL to your pages here or send it to [email=support@xlinesoft.com]support@xlinesoft.com[/email].

D
dlpirl author 3/21/2007

It's difficult to tell you what's happening without seeing actual data.

Try to display $data["PrdCode"] on the page before the image:
If it doesn't help publish your application on Demo Account and post a URL to your pages here or send it to [email=support@xlinesoft.com]support@xlinesoft.com[/email].



Yes, Jane. Adding your suggested code, the correct Product Code (PrdCode) is displayed before the broken image icon.
I will try publishing to Demo Account and then post the URL here as you suggest.

D
dlpirl author 3/26/2007



Yes, Jane. Adding your suggested code, the correct Product Code (PrdCode) is displayed before the broken image icon.
I will try publishing to Demo Account and then post the URL here as you suggest.



Jane, I published the project to the demo account. The url to view the broken image URL is http://demo.asprunner.net/dlpirl_earthlink...S&editid4=0. I am sending login ID and pwd to support@xlinesoft.com.

J
Jane 3/27/2007

answered in your personal email.