Good afternoon
I'm setting up a table with the following code
<table align="center" cellpadding="10" id="user_table" class='table table-striped table-advance table-hover'>
<tr>
<th>NOME</th>
<th>C.P.F.</th>
<th>IDENTIDADE</th>
<th>TEL.</th>
<th>E-MAIL</th>
<th style='text-align: center'>MARCAR</th>
</tr>
<?php
while ($row=mysql_fetch_array($select))
{
?>
<tr id="row<?php echo $row['id_paciente'];?>">
<td > <?php echo $row['nome'] . " " . $data_consulta . " " . $id_m_h;?></td>
<td > <?php echo $row['cpf'];?></td>
<td > <?php echo $row['identidade'];?></td>
<td > <?php echo $row['tel_01'];?></td>
<td > <?php echo $row['email'];?></td>
<td style='text-align: center'>
<button id="id_c02b_marcar_consulta" type="button" class="btn" value="<?php echo $row['id_paciente']?>" >MARCAR <?php echo $row['id_paciente']?></button>
</td>
</tr>
<?php
}
?>
</table>
As you can see within WHILE you have the following line
<button id="id_c02b_marcar_consulta" type="button" class="btn" value="<?php echo $row['id_paciente']?>" >MARCAR <?php echo $row['id_paciente']?></button>
I usually use the following code in java script to perform an action
$('#id_c02b_marcar_consulta').click(function ()
{
funcao_patati_patata($("#id_c02b_marcar_consulta").val(),"<?php $id_usuario; ?>","<?php $id_horario; ?>");
});
As I am in a TABLE and the IDs ARE EQUAL ... the above code will only work for the first line. Home
My idea is every BUTTON on the table line have to write a record containing user_id, patient_id, hour_id. I already have all the variables loaded.
I do not have much experience in PHP / JAVASCRIPT / JQUERY so I'm not seeing another path to my problem Do a javascript function that takes all the rows of the table
With my current knowledge I would have to have a javascript function for each button in the table row. It is not an option since the table is dynamic and comes from the database.