如何从SQL获取数据,在PHP中列为变量,然后将其作为$ _POST发送回SQL?

如何从SQL获取数据,在PHP中列为变量,然后将其作为$ _POST发送回SQL?

问题描述:

I hope I can explain this good enough...

I currently have data stored in a SQL table called 'client', I have taken this information that is stored there and it is currently displaying on a PHP page.

Now that this data is taken from the SQL to the PHP, do I need to store it somehow in order to POST it back to the database? If this is the case I am not should how this is done...

<?php
include 'includes/config.php';
$sel = "SELECT car_name FROM cars WHERE car_id = '$_GET[id]'";
$rs = $conn->query($sel);
$rws = $rs->fetch_assoc();
?>              

<?php echo 'Your Car: '.$rws['car_name'];?><br>

From the snippet of code, this is included within a as there is other information that is being gathered on the page. The SQL code SELECT gathers the information and the PHP displays it fine, I am now trying to use the same information and send it back to the SQL database.

Thanks guys, I hope you can help.

我希望我能解释得这么好...... p>

我目前 将数据存储在名为'client'的SQL表中,我已经获取了存储在那里的信息,它当前正在PHP页面上显示。 p>

现在这些数据来自于 SQL到PHP,我需要以某种方式存储它,以便将其POST回数据库吗? 如果是这种情况我不应该怎么做... p>

 &lt;?php 
include'include / config.php'; 
 $ sel =“  SELECT car_name FROM cars WHERE car_id ='$ _GET [id]'“; 
 $ rs = $ conn-&gt; query($ sel); 
 $ rws = $ rs-&gt; fetch_assoc(); 
?&gt;  ;  
 
&lt;?php echo'你的车:'。$ rws ['car_name'];?&gt;&lt; br&gt; 
  code>  pre> 
 
 

来自的片段 代码,这包含在a中,因为页面上正在收集其他信息。 SQL代码SELECT收集信息,PHP显示正常,我现在尝试使用相同的信息并将其发送回SQL数据库。 p>

谢谢大家,我希望你能 帮助。 p> div>

If you select data from database and display it in your app, you do not need to store same data into database. These data are persistent in DBS. If you need to find a way how to store information (in variables) to be used across multiple pages, you can use session. Sessions are global variables. Place session_start(); in the beginning of your app. Use: $_SESSION["car_name"] = $rws['car_name'];

You can use session_unset(); to remove all sessions in the end of app.