Note that there are some explanatory texts on larger screens.

plurals
  1. POopen another div when click on one incremental numbered div
    primarykey
    data
    text
    <p>I have a script that when i click on one div, will make another div show or hide.</p> <p>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.</p> <p>Here is the code:</p> <pre><code>&lt;?php $conn = mysql_connect("localhost","user","pass"); mysql_select_db("database"); mysql_set_charset("UTF8", $conn); $a = 1; $b = 1;?&gt; &lt;script&gt; $(".Denumire&lt;?php echo $a; ?&gt;").click(function(){ $(".Informatie&lt;?php echo $b; ?&gt;").toggle(); }) &lt;/script&gt;&lt;?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 " &lt;div id='dam'&gt; &lt;div class='Denumire".$a++."'&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;$Denumire&lt;/td&gt; &lt;td&gt;&lt;img src='http://bios-diagnostic.ro/wordpress/img/gobottom.png'&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;div class='Informatie".$b++."'&gt;&lt;br&gt;$Informatie&lt;br&gt;&lt;/div&gt; &lt;/div&gt;&lt;hr&gt;&lt;br&gt;&lt;br&gt; ";}}?&gt; </code></pre> <p>The problem is in the java script... Some ideas will be appreciated ... thank you all.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload