Jump to content

Javascript popUp with links in a php echo


DayDreamer16

Recommended Posts

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.

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>";
}

?>

Archived

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

×
×
  • Create New...

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.