I have a jQuery function on a panel as part of an ERP, making an INSERT via a PHP file. The INSERT is correctly made, as the database always receives info properly, but I am unable to send that last inserted record back in order to show it on screen on real time.
jQuery function (seems to be working properly)
function showSuggestions (datos) {
$('tbody *').empty();
var resultados= datos;
$('tbody').on('keydown').html(resultados);}
Content on the PHP file making the insert ( INSERT works properly ):
$nombreTurno = $_POST['tu_name'];
$insertar = mysql_query("INSERT INTO turn_conf (tu_id,tu_name,tu_status) VALUES ('','$nombreTurno','1')");
$lastInsert=mysql_insert_id();
$select =mysql_query("SELECT * FROM turn_conf WHERE tu_id='$lastInsert'");
$data="";
$name=$select['tu_name'];
$turn_id=$select['tu_id'];
$data= '<tr>
<td><span class="tableContentRow">'.$name.'</span></td>
<td class="editColumn"><a href="#"><div class="editIcon"></div></a></td>
<td class="discontinueColumn"><a href="/Gestion/config/forms/turn_conf/turn_discontinue.php?id='.$turn_id.'"><div class="discontinueIcon"></div></a></td>
</tr>'; echo $data;
What is coming back to the panel is the HTML piece, but with no values on '.$name.'
and '.$turn_id.'
so the row is added, but empty. There's no console error, and I've checked that $lastInsert
contains the correct info: this INSERT's id that has just been done.
EDIT_ I've also tryed by $turn_id=$lastInsert;
with no result.
i think you've missed this
$result= mysql_fetch_array($select);
print $result['tu_name'];
print $result['tu_id'];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.