這裏是我的功能爲什麼我的函數沒有返回任何東西?
function get_products($business_id){
$sql = "SELECT
b.*, b.name as business_name, p.builder_id,
bs.*, p.price, p.name as product_name, p.description, p.image, p.per_station, p.skip_screen
FROM
builder_product bp
JOIN builder_step bs ON bp.builder_step_id = bs.builder_step_id
JOIN builder b ON bp.builder_id = b.builder_id
WHERE b.business_id = '{$business_id}'
ORDER by b.step_number, b.price";
$result = mysql_query($sql);
$steps = array();
while($row_r = mysql_fetch_assoc($result)){
$steps["all_steps"]['business_id'] = $business_id;
$steps["business_name"] = $row_r['business_name'];
$steps["builder_id"] = $row_r['builder_id'];
if (count($steps) == 0) {
$business_id = 59;
get_products($business_id);
}else{
$steps["business_id"] = $business_id;
return $steps;
}
}
這裏是調用函數
$products = get_products($_GET['business_id']);
爲什麼我沒有得到這個函數返回....我之前做的print_r權返回,我有我的數組噸噸的數據,但如果我做一個print_r調用這個函數下面,我什麼也得不到。我做一個遞歸調用,以確保我有一個返回數組...我很想念
* sigh * http://bobby-tables.com/ – Quentin 2011-12-14 15:05:03
在`else`情況下只有`return`語句。如果你不輸入`else`的情況下,你將不會返回一個值。 – 2011-12-14 15:05:24
我輸入其他...我正在做一個print_r之前返回,我得到的數組 – Trace 2011-12-14 15:06:57