php - Mysql insert in two tables where the first table has foreign key and update the first table -


this have in db if insert in bmw car brands example.how update id_make whith id bmw sql.(i know huge mess in code , no aligment)

http://i.stack.imgur.com/gqqg1.png

this form:

<div class="modal-content">     <div class="modal-header">         <button type="button" class="close" data-dismiss="modal">&times;</button>         <h4 class="modal-title">add car:</h4>     </div>     <div class="modal-body ">         <form action="index.php?page=carlist" method="post" autocomplete="off">             <div class="form-group">                 <label for="marca">marca:</label>                 <!-- <input type="text" class="form-control" name="marca" placeholder="marca" data-toggle="modal" data-target="#marca"> -->                 <div class="input-group">                     <div class="input-group-btn">                         <input type="text" class="form-control dropdown-toggle " data-toggle="dropdown" placeholder="                                    <?php                         if (!isset($brd['name']))                         {                             echo "brand";                         } else                             echo $brd['name'];                         ?>" name="marca" readonly="readonly">                         <ul class="dropdown-menu scrollable">                             <?php foreach ($brds $brd)                             { ?>                                 <li><a href='#'><?php echo $brd['name']; ?></a></li>                             <?php } ?>                         </ul>                     </div>                     <!-- /btn-group -->                 </div>                 <!-- /input-group -->             </div>             <div class="form-group">                 <label for="model">model:</label>                 <input type="text" class="form-control" name="model" placeholder="model">             </div>             <div class="form-group">                 <label for="color">color:</label>                 <input type="test" class="form-control" name="color" placeholder="color">             </div>             <div class="form-group">                 <label for="release_date">release date:</label>                  <div class=" date">                     <input type="date" class="form-control" name="release_date" placeholder="release date"                            id='release_date'>                     <!-- <span class="input-group-addon add-on"><span class="glyphicon glyphicon-calendar"></span></span> -->                 </div>             </div>             <div class="form-group">                 <label for="value">value:</label>                 <input type="test" class="form-control" name="value" placeholder="value">             </div>             <div class="modal-footer">                 <button type="button" class="btn btn-default" data-dismiss="modal">close</button>                 <input type="submit" name="addcar" class="btn btn-primary" value="add car">             </div>         </form>     </div> </div> 

(the php input on brand show brands db )

when select brand list , put model ,color, value ,release date press add car php makes connection on db insert on table models model of car , need add id brands witch car selected on list , update models id_make id of car.

perhaps need request id of make inserted using:

mysql_insert_id(); 

id of record inserted, , use id make in other table.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -