salve ragazzi,
Sto diventando pazzo, vi spiego meglio.
Ho realizzato un database con mysql, quindi con tabelle ecc.
Ho realizzato una funzione jquery per stampare i dati presi(con PHP) da una tabella su mysql .
Detto ciò per ogni riga che stampo della tabella, ho inserito un pulsante che dovrebbe permettermi la cancellazione. ma non so proprio come fare visto che la tabella si crea automaticamente in base ai dati presenti sul database. AIUTOOO !!!
Codice Html che stampa la tabella con jquery
<table id="meeting2" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Meeting</th>
<th>Titolo</th>
<th>Place</th>
<th>Date</th>
<th>Topic</th>
<th></th>
<th></th>
</tr>
</thead>
</table>
<script>
$(document).ready(function(){
var table = $('#meeting2').dataTable( {
"sAjaxSource": "dati_meeting.php",
"aoColumns": [
{ "mData": "meeting_id" },
{ "mData": "title" },
{ "mData": "place"},
{ "mData": "date"},
{ "mData": "topic"},
{ "defaultContent":"<input type='button' value='delete' onclick='elimina()'/> "},
{ "defaultContent":"<button>Info</button>"},
],
});
});
</script>
CODICE PHP CHE PRENDE I DATI E LI RESTITUISCE A JQUERY
<?php
// Avvia la sessione
session_start();
// Include dati DB
include("db.php");
// Crea connessione al DB
$conn = mysqli_connect($db_host, $db_user, $db_password);
mysqli_select_db($conn, $db_database);
$result = mysqli_query($conn, "SELECT meeting_id,title, place, date, topic FROM meeting WHERE user_id=(select user_id from account where username=\"".$_SESSION["username"]."\")");
$num_rows = mysqli_num_rows($result);
$res = array();
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
{
$res[] = array(
'title'=> utf8_encode($row['title']),
'place' => utf8_encode($row['place']),
'date' => utf8_encode($row['date']),
'topic' => utf8_encode($row['topic']),
'meeting_id'=> utf8_encode($row['meeting_id']),
);
}
$json_data = array(
"draw" => 1,
"recordsTotal" => $num_rows,
"recordsFiltered" => $num_rows,
"data" => $res
);
$json = json_encode($json_data);
echo $json;
?>