Saturday, 24 August 2013

PHP function to fetch data as arrays and display

PHP function to fetch data as arrays and display

I came up with this piece of code from others work to gather data from
database and display it the simplest and safest way without loop. However
it doesn't really work and I would like to know why? So my main question
is how to make it work? And the 2:nth how to make it as secure as
possible?
Code to display data:
<?php echo webdata("web_name"); ?>
Code for function:
function webdata($data)
{
$data = array();
$func_num_args = func_num_args();
$func_get_args = func_get_args();
global $db_connect;
if ($func_num_args > 1) {
unset($func_get_args[0]);
$query = "SELECT * FROM `settings`";
$result = $db_connect->query($query);
while ($webdata = $result->fetch_assoc()) { return ($data); }
}
}

No comments:

Post a Comment