我想知道如何将从数据库中提取的结果保存回数据库。
我从数据库中的表中选择并获取了一行,我希望在同一数据库中的另一个表中插入一行。我试图转动$ row ['example'];一个变量,但它不会工作,我回应变量,以确定它的工作,但它没有显示。
我需要帮助,下面是我的代码。
<?php
$query =mysqli_query ($dbconnect, "select * from stuprofile where username ='$user' limit 1");
while ($row= mysqli_fetch_assoc($query)){?>
<?php
$uname= "USERNAME :";
$ebc= "EBC16";
$id ="MATRIC NO : ";
$wel = "WELCOME ";
$name ="FIRSTNAME : ";
$lname ="LASTNAME : ";
$sex ="SEX : ";
$add ="ADDRESS : ";
$mob ="MOBILE : ";
$inst ="INSTITUTION : ";
$chap ="CHAPTER : ";
$marr ="MARITAL STATUS : ";
$lc ="LOCAL CHURCH : ";
$bap ="BAPTISM : ";
$baptised ="BAPTISED : ";
$bank ="BANK : ";
$teller ="TELLER NUMBER : ";
$pay ="PAYMENT NUMBER : ";
$email ="EMAIL : ";
// dont forget to style your above varibles
//<span id ="ty">
?>
<div class="wel">
<?php
echo "<p>" . $wel . "<div id='ten' >" . " " . $row['firstname'] . " " . $row['lastname'] . "</div>" . "<p>" . "<br />" ;
?>
</div>
<!--<section><img src= "images/egliselogocomp.jpg" height="310" width: 50px> </section>-->
<p class= "names">
<?php
echo
$id . "<span >" . $ebc . $row['id']. "</span >" . " <br />" .
$name . "<span >" . $row['firstname']. "</span >" . "<br />" .
$lname . "<span >" .$row['lastname']. "</span >" . "<br />" .
$uname . "<span >" .$row['username']. "</span >" . "<br />" .
$sex . "<span >" .$row['sex'] . "</span >" . "<br />" .
$add . "<span >" .$row['address']. "</span >" . "<br />" .
$email . "<span >" .$row['email']. "</span >" . "<br />" .
$mob . "<span >" .$row['mobile']. "</span >" . "<br />" .
$inst . "<span >" .$row['institution']. "</span >" . "<br />" .
$chap . "<span >" .$row['chapter']. "</span >" . "<br />" .
$marr . "<span >" .$row['marital_status']. "</span >" . "<br />" .
$lc . "<span >" .$row['local_church']. "</span >" . "<br />".
$bap . "<span >" .$row['baptised']. "</span >" . "<br />" .
$baptised . "<span >" .$row['baptism']. "</span >" . "<br />" .
$bank . "<span >" .$row['bank']. "</span >" . "<br />" .
$teller . "<span >" .$row['teller_no']. "</span >" . "<br />".
$pay . "<span >" .$row['payment_date']. "</span >" . "<br />";
}
?>
</p>
<?php
} else {
header("location: ebcreg.php");
}
我需要插入。 $ ebc。 $ row ['id']回到数据库中。
我该怎么做呢。 感谢
答案 0 :(得分:0)
mysqli_query($ dbconnect,&#34; INSERT INTO ....&#34;);
与选择数据的方式相同,只需更改查询即可。