开发者

Editing a mySQL record with PHP

开发者 https://www.devze.com 2023-01-24 00:27 出处:网络
The snippet of the PHP script below works for the most part... except for the fact that $rows[from_location_1] and $rows[\'to_location_1\'] are not displaying all of the data.

The snippet of the PHP script below works for the most part... except for the fact that $rows[from_location_1] and $rows['to_location_1'] are not displaying all of the data.

The data consist of building code (letters) followed by a space then floor number/room number. example: NAC 1/200A. The script is displaying only the building code (NAC)

Note: the statement: echo "$rows[from_location_1]"; show all of the data.

I'm totally stumped after trying everything I can think of and read...

Any ideas as to what's causing it not to display all of the data and a possible get around will be greatly appreciated...

Thanks Chris

echo '<html>';
echo '<head><title> </title>';
echo '</head>';
echo '<body>';
echo '<form method=post action=xxx>';
echo '<table border=5>';
$rows= mysql_fetch_array($result);
echo '<tr>&lt;th>CIT Number&lt;/th>&lt;td>';
echo "&lt;input type=text disabled value=" . $rows['citnum'] . ">&lt;/td>&lt;/tr>";
echo '&lt;tr>&lt;th>Serial Number&lt;/th>&lt;td>';
echo "&lt;input type=text disabled value=" . $rows['sernum'] . ">&lt;/td>&lt;/tr>";
echo '&lt;tr>&lt;th>Move Date&lt;/th>&lt;td>';
echo "&lt;input type=text value=" . $rows['move_date_1'] . ">&lt;/td>&lt;/tr>";
echo '&lt;tr>&lt;th>From&lt;/th>&lt;td>';
echo "&lt;input type=text value=" . $rows[from_location_1] . ">&lt;/td>&lt;/tr>";
echo '&lt;tr>&lt;th>To&lt;/th>&lt;td>开发者_StackOverflow';
echo "&lt;input type=text value=" . $rows['to_location_1'] . ">&lt;/td>&lt;/tr>";
echo '&lt;tr>&lt;th>Comment&lt;/th>&lt;td>';
echo "&lt;input type=text value=" . $rows['comment_1'] . ">&lt;/td>&lt;/tr>";
echo '&lt;/td><td align="center">';
echo '&lt;/td>&lt;/tr>&lt;/table>';
echo '&lt;input type=submit value="Click To update">';
echo '&lt;/form>';
echo '&lt;/body>';
echo '&lt;/html>';
mysql_close($dbconnect);


Your echo statements from the database do not have any quotes around the $rows from the database. Also you should escape values coming from the database

change lines like

echo "<input type=text value=" . $rows['comment_1'] . "></td></tr>";

to

echo "<input type=text value=\"" . htmlspecialchars($rows['comment_1']) . "\"></td></tr>";
0

精彩评论

暂无评论...
验证码 换一张
取 消