Re: Javascript and php

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

 



Reinhart,


<?php for($i = 0; $i < mysql_num_rows($result)-1; $i++) { $row = mysql_fetch_object($result); echo '"'.$row->picture_url.'"'; if($i <= mysql_num_rows($result)-2) { echo ','; } } ?>

Here is how I do in my developments.

Regards,
Bruno B B Magalhães

On Nov 7, 2004, at 8:44 AM, Reinhart Viane wrote:

Hey all,
Hope some of you also work on sundays :)

I have a little javascript which displays a images (with previous / next
thing)
Now, i populate the javascript array with an php array:


<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
NewImg = new Array (
<?php
while($row = mysql_fetch_object($result)){
echo "\"".$row->picture_url."\",";
}
?>
"../pictures/7_stripper3.jpg",
"../pictures/7_stripper2.jpg"
);
var ImgNum = 0;
var ImgLength = NewImg.length - 1;
...
</script>

As you can see i echo the url of the picture.
After each picture url there needs to be a ','
But not after the last picture.
At this moment all pictures have the ',' after there url, even the last
one.
Any way to determine if the url is the url of the last picture and thus
not printing a ',' behind that last one?

Thx in advance,

Reinhart

  _____

Reinhart Viane
<mailto:rv@xxxxxxxx> rv@xxxxxxxx
Domos || D-Studio
Graaf Van Egmontstraat 15/3 -- B 2800 Mechelen -- tel +32 15 44 89 01 --
fax +32 15 43 25 26



STRICTLY PERSONAL AND CONFIDENTIAL
This message may contain confidential and proprietary material for the
sole use of the intended
recipient. Any review or distribution by others is strictly prohibited.
If you are not the intended
recipient please contact the sender and delete all copies.




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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux