Hi,
First of all I am Sorry for such a long query.
I am using mysql db.I wanted to display data present in the db.I am using two functions showdiv() & hidediv().
For example,I have 26 tables in my db say from A-Z.In each table it has some info.for examp, in table 'A' it has A1,A2,A3... In table 'B' it has B1,B2..The page where the data from db must display is something like this.
<html>
<body>
<table>
<tr>
<td class="imag" id="def">| <a href="home.html"> Home </a> | <a href="ab.php"> About Us </a>| <a href="st.php"> Staff </a> | <a href="med.php"> Medicines</a> |<a href="hc.html"> Health Care</a> |<a href="news.html"> News </a>|</td></tr>
This is the 1st row and in the 2nd row it contains alphabets A-Z.Here is the code
<tr><td>
<a href="javascript:switchid('div1');" style="text-decoration:none;" >A </a>
<a href="javascript:switchid('div2');" style="text-decoration:none;" >B</a>
<a href="javascript:switchid('div3');" style="text-decoration:none;" >C</a>
.
.
.
<a href="javascript:switchid('div25');" style="text-decoration:none;" >Y</a>
<a href="javascript:switchid('div26');" style="text-decoration:none;" >Z</a></td></tr>
Now in the next row I wanted the to display infor from db.For exam, when I click 'A' the data in table 'A' must display.If I click 'B',in the same row instead of data from 'A' data from table 'B' must display.Code I wrote is
<tr><td>
<?
$str="SELECT * FROM a";
$res=mysql_query($str);
if(mysql_num_rows($res)!=0)
{
while($data=mysql_fetch_array($res,MYSQL_ASSOC))
{
echo '<tr>';
echo ' <td class="pos" id="div1" style="display:none;text-decoration:none; "> <a href="'.$data['MedName'].'" >' .$data['dispname'].' </a></td > ';
echo '</tr>';
}
}
$str="SELECT * FROM b ";
$res=mysql_query($str);
if(mysql_num_rows($res)!=0)
{
while($data=mysql_fetch_array($res,MYSQL_ASSOC))
{
echo '<tr>';
echo ' <td class="pos" id="div2" style="display:none;"> <a href="'.$data['MedName'].'" >' .$data['dispname'].' </a></td > ';
echo '</tr>';
}
}
else
echo 'Failure';
So on upto 'Z'
And in the head I wrote
<script language="javascript" type="text/javascript">
var ids=new Array('div1','div2', 'div3', 'div4', 'div5', 'div6', 'div7', 'div8', 'div9', 'div10', 'div11', 'div12', 'div13', 'div14', 'div15', 'div16','div17', 'div18', 'div19', 'div20', 'div21', 'div22', 'div23', 'div24', 'div25', 'div26');
function switchid(id)
{
hideallids();
showdiv(id);
}
function hideallids()
{
for(var i=0;i<ids.length;i++)
{
hidediv(ids[i]);
}
}
function hidediv(id)
{
if(document.getElementById)
{
document.getElementById(id).style.display ='none';
}
else
{
if(document.layers)
{
document.id.display ='none';
}
else
{
document.all.id.style.display ='none';
}
}
}
function showdiv(id)
{
if(document.getElementById)
{
document.getElementById(id).style.display ='block';
}
else
{
if(document.layers)
{
document.id.display ='block';
}
else
{
document.all.id.style.display ='block';
}
}
}
</script>
I am able to display data but my problem is that when I click 'A' onli A1 is displaying.when I click 'B' onli B1 is displaying not in the same row but some where down in the next row.For each alphabet data displayed is onli one and in the next row.
Once again Sorry for such a lengthy query.
Thank You