Ok, not so good in PHP, i have a database (mysql), and a form with many field submitting to the database, i need to call all the values and display them into the text box's accordingly so they can be edited and submitted again. please help
2条回答 默认 最新
- duanseci1039 2013-04-01 21:51关注
I'll give a very simple example that should get you started.
The values are accessible via (most likely)
$_POST['input_name']
. Without using Post/Redirect/Get, you can just get the input values like:$input_name = isset($_POST['input_name']) ? $_POST['input_name'] : '';
Then later you'll display it in the form like:
echo '<input name="input_name" value="' . htmlspecialchars($input_name, ENT_QUOTES) . '">';
If you want to use P/R/G, which you should do, you need to store the input in the
$_SESSION
.session_start(); //initialize all inputs to the empty string if (!isset($_SESSION['inputs'])) { $_SESSION['inputs'] = array('input_name' => ''); } if ('POST' == $_SERVER['REQUEST_METHOD']) { $_SESSION['inputs']['input_name'] = isset($_POST['input_name']) /* etc. */; }
You can then output it in your form via
$_SESSION
instead of$_POST
.本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 ubuntu子系统密码忘记
- ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
- ¥15 保护模式-系统加载-段寄存器
- ¥15 电脑桌面设定一个区域禁止鼠标操作
- ¥15 求NPF226060磁芯的详细资料
- ¥15 使用R语言marginaleffects包进行边际效应图绘制
- ¥20 usb设备兼容性问题
- ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
- ¥15 安装svn网络有问题怎么办
- ¥15 vue2登录调用后端接口如何实现