PDA

View Full Version : small php question


arne
01-27-2006, 04:46 PM
Hi, it's difficult to explain but a rather easy question i think.
I have a code (see below) and i want to 'automatisize' it.
It works like this,
for every picture in the database, it should make something like this:
picArray[0] = new Array(3)
picArray[0][0] = new Image();
picArray[0][0].src = "http://www.kempischbouwcenter.be/fotos/4.jpg";
picArray[0][1] = stdWidth;
picArray[0][2] = (stdWidth * 392)/522;

if (picArray[0][2]>stdHeight){
picArray[0][1] = (stdHeight*stdWidth)/picArray[0][2];
picArray[0][2] = stdHeight;

the problem is that i know i should use a while loop, and then i can make it, except for ONE small thing !!! The picArray[0], should become [1] witht he next photo, [2] after that, 3,4,5,...

LIke in the example below:


<!--
var picArray = new Array(1);
var stdHeight=375;
var stdWidth=525;

picArray[0] = new Array(3)
picArray[0][0] = new Image();
picArray[0][0].src = "http://www.kempischbouwcenter.be/fotos/4.jpg";
picArray[0][1] = stdWidth;
picArray[0][2] = (stdWidth * 392)/522;

if (picArray[0][2]>stdHeight){
picArray[0][1] = (stdHeight*stdWidth)/picArray[0][2];
picArray[0][2] = stdHeight;
}else{

}
}else{

}

picArray[1] = new Array(3)
picArray[1][0] = new Image();
picArray[1][0].src = "http://www.kempischbouwcenter.be/fotos/12b.jpg";
picArray[1][1] = stdWidth;
picArray[1][2] = (stdWidth * 392)/522;

if (picArray[1][2]>stdHeight){
picArray[1][1] = (stdHeight*stdWidth)/picArray[1][2];
picArray[1][2] = stdHeight;
}else{

}

picArray[2] = new Array(3)
picArray[2][0] = new Image();
picArray[2][0].src = "http://www.kempischbouwcenter.be/fotos/12c.jpg";
picArray[2][1] = stdWidth;
picArray[2][2] = (stdWidth * 392)/522;

if (picArray[2][2]>stdHeight){
picArray[2][1] = (stdHeight*stdWidth)/picArray[2][2];
picArray[2][2] = stdHeight;
}else{

}
AND SO ON
totalPic = 1;
// firstLim = 0;
// secondLim = -1;
I don't think it's that difficult, just a small number that should auto-change from zero till all the pics have been 'while-looped'.
THANK YOU VERY MUCH

arne
01-27-2006, 05:27 PM
I would appreciate some quick help !

Rich Pedley
01-27-2006, 07:16 PM
$i=0;

while ...{
picArray[$i]
etc...
$i++;
}


is that what you mean?

arne
01-28-2006, 09:20 AM
yes i already thought about something with an imaginary number but i wasn't sure. THANX, i'll try it later today :thumbsup:

Velox Letum
01-28-2006, 06:22 PM
I believe this is javascript, not PHP. Asking in the JS forum will get much more, and indeed better responses.