I am a newbie to PHP for sure. I need some advice though. I am attempting to tweak an existing PHP script I have.
The is an array called $row that has all the value that was pulled from a database.
I want to take the values $row [ 'propertyphoto1' ] , $row [ 'propertyphoto2' ], $row [ 'propertyphoto3' ] and so forth up to propertyphoto 8 and put them in a different array in which I will use that array to mesh with a image rotator.
Here is the code I am working with:
?php if ( ! $row [ 'propertyphoto1' ] )
{
?><img src="<?php echo $ImageURL; ?>nopropertyimage.jpg" border="0" align="left" hspace="10" height="150" width="200"><?php
}
else
{
?><?
$pic = array("echo $row ['propertyphoto2']", "echo $row ['propertyphoto3']", "echo $row ['propertyphoto1']" );
?>
<? echo $pic[2]; ?>
I have the above echo $pic[2]; just to see if I am actually storing the array correctly ie., the propertyphoto values.
But all it does it print out
echo Array ['propertyphoto1']
instead the actual value of the propertyphoto1 which is something like imagename.jpg.
Can anyone point me to the right direction as to what I am doing wrong??
Thanks for your help
Chris
PHP Array Help Please
Moderator: General Moderators
Re: PHP Array Help Please
Look at this line:
You have error in syntax "echo $row ['propertyphoto1']" (needless space). You should use something like this:
Code: Select all
$pic = array("echo $row ['propertyphoto2']", "echo $row ['propertyphoto3']", "echo $row ['propertyphoto1']" );Code: Select all
"echo {$row['propertyphoto1']}"
//or
"echo ".$row['propertyphoto1']
//or
'echo '.$row['propertyphoto1']
// Read manual