I have been programming in Php and MySQL a practice of master detail which has as fields the "id_detalle_renta", "idrenta", "idauto", which inserts the rent, but not the detail of the rent, then the php code with certain parts commented, I would be very helpful, thanks.
<?php
session_start();
require 'bd/conexion_bd.php';
if(!isset($_SESSION['status_renta']))
{
$_SESSION['status_renta']='Cerrada';
}
//echo var_dump($_SESSION['status_venta']);
//echo var_dump($_SESSION['ultimo_id']);
$obj = new BD_PDO("usuarios");
if (isset($_POST['btninsertardetalle']))
{
//if(!isset($_SESSION['status_venta']))
//{
if($_SESSION['status_renta']=='Cerrada')
{
$obj->Ejecutar_Instruccion("insert into rentas(fecharenta,idusuario,idcliente) values(Now(),'".$_POST['txtusuario']."','".$_POST['txtcliente']."')");
$_SESSION['ultimo_id'] = $obj->Ultimo_id();
$_SESSION['status_renta']='Abierta';
}
$result = $obj->Ejecutar_Instruccion("insert into detalle_renta(idrenta,idauto) values('".$_SESSION['ultimo_id']."','".$_POST['txtidauto']."')");
/*}
else
{
$_SESSION['ultimo_id']=0;
}*/
}
elseif (isset($_POST['btncerrarrenta']))
{
session_destroy();
// header("Location: reporte_ticket.php");
unset($_SESSION['status_renta']);
$_SESSION['status_renta']='Cerrada';
}
// $datos = $obj->Ejecutar_Instruccion("Select IdDetalleVenta, IdVenta,NombreProducto,IdProducto, Cantidad,Precio,( Cantidad*Precio ) as Subtotal from tbldetalleventa inner join tblproducto on tbldetalleventa.IdProducto=tblproducto.id_Producto where IdVenta='".@$_SESSION['ultimo_id']."'");
//$ticket = $obj->Ejecutar_Instruccion("CALL ticket('82');");
//echo var_dump($ticket);
?>