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>

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.