I have a script that when i click on one div, will make another div show or hide.
That works great, but when i use that in an sql query and i click on one div, all the other ones will show :) So i was thinking at an incremental script so that it will auto number the div automatically (which works great) but i don't know what to use inside java script so that it will work.
Here is the code:
<?php
$conn = mysql_connect("localhost","user","pass");
mysql_select_db("database");
mysql_set_charset("UTF8", $conn);
$a = 1;
$b = 1;?>
<script>
$(".Denumire<?php echo $a; ?>").click(function(){
$(".Informatie<?php echo $b; ?>").toggle();
})
</script><?php
$construct ="SELECT * FROM tablename ";
$run = mysql_query($construct) or die(mysql_error());
$foundnum = mysql_num_rows($run);
// Define $color=1
$color="1";
if ($foundnum==0)
{
echo "Nu avem Informații!";
}
else
{
while($runrows = mysql_fetch_assoc($run))
{
$Denumire = $runrows ['Denumire'];
$Informatie = $runrows ['Informatie'];
echo "
<div id='dam'>
<div class='Denumire".$a++."'>
<table>
<tr>
<td>$Denumire</td>
<td><img src='http://bios-diagnostic.ro/wordpress/img/gobottom.png'></td>
</tr>
</table>
</div>
<div class='Informatie".$b++."'><br>$Informatie<br></div>
</div><hr><br><br>
";}}?>
The problem is in the java script... Some ideas will be appreciated ... thank you all.