lingo5 Posted May 28, 2012 Share Posted May 28, 2012 Hi, I have a "tell a friend script" that opens a popup using javascript. The script posts opens a popup containig a form like this: var source = "friend_form.php"; My problem is that I need to also pass a URL parameter like so: var source = "friend_form.php?id_property='<?php echo $row_properties_RS['id_property]?>'"; but it doesn't seem to work as the popup does not get the id_property passed. I know I'm doing something wrong but can't figure it out Thanks Quote Link to comment https://forums.phpfreaks.com/topic/263277-please-help-passing-a-php-url-parameter/ Share on other sites More sharing options...
lingo5 Posted May 28, 2012 Author Share Posted May 28, 2012 Hi again, I've tried this: <?php $myVar="friend_form.php?id_property=$row_properties_RS['id_property]"; ?> and then added this to the JS: var source = '<?php echo $myVar ;?>'; but get this error: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in C:\wamp\www\mysite\index.php on line 89 being line 89 this: $myVar="friend_form.php?id_property=$row_properties_RS['id_property]"; :confused: :confused: :confused: Quote Link to comment https://forums.phpfreaks.com/topic/263277-please-help-passing-a-php-url-parameter/#findComment-1349260 Share on other sites More sharing options...
Alex Posted May 28, 2012 Share Posted May 28, 2012 Try: $myVar="friend_form.php?id_property=" . $row_properties_RS['id_property']; Quote Link to comment https://forums.phpfreaks.com/topic/263277-please-help-passing-a-php-url-parameter/#findComment-1349332 Share on other sites More sharing options...
lingo5 Posted May 29, 2012 Author Share Posted May 29, 2012 Thanks Alex, well at least this is passing a URL parameter...the problem is it always passes the same one (the id of the first record on my DB) :confused: Quote Link to comment https://forums.phpfreaks.com/topic/263277-please-help-passing-a-php-url-parameter/#findComment-1349435 Share on other sites More sharing options...
lingo5 Posted May 29, 2012 Author Share Posted May 29, 2012 OK, here's the button you press to open the "tlla frind" popup <td width="6%"><a class="modal" href="javascript:void(0);"><img src="img/iconos/enviar_amigo.gif" width="21" height="17" border="0" class="fixedTip" title="enviar a un amigo" /></a></td> this is my recordset and the $myVar variable that I use in the JS: mysql_select_db($database_MySQLconnect, $MySQLconnect); $query_destacadas_RS = "SELECT * FROM t_propiedades WHERE destacada = 1"; $destacadas_RS = mysql_query($query_destacadas_RS, $MySQLconnect) or die(mysql_error()); $row_destacadas_RS = mysql_fetch_assoc($destacadas_RS); $totalRows_destacadas_RS = mysql_num_rows($destacadas_RS); $myVar="friend_form.php?id_propiedad=". $row_destacadas_RS['id_propiedad']; and this is the JS: <script language="javascript"> $(document).ready(function() { var source = '<?php echo $myVar ;?>'; var width = 400; var align = "center"; var top = 100; var padding = 10; var backgroundColor = "#FFFFFF"; var borderColor = "#FFD200"; var borderWeight = 4; var borderRadius = 5; var fadeOutTime = 300; var disableColor = "#666666"; var disableOpacity = 40; var loadingImage = "images/loading.gif"; //This method initialises the modal popup $(".modal").click(function() { modalPopup( align, top, width, padding, disableColor, disableOpacity, backgroundColor, borderColor, borderWeight, borderRadius, fadeOutTime, source, loadingImage ); }); //This method hides the popup when the escape key is pressed $(document).keyup(function(e) { if (e.keyCode == 27) { closePopup(fadeOutTime); } }); }); </script> and still all I get is the same variable passed to friend_form.php..... any reasons why this is only passing the id_propiedad of the first record on my DB?? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/263277-please-help-passing-a-php-url-parameter/#findComment-1349448 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.