I want to create a form which is populated with the users details taken from an SQL query suing SQL Server and PHP.
Here is my query:
$result2 = sqlsrv_query( $conn, $query, array(), array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
if( $result2 === false)
{
echo "Error in query preparation/execution.\
";
die( print_r( sqlsrv_errors(), true));
}
while( $row = sqlsrv_fetch_array ( $result2, SQLSRV_FETCH_ASSOC))
{
echo '<p id="productsContent">'.$row['firstname'];
echo '<br/>'.$row['surname'];
echo '<br/>'.$row['email'];
echo '<br/>'.$row['address'];
echo '<br/><br/><a href="products.php?productID='.$row['productID'].'"><img id="searchimage" src="' . $row['picture'] .'" /></a>';
echo '<br/><br/><p/>';
}
Here is what I am trying to do with my form:
<label class="mandatory">*First name :</label>
<input type="text" name="fName" id="fname" <?php echo'value="'.$row['firstname'].'"'; ?> onfocus="value=''" onblur="if (this.value=='') this.value=this.defaultValue"/><br />
But when I run page the form inputs are empty, so I tried many different things trying to assign $row results to variables and use them instead but it didn’t work, can anyone tell me where I am going wrong with this please?
Many thanks!