RE: Images

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



John,

the code is listed below. Very cluttered, I acknoweledge:)
The limit you'll see in the second query is the maximal value for which I
get a good checkerboard.

Mihai
--------------------
$q1=mysql_query("select distinct idsend from connections where publi=1 and
uid=1 order by idsend");
$nu1=mysql_num_rows($q1);
for ($i=0; $i<$nu1; $i++) {
$qmax=mysql_fetch_row($q1);
$send[$i]=$qmax[0];
}
$q2=mysql_query("select distinct idrec from connections where publi=1 and
uid=1 order by idrec limit 127");
$nu2=mysql_num_rows($q2);
for ($i=0; $i<$nu2; $i++) {
$qmax2=mysql_fetch_row($q2);
$rec[$i]=$qmax2[0];
}
$image=imageCreate(5000,5000);

for ($i=0; $i<$nu1; $i++) {
for ($j=0; $j<$nu2; $j++) {

$qcheck=mysql_query("select count(*) from connections where
idsend=$send[$i] and idrec=$rec[$j] and publi=1 and uid=1") or
die(mysql_error());
$rcheck=mysql_fetch_row($qcheck);
$check=0+$rcheck[0];
if ($check>0) {
$rmax=mysql_query("select min(strength) from connections where
idsend=$send[$i] and idrec=$rec[$j] and publi=1 and uid=1")  or
die(mysql_error());
$qmax3=mysql_fetch_row($rmax);
$qq=$qmax3[0];
if ($qq==1) {
$a=0;
$b=0;
$c=0;
}
elseif ($qq==2) {
$a=255;
$b=50;
$c=50;
}
elseif ($qq==3) {
$a=200;
$b=100;
$c=100;
}
elseif ($qq==4) {
$a=0;
$b=0;
$c=255;
}
elseif ($qq==5) {
$a=0;
$b=255;
$c=255;
}
elseif ($qq==6) {
$a=0;
$b=255;
$c=200;
}
elseif ($qq==7) {
$a=0;
$b=100;
$c=255;
}

elseif ($qq==8) {
$a=0;
$b=100;
$c=255;
}
elseif ($qq==9) {
$a=255;
$b=0;
$c=0;
}
elseif ($qq==12) {
$a=0;
$b=0;
$c=255;
}
 elseif ($qq==0){
$a=200;
$b=200;
$c=200;
}
}
elseif ($check==0) {
$a=0;
$b=0;
$c=0;
}

$cul=imageColorAllocate($image, $a, $b, $c);;
imagerectangle($image, 7*$j,7*$i,7*$j+7,7*$i+7,$cul);
}
}

Header("Content-type: image/png");
imagePNG($image);
imageDestroy($image);

On Sat, 1 Feb 2003, John W. Holmes wrote:

> > I try to create a simple image from some data from a database
> (something
> > like a checkerboard: if $a=1 then red, elseif $a=2 then blue etc).
> > Everthing works fine until the assignment of colors. Whenever I use
> the
> > whole set of data that I have to display, wrong colors are assigned.
> > Whenever I use small subsets of the whole set, then I have the correct
> > display.  I only change the value of the limit from the query and the
> > whole pattern might change drastically.
>
> Show your code...
>
> ---John W. Holmes...
>
> PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> today. http://www.phparch.com/
>
>
>
>
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux