pontus
Posts: 5
|
Posted: 02/29/2004, 9:22 AM |
|
Hi,
I create an image using PHP within Codecharge. This is done in the before show event of a table. The image is saved on the server. In the table there is a image whit src = to the newly created image.
For various reasons I would like not to save the image on the server.
The image is created using the code below and my problem is how to direct this image to the src of the image in the table.
Ive tried things like src=$im, src=Imagepng($im)....
Any help is apreciated..
Pontus
global $Image1;
$db = new clsDBConnection1();
$Width = 300;
$Height = 300;
$im = ImageCreate($Width, $Height);
$background = ImageColorAllocate ($im, 126, 164, 205);
$red = ImageColorAllocate ($im, 0, 255, 0);
$blue = ImageColorAllocate ($im, 0,51,102);
$black = ImageColorAllocate ($im, 0,0,0);
imageColorTransparent($im, $background);
$productsquery = "SELECT COUNT(*) FROM products";
$numproducts = CCGetDBValue(CCBuildSQL($productsquery, "product_name <> 'Kommentar'", ""), $db);
$xval = 5;
$barwidth = floor(200/$numproducts);
$product_name_sql ="SELECT product_name, product_id FROM products";
$db->query(CCBuildSQL($product_name_sql, "product_name <> 'Kommentar'", ""));
for ($i=0;$i<=($numproducts-1);$i++)
{
$dbvalue = $db->next_record() ? $db->f(0) : "";
$productlist[$i]= $dbvalue;
}
for ($i=0;$i<=($numproducts-1);$i++)
{
$product_name= $productlist[$i];
$currentnum_sql = "SELECT SUM(number_of) FROM sales";
$currentnum= CCGetDBValue(CCBuildSQL($currentnum_sql, "product_name='$product_name' AND product_price_actual > 0", ""), $db);
$currentnum_scaled= $currentnum*0.25;
imagefilledrectangle ($im, $xval, (150-$currentnum_scaled), ($xval+$barwidth), 150, $blue);
imagerectangle ($im, $xval, (150-$currentnum_scaled), ($xval+$barwidth), 150, $black);
imagestring ($im, 2, ($xval), 155, $product_name, $black);
imagestring ($im, 2, ($xval), ((150-$currentnum_scaled)-15), $currentnum, $black);
$xval+=($barwidth+10);
}
ImagePNG($im,"Images/salesgraph.png");
imagedestroy($im);
|
|
|
peterr
Posts: 5971
|
Posted: 02/29/2004, 10:41 PM |
|
I'm not sure what is the question. If for various reasons you would like not to save the image on the server, then where should it be saved?
If the images are stored in the database and you want to display them dynamically, see: http://forums.devarticles.com/showthread.php?t=435
Basically you will need a separate PHP program that displays an image, then use it as your <img src...>
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
|