简体   繁体   中英

Getting a data from a table to insert to another database table

I have this table that contains data from the database table 'patient'.

在此处输入图片说明

 <td>
   <a href="{{ URL::to('/addvisit/'.$patient->pID) }}">
   <img src="images/visit.png" style="width:30px; height:30px;">
   </a>
 </td>

when the circle icon is clicked it will redirect to a page with a form that will be inserted in a database table 'visit'.

below is the form:

{!! Form::model($patient, ['url'=>'visit/' . $patient->pID, 'method' => 'PATCH']) !!}
            <div class="form-group">
                {!! Form::label('fname', 'Full Name',['class' => 'control-label'])!!}
                {!! Form::text('pName',null,['class' => 'form-control']) !!}

                {!! Form::label('address', 'Address',['class' => 'control-label'])!!}
                {!! Form::text('pAddress',null, ['class' => 'form-control']) !!}

                {!! Form::submit('SUBMIT',['class' => 'form-control btn btn-success']) !!}
            </div>
{!! Form::close() !!}

how can I add the patient ID from the 'patient' table to be set as a foreign key in the 'visit' table.

通过控制器将其再次传递给带有表单的视图,并将其存储在隐藏的输入中

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM