Jump to content

Archived

This topic is now archived and is closed to further replies.

martyng

Syntax help

Recommended Posts

I read a recordset into an array and one part is shown below. I need to replace the numeral 1 with the variable picture, which i tried to do by just replacing 1 with $picture but can't get it work, any ideas

"link"=>"<A HREF=\"profile.php?id=$row[id]\"><IMG SRC=\"pictures/$row[gallery1]\" WIDTH=\"132\" HEIGHT=\"175\" BORDER=\"0\"></A>",

Share this post


Link to post
Share on other sites
I don't see any 1s but try this

"link"=>"<A HREF=\"profile.php?id=".$row['id']."\"><IMG SRC=\"pictures/".$row['gallery1']."\" WIDTH=\"132\" HEIGHT=\"175\" BORDER=\"0\"></A>",

Share this post


Link to post
Share on other sites
Sorry, unclear, i Need to replace the 1 in gallery1 with the variable $picture ie. like $row[gallery$picture] but this doesn't work

Share this post


Link to post
Share on other sites
try [code]"<A HREF=\"profile.php?id=$row[id]\"><IMG SRC=\"pictures/".$row['gallery'.$picture]."\" WIDTH=\"132\" HEIGHT=\"175\" BORDER=\"0\"></A>";[/code]

Share this post


Link to post
Share on other sites
[code]

$row['gallery1']=$picture;

"link"=>"<A HREF=\"profile.php?id=".$row['id']."\"><IMG SRC=\"pictures/".$row['gallery1']."\"

WIDTH=\"132\" HEIGHT=\"175\" BORDER=\"0\"></A>",

[/code]

Share this post


Link to post
Share on other sites
Still no luck, gallery1 refers to a row in a table. I also have a row called gallery2 and to create a random galery I have the random variable $picture with a value of either 1 or 2. The code works fine with a fixed [gallery1] or [gallery2] but not by trying to replace the 1 with $picture.


KrisNz's post looks closest to what i'm trying to do but still doesn't work giving the following
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in

Any ideas guys

Share this post


Link to post
Share on other sites
[code]
"<a href=\"profile.php?id={$row['id']}\"><img src=\"pictures/{$row['gallery$picture']}\" width=\"132\" height=\"175\" border=\"0\"></a>";
[/code]

Share this post


Link to post
Share on other sites
Nearly there, this doesn't produce an error but doesn't add the information contained in gallery$picture looking at the source code the image is just pictures/ with nothing tagged on

Any ideas



[!--quoteo(post=380530:date=Jun 6 2006, 03:57 AM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Jun 6 2006, 03:57 AM) [snapback]380530[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[code]
"<a href=\"profile.php?id={$row['id']}\"><img src=\"pictures/{$row['gallery$picture']}\" width=\"132\" height=\"175\" border=\"0\"></a>";
[/code]
[/quote]

Share this post


Link to post
Share on other sites
Still couldn't figure it out, but got around it by checking value of $picture and using two different statements with a fixed gallery1 or gallery2

I'd still love to know how to do it properly tho as my way is messy and only good as I only have two variable choices 1 or 2

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.