I currently have a table that comes with MySQL data:
$ Result = mysqli_query ($ Conn, "Select + Artist LIMIT 10"); If (! $ Result) {printf ("Error:% s \ n", mysqli_error ($ con)); Go out(); } // show artist data "echo" in the table; Table & gt; & Lt; Th & gt; BadNoise artists & lt; / Th & gt; "; While ($ line = mysqli_fetch_array ($ result)) {resonant" & lt; Tr & gt; & Lt; Td & gt; ". $ Line ['first name']" & lt; / TD & gt; & Lt; TD & gt; ". $ Line ['Last name']" & lt; / Td> & Lt; Td> & Lt; Button ID = ''. $ Line ['Artist number'] "'& gt; by this artist song & lt; / button & gt; & lt; / tr & gt;" ; } Resonates "& lt; / table & gt;"; Mysqli_close ($ thief);
?
?
& lt; Script & gt; $ (Document) .ready (function () {$ ("button") Click (function () {var ArtistNumber = $ (this) .attr ('id'); $ ("# div1"). Load (" Demo_test "+ ArtistNumber +" .txt ");});}); & Lt; / Script & gt;
For every result I need to be able to do that, a div is inserted in each row of the table, and when clicking on that row button, the box of that row
I think I know what you are trying to do They want a line in each row when you click on the button. So your PHP code will look like this:
while ($ row = mysqli_fetch_array ($ result)) {resonant "<<< tr> . $ Line ['first name'] "& lt; / td> & lt; td & gt;" . $ Line ['last name'] "& lt; / td> gt; & lt; td & gt; & lt; button id = ''. $ Line ['artist number']" '& gt; The song given by this artist & lt; / Button & gt; & Lt; / Td> & Lt; Td> & Lt; Div id = 'artist' $ line ['artist number'] "'& gt; & lt; / div & gt; & lt; / td & gt; & lt; / tr & gt; ; } and you can change your JQuery to put it into code using your code:
$ ("# artist" +) ArtistNumber) .load ("demo_test" + ArtistNumber + ".txt");
Hope it helps!
Comments
Post a Comment