dpizd08264 2019-05-12 13:14
浏览 80
已采纳

如何从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.

  • 写回答

1条回答 默认 最新

  • dongsan6889 2019-05-12 13:30
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。