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 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译