...

View Full Version : handling onclick window.open



mrjameer
01-07-2007, 01:49 PM
hi,

i have a mysql table called footers.it's fields are as follows
id--caption--content
1--aboutus--some company info
2--privacy--privacy info
3--copyright--copyright info

here i retrieved all the captions from table and print in the footer position on my form as footer menu.what i want to do actually is when i click aboutus,it should open small window and display the aboutus content from mysql table,similarly when i click privacy,it should open a small window and should display privacy info like that.everything i did,but when i click aboutus,it shows all the three records from table.i want to display uniquely.means if i click aboutus it should display only aboutus info in small window like that..any of your help will be greatly appreciated

here is my code
<?php
$conn4=mysql_connect("localhost","","");
mysql_select_db("jrm",$conn4);
$sql="SELECT * FROM footers";
$result=mysql_query($sql,$conn4) or die (mysql_error());
echo "<center><table border='0' style='text-align:left;'><tr>";
while($newarray=mysql_fetch_array($result))
{
$caption=$newarray['caption'];


echo "<center><a style='text-decoration:underline;'
href onclick=window.open('xyz.php','','top=200,left=350,screenY=0,screenX=0,width=400,height=300,scrollba rs=yes');>
<td><font color='white'><b>".$caption. "&nbsp;&nbsp;</b></font></td></a></center>";
}
echo "</tr></table></center>";
?>


xyz.php
------
<?php


$conn4=mysql_connect("localhost","","");
mysql_select_db("jrm",$conn4);
$sql="SELECT * FROM footers";
$result=mysql_query($sql,$conn4) or die (mysql_error());
while($newarray=mysql_fetch_array($result))
{
$caption=$newarray['caption'];
$content=$newarray['content'];

echo "<center><b><u><font color='navy'>".$caption."</font></b></u><br><font color='green'>".$content."</font></center>";
}

?>

is it possible without using xyz.php file,i will display the $content in small window directly

thanks
mrjameer

gunman
01-08-2007, 10:05 AM
Try this



<?php
$conn4=mysql_connect("localhost","","");
mysql_select_db("jrm",$conn4);
$sql="SELECT * FROM footers";
$result=mysql_query($sql,$conn4) or die (mysql_error());
echo "<center><table border='0' style='text-align:left;'><tr>";
while($newarray=mysql_fetch_array($result))
{
$caption=$newarray['caption'];


echo "<center><a style='text-decoration:underline;'
href onclick=window.open('xyz.php?id=".$newarray['id']."','','top=200,left=350,screenY=0,screenX=0,width=400,height=300,scrollba rs=yes');>
<td><font color='white'><b>".$caption. "&nbsp;&nbsp;</b></font></td></a></center>";
}
echo "</tr></table></center>";
?>


xyz.php



<?php


$conn4=mysql_connect("localhost","","");
mysql_select_db("jrm",$conn4);
$sql="SELECT * FROM footers where id = '".$_GET['id']."' limit 1";
$result=mysql_query($sql,$conn4) or die (mysql_error());
while($newarray=mysql_fetch_array($result))
{
$caption=$newarray['caption'];
$content=$newarray['content'];

echo "<center><b><u><font color='navy'>".$caption."</font></b></u><br><font color='green'>".$content."</font></center>";
}

?>


Yes it is possible to make it without xyz.php file. You could use instead some well formed div. Good Luck



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum