i want to show user specific data in html form(in text fields or in select list)
I have a function ShowUserInformation() in class MyClass:
function ShowUserInformation()
{
$query = "SELECT id, name, email FROM saloni WHERE id = '$_SESSION[ID_korisnika]'";
$result = mysql_query($query);
while($row=mysql_fetch_array($result)):
$id= $row['id'];
$name= $row['name'];
$email = $row['email'];
$address= $row['address'];
$address2= $row['address2'];
$address3= $row['address3'];
endwhile;
return $result;
}
My question is: How can i display value of $name, or $email, $id… on another page in text box or in select list?
If i do it in procedural way it works when i do this:
<input type="text" value="<?php echo $name ?>" name="name" class="" />
But, how can i display the $name,$email,$ID… in oop way? Is there a way to call it directly and not declare it as class variable and then call it.
i’ve included file, created object…
$my_class = new MyClass; //create an object of class
HTML – i’ve tried something like this…
<input type="text" value="<?php echo $my_class->ShowUserInformation($name)?>" name="name" class="" />
I’m new in PHP and oop so be easy with me 🙂
Thank you
If you only plan on one row being returned, then why not use mysql_fetch_assoc()
Note: mysql_* functions are deprecated, and you should move to use MySQLi or PDO