doumie7914 2014-07-21 02:45
浏览 600
已采纳

将数据库结果输出到文本框

When I connect to my database and try to output it's result in to a text box, it wouldn't print anything that would comes after a space. For example, as shown in the image bellow, it only prints out Brown and wouldn't show the rest. (This only happens if there is a space). However, this problem doesn't happen if I print the result without using a text box. Please let me know if there is anything I can do make it work with a textbox.

<?php

$connInfo = array(
        'Database' => 'database_name',
        'UID' => 'user_ID',
        'PWD' => 'my_password',
        'ReturnDatesAsStrings' => true 
        );

    $connectString = sqlsrv_connect('sever_name.com', $connInfo) or die("Can't connect to the database.");


$query_infor = "SELECT * FROM ElectronicShop WHERE WorkOrder=5";
$data_infor = sqlsrv_query($connectString, $query_infor) or die(print_r(sqlsrv_errors(SQLSRV_ERR_ALL), true));
$row_infor = sqlsrv_fetch_array($data_infor);

echo "Printing the name outside the textbox: ".$row_infor['fullname']."<br><br>";
echo "Should show both LastName and FirstName: <input id=\"fullname\" type=\"text\" name=\"fullname\" value=".$row_infor['fullname']." >";

?>

enter image description here

  • 写回答

1条回答 默认 最新

  • doskmc7870 2014-07-21 02:51
    关注

    This is because you don't have the value attribute in quotes. Your HTML looks like this: value=Brown Sam as opposed to value="Brown Sam".

    You should use something like this:

    echo 'Should show both LastName and FirstName: <input id="fullname" type="text" name="fullname" value="'.$row_infor['fullname'].'" >';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置