Having a hard time with OOP php

I'm having a hard time understanding OOP, I do not know what's wrong with this code.

basically I just need to select all the os_id from the database. this is the solution i came up and

public function select_all_users($fields, $table){
    $query = mysql_query("select {$fields} FROM {$table}");
    while($row = mysql_fetch_array($query)){
        $result[] = $row['os_id'] ;
    }
    return $result;

}

and technically this is how I would display it

require_once 'global/db.php'; 
$db = new Database();
$results = $db->select_all_users("*", "os_inventory"); 
echo "<td>". $results . "</td>";

Answers


Variable $results is array and you use echo!. Use foreach like:

require_once 'global/db.php'; 
$db = new Database();
$results = $db->select_all_users("*", "os_inventory"); 
foreach($results as $temp)
    echo "<td>". $temp[0] . "</td>";

Need Your Help

Passing Parameter To Bash Shell Script Through Input Redirection (<)

linux bash shell

So, I need to write a shell script that accepts a file path as an argument and uses it within the shell script. I know that I could do something like:

pop a specific view controller

iphone cocoa-touch uinavigationcontroller

I have an hierarchy of 3 view controllers in my navigation bar controller: view1->view2->view3. After the user finished with view3 I want to take him to view1. What is the best approach to do that?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.