DayDreamer16 Posted July 16, 2010 Share Posted July 16, 2010 i hardly ever make anything with php or even code anything so therefore i'm a newb, but this problem is nagging me. here's my code <?php mysql_connect("localhost", "username", "password"); mysql_select_db("database"); $sql = mysql_query("SELECT * FROM searchengine WHERE pagecontent LIKE '%$_GET[term]%' LIMIT 0,$_GET[results]"); while($ser = mysql_fetch_array($sql)) { echo "<h2><a href='javascript:popUp('$ser[pageurl]');'>$ser[title]</a></h2>"; echo "<p>$ser[pagecontent]</p>"; echo "<p><a href='$ser[link]'>$ser[link]</a></p>"; } ?> i have this code in the header <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function popUp(URL) { day = new Date(); id = day.getTime(); eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=150');"); } // End --> </script> i cant get the page to popup within the php echo, can anyone help? i'm sure its a simple fix. Link to comment https://forums.phpfreaks.com/topic/207943-javascript-popup-with-links-in-a-php-echo/ Share on other sites More sharing options...
isedeasy Posted July 16, 2010 Share Posted July 16, 2010 try <?php mysql_connect("localhost", "username", "password"); mysql_select_db("database"); $sql = mysql_query("SELECT * FROM searchengine WHERE pagecontent LIKE '%{$_GET['term']}%' LIMIT 0,{$_GET['results']}"); while($ser = mysql_fetch_array($sql)) { echo "<h2><a href=\"javascript:popUp('{$ser['pageurl']}');\">{$ser['title']}</a></h2>"; echo "<p>{$ser['pagecontent']}</p>"; echo "<p><a href=\"{$ser['link']}\">{$ser['link']}</a></p>"; } ?> Link to comment https://forums.phpfreaks.com/topic/207943-javascript-popup-with-links-in-a-php-echo/#findComment-1087027 Share on other sites More sharing options...
DayDreamer16 Posted July 16, 2010 Author Share Posted July 16, 2010 thankyou Link to comment https://forums.phpfreaks.com/topic/207943-javascript-popup-with-links-in-a-php-echo/#findComment-1087030 Share on other sites More sharing options...
isedeasy Posted July 16, 2010 Share Posted July 16, 2010 Also make sure you sanitize any input before using it in a query Link to comment https://forums.phpfreaks.com/topic/207943-javascript-popup-with-links-in-a-php-echo/#findComment-1087031 Share on other sites More sharing options...
DayDreamer16 Posted July 16, 2010 Author Share Posted July 16, 2010 ok Link to comment https://forums.phpfreaks.com/topic/207943-javascript-popup-with-links-in-a-php-echo/#findComment-1087032 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.