I created a variable from a MySQL query that gives a total number value of photos available for a record. This along with a few other variables from the query I can use to construct a dynamic URL in a CSV file I am exporting.
This works great:
foreach($rowr as $name => $value)
{
if($name=='MatrixImage') {$jpg_name=$value;}
if($name=='PhotoCount') {$count_name=$value;}
if($name != 'estate_property_gallery')
$csv_output .= $value."|";
if($name == 'estate_property_gallery')
{
$csv_output .= "http://url/feeds/".$value."/rets_images/".$jpg_name."_".$count_name.".jpg";
}
}
I need to be able to loop through and create multiple URLs using this PhotoCount variable starting from 1 to the final value found in PhotoCount seperated by a comma but I can't seem to get it right.
Not working:
foreach($rowr as $name => $value)
{
if($name=='MatrixImage') {$jpg_name=$value;}
if($name=='PhotoCount') {$count_name=$value;}
if($name != 'estate_property_gallery')
$csv_output .= $value."|";
if($name == 'estate_property_gallery')
{
//$csv_output .= "http://url/feeds/".$value."/rets_images/".$jpg_name."_".$count_name.".jpg";
for( $pic_start=1; $pic_start<=$count_name; $pic_start++ ){
echo '$csv_output .= "http://url/feeds/' . $value . '/rets_images/' . $jpg_name . '_' . $pic_start . '.jpg,"';
}
}
}
The example above outputs the entire line including the $csv_output to the screen instead of putting each URL into the column of the CSV and delimiting with a comma.
To clarify: I need to be able to write this echo into the $csv_output .= portion of the code successfully so I can write multiple URLs separated by a comma within that column in my csv output:
echo 'http://www.myagentsbuddy.com/feeds/' . $value . '/rets_images/' . $jpg_name . '_' . $count_name . '.jpg';