Forum Moderators: coopster

Message Too Old, No Replies

dynamically creating links with php

         

bleak26

7:22 pm on Oct 1, 2004 (gmt 0)

10+ Year Member



Here is the link i would like to create.
<a href="#"onMouseOver="MM_swapImage('imageswapable','','tshirts/jpgs/big/whiteshirt_247.jpg',1)">black</a><br>

I am using the code at the bottom , but it keeps removeing some of my " and some of my slashes could you tell me what i need to do to my code to make my code out put a string, like the one i would like to create above.

PROBLEMATIC RESULTING STRING
<a href="#" onMouseOver="MM_swapImage("imageswapable,,/tshirts/jpgs/big/whiteshirt_247.jpg,//,0)>white</a>

CODE I AM CURRENTLY USING
$out = '<a href="#" onMouseOver="MM_swapImage("imageswapable","",""';
$out .= ltrim($rowcolour['lg_image_link']).',"//"';
$out .= '",0)">';
$out .= $rowcolour['colour'];
$out .= '</a><br>'; echo $out;
echo "\n";

Symbios

7:27 pm on Oct 1, 2004 (gmt 0)

10+ Year Member



You need to put \ in front of each " in the output so

<a href="widget.php">Widget</a> becomes <a href=\"widget.php\">Widget</a>

bleak26

8:09 pm on Oct 1, 2004 (gmt 0)

10+ Year Member



i changed the php code to this

$out = '<a href=\"#\" onMouseOver=\"MM_swapImage(\"imageswapable\",\"\",\"\"';
$out .= ltrim($rowcolour['lg_image_link']).',"//"';
$out .= '",0)">';
$out .= $rowcolour['colour'];
$out .= '</a><br>'; echo $out;
echo "\n";

i end up with this as html out put in my source.

<a href=\"#\" onMouseOver=\"MM_swapImage(\"imageswapable\",\"\",\"\"/tshirts/jpgs/big/whiteshirt_247.jpg,"//"",0)">white</a><br>

it gets back my " marks but i what should i do about the slashes?

dreamcatcher

9:11 pm on Oct 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You need to juggle some of your apostrophes and quotes around.

Try this:


$out = "<a href=\"#\" onMouseOver=\"MM_swapImage(\"imageswapable\",'',''";
$out .= ltrim($rowcolour['lg_image_link']).",'//'";
$out .= "',0)'>";
$out .= $rowcolour['colour'];
$out .= "</a><br>";
echo $out;
echo "\n";

:)

jamesa

9:17 pm on Oct 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try this. I used double quotes since there's less to escape that way:

$out = "<a href=\"#\"onMouseOver="MM_swapImage('imageswapable','','";
$out .= ltrim($rowcolour['lg_image_link']);
$out .= "',1)\">";
$out .= $rowcolour['colour'];
$out .= "</a><br>";
echo $out . "\n";