How to loop when calling the function?

function get_jd_table(){		
					$result = $GLOBALS['conn']->query('SELECT * FROM jdhtmlcontroller');
				catch (PDOException $e)
					echo 'Error fetching data from the database!';
				$val = $result->fetchAll();

// calling function 

I want to loop through the data that is stored in $val variable. any idea anyone?

Hi joeboo,

How about something like this:

$rows = get_jd_table();

foreach ($rows as $row) {
    // Output your table rows here, or whatever..

Why didn’t I think of that! lol. thanks, it works now! :smiley: