0

Hello all,
I use a database to extract the title of a url. I want to take save this title in a variable and then check if it is url1 or url2.
If it is url1 call url1 javascript function else if url2 call url2 function.

My code is :
Code:

$query = "SELECT url FROM info"; 
$row = mysql_fetch_array($result); 

 if ($row['url']=='http://....') 
{ 
   echo '<A HREF="'; 
   echo '<SCRIPT LANGUAGE="javascript">'; 
   echo 'popUp("url1.php")'; 
   echo "</SCRIPT>"; 
   echo '">'; 
 }         
 if($row['url']=='http://...') 
{ 
   echo '<A HREF="'; 
    echo '<SCRIPT LANGUAGE="javascript">'; 
    echo 'popUp("url2.php")'; 
    echo "</SCRIPT>"; 
    echo '">'; 
 }

What is the error??

Thanks
-----------------------------------------------------------------------------
<URLs SNIPPED>

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by sDJh
0

1) You better don't do it this way. Write a JS-function popup with an argument. THen popup the argument (which is window.open() by the way).
2) in every link you pass the complete url from PHP to JS with simply something like this:

<a href="javascript:newwin('<?echo $row['url']?>');">

3) for the future: ALWAYS explain the error. Noone here has enough time to doublecheck your code. You problem can be either in JS, PHP, MySQL or just because your browser doesn't execute JS. So always give at least an errormessage so that we know where to look at.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.