Hello guy,
I need help. I can't figure out how to pass these values from a PHP loop to a jQuery function.
PHP: the playlist, psychically visual
Javascript (An example that works fine with manually added items, I can't figure out how to pass values from a PHP loop yet):Code:if ($result = $mysqli->query("SELECT mp3_id, genre, mp3_title, mp3_path, mp3_duration FROM mp3 WHERE genre = 'pop' ORDER BY mp3_id DESC LIMIT 5")) { while(($row = $result->fetch_object()) && ($i <= 5)) { echo "<li>"; echo "<div id=mp3Item>"; echo "<div id=mp3Track>"; echo $i++; echo "</div>"; echo "<div id=mp3Title>"; echo $row->mp3_title; echo "</div>"; echo "<div id=mp3Lenght>"; echo $row->mp3_duration; echo "</div>"; echo "</div>"; echo "</li>"; $mp3_files = $row->mp3_path; } }
I want something like this:Code:tracks = [ {"track":1,"name":"One More Night","length":"04:55","file":"01_One More Night.mp3"}, {"track":2,"name":"Some Nights","length":"03:37","file":"02_Some Nights.mp3"}, {"track":3,"name":"We Are Never Ever Getting Back Together","length":"04:05","file":"03_We Are Never Ever Getting Back Togethe.mp3"}, {"track":4,"name":"Too Close","length":"06:40","file":"04_Too Close.mp3"}, {"track":5,"name":"Die Young","length":"05:59","file":"05_Die Young.mp3"} ],
Any suggestion would be greatly appreciated.Code:tracks = [ {"track":1,"name":"$row->mp3_title","length":"$row->mp3_duration","file":"$row->mp3_path"}, {"track":2,"name":"$row->mp3_title","length":"$row->mp3_duration","file":"$row->mp3_path"}, . . . ],
Thanks



Reply With Quote
Bookmarks