这是我的表
tag enabled
bank 1
WT 1
Credit 1
Debit 1
EMI 1
我的查询是:
$sql = "SELECT * FROM payment WHERE enabled = '1'";
$result = mysql_query($sql);
while($data = mysql_fetch_assoc($result)) {
$gateway='';
if($data['tag']=='credit') {
$gateway='/'.getPaymentGateway($data['gateway'],'tag');
}
include('payment/'.$data['tag'].$gateway.'/display.php');
...
}
问题是,它显示直到信用,没有显示借记和EMI 这是因为,信用证有子文件夹。
函数getPaymentGateway
是:
function getPaymentGateway($id,$field) {
$sql = "SELECT * FROM payment_gateway WHERE id = '".$id."'";
$result = mysql_query($sql);
$data = mysql_fetch_assoc($result);
return $data[$field];
}
答案 0 :(得分:0)
你不需要做关联,你没有加入任何表格保持简单。
if(!$result){
// error with query
return mysql_error();
}else{
while($data = mysql_fetch_array($result)){
$gateway='';
if($data['tag']=='credit') $gateway='/'.getPaymentGateway($data['gateway'],'tag');
include('payment/'.$data['tag'].$gateway.'/display.php');
}
}