Hi guys
I have a class which im working on as a personal improvement project to try to understand classes better. π
I know theres mysqli which i have been told you can do pre-determined statements on. But this is just a project for me to get a better understanding of classes and how certain things would be done in them
My method/function
function retrieveallrows($table){
$this->generatedsql = "SELECT * FROM `".$table."`";
$this->query = mysql_query($this->generatedsql);
while($this->result = mysql_fetch_array($this->query)){
$this->returnarray();
}
}
and the return array method
function returnarray(){
return( $this->result);
}
I understand that return will end the method retrieveallrows as soon as the return is executed.
And no results will be displayed.
The page i am calling this class from is
$new = new connection;
$new->retrieveallrows("users");
And now the tricky part lol or i think so...
I have a dropdown on the same page and im trying to fill it with the value of id and displayed value of username
These are columns 0 and 1 in the table.
So $this->result[0]; would be the user id
and $this->result[1]; would be the username
The Dropdown Menu
<select name="users">
<option>Please select a user</option>
<?php
echo "<option value = '$new->returnarray([0])'>$new->returnarray([1])</option>";
?>
</select>
Is this possible or is retrieving multiple arrays and being able to reference the values inside that array in an external page?
Many Thanks to all who reply
Pink. π