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.

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.