Jump to content

Putting fields into an array


apot

Recommended Posts

im trying to get this function to work.

 

function get_fields()
{
$result = mysql_db_query($db,"SHOW FIELDS FROM product_type_prices");

$rows = array();

while ($row = mysql_fetch_assoc($result))
	{
	if ($row["Extra"] == "auto_increment") continue;

	$this_row = $row;

	if (stripos($row["Type"], "char") !== false)
		{
		$this_row["Type"] = "char";
		}
	else if (stripos($row["Type"], "date") !== false)
		{
		$this_row["Type"] = "date";
		} 
	else if (stripos($row["Type"], "int") !== false) 
		{
		$this_row["Type"] = "int";
		}
	else if (stripos($row["Type"], "dec") !== false) 
		{
		$this_row["Type"] = "dec";
		}
	$rows[$row["Field"]] = $this_row;
	}

return $rows;
}

$fields = get_fields();

echo "<PRE>";
var_dump($fields);
echo "</PRE>";

 

It works when it is not in a function but when in a function returns:

 

array(0) {

}

 

Any idea what is happening here?

Link to comment
https://forums.phpfreaks.com/topic/71402-putting-fields-into-an-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.