Ich habe zwei Tabellen erstellt. Eine für abprodut_detail ist, ein anderer ist tbproduct_detailWert basierend auf einer Tabelle ID zu einer anderen Tabelle in Odeigniter erhalten
1.abproduct_deatil Struktur
id product_id product_name cost_price selling_price
7 4 Alentin DS 400 Tablet 55 60
I ein Formular erstellt wie dieser
<table class="table table-borderd table-hover">
<thead>
<tr>
<th>Product Name</th>
<th>Price</th>
<th>Quantity</th>
<th>Total</th>
<th><input type="button" class="btn btn-primary addmore" value="+"></th>
</tr>
</thead>
<tbody id="itemlist2">
<tr id="tr_1">
<td class="prod_c">
<select class="select-product form-control" id="itemName_1" name="product_name[]">
<option value="">
</option>
<?php
foreach ($product as $key):
?>
<option value="<?php echo $key['id'] ?>">
<?php echo $key['product_name'] ?>
</option>
<?php endforeach; ?>
</select>
</td>
<td>
<input type="text" name="price[]" id="price_1" class="price form-control" value="" data-cell="C1">
</td>
<td><input type="text" data-cell="D1" name="quantity[]" id="quantity_1" class="qty form-control"></td>
<td><input type="text" data-cell="E1" name="discount[]" id="discount_1" class="form-control"></td>
<td><input type="text" data-cell="F1" data-formula="(C1*D1)-(C1*D1*E1/100)" name="total[]" id="total_1" class="amount form-control"></td>
</tr>
</tbody>
</table>
I wählen alle Daten von abproduct_detail dadurch aus und legen tbproduct_detail . Nach dem Einfügen in tbproduct_detail sieht das so aus. Das bedeutet, dass ich die Produkt-ID-Nummer in product_name gespeichert habe.
2.tbproduct_detail Struktur
id product_id product_name quantity price
19 16 7 5 60
Ich mag diese Struktur auf meiner Seite Ansicht bearbeiten
id product_id product_name quantity price
19 16 Alentin DS 400 Tablet 5 60
Sie, dass abproduct_deatil bemerken, id = tbproduct_detai, product_name
zeigen will ich Ich möchte 2 Tabellen kombinieren und Daten auf meiner Bearbeitungsansichtsseite anzeigen.
meine Seite Ansicht bearbeiten
<thead>
<tr>
<th>ProductName</th>
<th>Quantity</th>
<th>Price</th>
</tr>
</thead>
<tbody class="detail">
<?php
if($rows->num_rows() > 0)
{
foreach($rows->result() as $d)
{
?>
<tr>
<td><input type="text" value="<?= $d->product_name ?>" name="product_name[]" class="form-control"></td>
<td><input type="text" value="<?= $d->quantity ?>" name="quantity[]" class="form-control"></td>
<td><input type="text" value="<?= $d->price ?>" name="price[]" class="form-control"></td>
</tr>
<?php
}
}
?>
</tbody>
</table>
mein Controller
public function edit($id)
{
$data['rows']= $this->db->query("SELECT * FROM tbproduct_detail WHERE product_id = '$id'");
$this->load->view('product/edit',$data);
}
Ich weiß nicht, wie dies zu tun? Bitte hilf mir. Ich bin neu in diesem Forum und Anfänger in Codeigniter.
ich mich gelöst durch Textwert geben statt id. Ich habe gerade mein erstes HTML-Formular geändert. Danke für alles. – TPLMedia24