I am putting together a list of music lists for a karaoke site. It works like this:
Search for pre-recorded music Get this input song and insert it into a li list
I have the following:
<input id="musica" type="text">
<button type="button" id="add">Adicionar</button>
<ul id="listademusicas">
</ul>
<script>
jQuery('#add').click(function() {
jQuery('#listademusicas').append('<li id="">'+jQuery('#musica').val()+'</li>');
});
</script>
Then I wanted to insert the li, it would bring the id of the song, the table looks like this:
tabela_musicas
id|nome
1 |nome da musica1
2 |nome da musica2
In the input that takes the name of the song I'm using a query that has the exact name of the song, so I thought of doing something like
SELECT id FROM tabela_musicas WHERE nome = "nome da musica".
But I do not know how to do this query dynamically. I wanted the music id to be inserted in the name or id of each line.