Define a SQL query to call on
Say I have the following php code:
$sql = "SELECT firstname FROM contact WHERE '{$_REQUEST['userid']}' = contactid";
$rs = $conn->Execute($sql);
if (!$rs) {
print $conn->ErrorMsg();
}
else {
while (!$rs->EOF) {
print $rs->fields[0].'<br>';
$rs->MoveNext(); // Moves to the next row
}}
Which works well, 开发者_JAVA百科however, how can I define that scrip/code to have the following in my form:
<p>First Name: <?php $whatever_it_can_be ?></p>
else {
if (!$rs->EOF) {
$firstname = $rs->fields[0];
} else {
// user id is invalid
}
}
Then in the page:
<p>First Name: <?php echo $firstname; ?></p>
精彩评论