Is it possible to get those values inside of function and use those outside of function here is my code:
You need to "return" the value. See the entry in the PHP manual for this. Basically, return means "exit this function now". Optionally, you can also provide some data that the function can return.
Just use the return statement:
$value) {
if ($value > 0) {
if (substr($name, 0, 5) == 'cart_') {
$id = substr($name, 5, (strlen($name) - 5));
$get = mysql_query('SELECT id, name, price FROM products WHERE id=' . mysql_real_escape_string((int)$id));
while ($get_row = mysql_fetch_assoc($get)) {
$sub = $get_row['price'] * $value;
echo $get_row['name'] . ' x ' . $value . ' @ £' . number_format($get_row['price'], 2) . ' = £' . number_format($sub, 2) . '[-] [+] [Delete]
';
}
}
$total += $sub;
}
}
return $total;
}
?>