Solarpitch Posted January 1, 2007 Share Posted January 1, 2007 Hey guys,Just looking for a little help with this. I posted something similar last week but it resolved itself. This is slightly different however.Basically the following code generates a href to 3 images that are retrieved from the DB. Using Javascript the user can navigate through the 3 images.The following codes works perfect![code]<div style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:13px; "> View images:<a href="javascript:image('user_images/<?php echo $image1; ?>');">[1]</a><a href="javascript:image('user_images/<?php echo $image2; ?>');">[2]</a><a href="javascript:image('user_images/<?php echo $image3; ?>');">[3]</a></div>[/code]however, when I try to generate this code as an "echo" to the page, when the links [1], [2] and [3] are clicked . . noting happens! heres that code . . [code]echo "<a href='javascript:image('user_images/".$row['image_path1']."');'>[3]</a>"echo "<a href='javascript:image('user_images/".$row['image_path2']."');'>[2]</a>";echo "<a href='javascript:image('user_images/".$row['image_path3']."');'>[3]</a>";[/code]I should also add that when you roll the mouse over the links in the first example, the href displays as.."javascript:image('user_images/taylormade.jpg');" however in the bottom example that wont work it displays as.."javascript:image("Grateful of some help, cheers Link to comment https://forums.phpfreaks.com/topic/32498-problem-with-echoing-javascript-and-php-database-values/ Share on other sites More sharing options...
kenrbnsn Posted January 1, 2007 Share Posted January 1, 2007 You have problems with your quotes. Try this:[code]<?phpecho '<a href="javascript:image(' . "'user_images/" . $row['image_path1'] . "');" . '">[3]</a>';echo '<a href="javascript:image(' . "'user_images/" . $row['image_path2'] . "');" . '">[2]</a>';echo '<a href="javascript:image(' . "'user_images/" . $row['image_path3'] . "');" . '">[3]</a>';?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/32498-problem-with-echoing-javascript-and-php-database-values/#findComment-151056 Share on other sites More sharing options...
Solarpitch Posted January 1, 2007 Author Share Posted January 1, 2007 Thanks a mill ken that sorted it, 2 hours of trying to figure that out! :) Link to comment https://forums.phpfreaks.com/topic/32498-problem-with-echoing-javascript-and-php-database-values/#findComment-151062 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.