Hi there,
i am trying to use the classes proplery and i have a basic question....The following is the class i am using in order to get information from the DB...It is workinkg and i dont have any problem. But the question is how do i show the information on a form based on the data i got from the class?
file name: user.class.php
class User
{
function __construct()
{
}
public function getRecord($var)
{
try
{
/*** query ***/
$sql = " SELECT * FROM users WHERE userID= :id ";
/*** prepare the select statement ***/
$rs = db::getInstance()->prepare($sql);
/*** bind the parameters ***/
$rs->bindParam(':id' , $var);
/*** execute the prepared statement ***/
$rs->execute();
/*** Save result in $result ***/
$result = $rs->fetch(PDO::FETCH_ASSOC);
return $result;
}
catch (PDOException $e)
{
print $e->getMessage();
}
}
}//close class
on the web form i do this:
$User =new User();
$User->getRecord($_GET[userid]);
i know that i could do the following and it will work, but i am not sure if it;s the best way to do it:
$User =new User();
$Row = $User->getRecord($_GET[userid]);
<input name="first_name" type="text" id="first_name" value="<?=$Row['first_name']?>" />
I just want to do it right....