i am having a problem writing a simple loop.
the code i have is:
<?
$news_array = getimages($clientid,$projectid);
$result=count($news_array);
?>
<?
foreach ($news_array as $item){
$image=$item[image];
$number = $result;
$x = 0;
if ($x < $number) {
$namenumber = $x + 1;
echo "image$namenumber=../images/clients/projects/$image&";
}
++$x;
}
?>
the problem is that it if there are 2 records it write both records, twice. as in:
image1=../images/clients/projects/img1.jpg&image1=../images/clients/projects/img2.jpg&image2=../images/clients/projects/img1.jpg&image2=../images/clients/projects/img2.jpg&
obviously i only want it to write:
image1=../images/clients/projects/img1.jpg&image2=../images/clients/projects/img2.jpg&
any ideas?
thanks,
james