public function selectResultByThird() { if ((!empty ($_REQUEST["bigname"])) && (!empty ($_REQUEST["secondname"])) && (!empty ($_REQUEST["thirdname"])) && (!empty ($_REQUEST["fourname"])) && (!empty ($_REQUEST["fivename"]))) { $bigid = $_REQUEST["bigname"]; $secondid = $_REQUEST["secondname"]; //从页面取得提交的二类 $thirdname = $_REQUEST["thirdname"]; //从页面取得提交的三类 $fourname = $_REQUEST["fourname"]; //从页面取得提交的四类 $fivename = $_REQUEST["fivename"]; //从页面取得提交的五类 $start = ($_REQUEST["start"] = '') ? $_REQUEST["start"] : 0; //处理分页用到的变量 $limit = ($_REQUEST["limit"] = '') ? $_REQUEST["limit"] : 3; $count_sql = "SELECT * FROM `protein` WHERE expression_system_plant LIKE " . "'$secondid'" . "and protein_name LIKE " . "'$bigid'" . "and country LIKE " . "'$thirdname'" . "and commercialization_process like " . "'$fourname'"."and time like "."'$fivename'"; $count = mysql_query($count_sql); $arr = mysql_fetch_object($count); return $arr; } }
向页面展示时候,这里用到的是mysql_fetch_object即是对象。我们接下来在控制层对这个对象进行封装进一个二维数组中,这样我们在页面中就很容易的取值。
1 $data['all'][] = $this->selectInfo_model->selectResultByThird();2 // print_r($data);3 $this->load->view('outside/achievement/information_result',$data);
页面中该怎样输出呢?好吧 ,我们想到的是foreach输出
1 2 3 code_number ?> 4 protein_name?> 5 expression_system_plant?> 6 country?> 7 commercialization_process?> 8 time?> 9 10
现在让我们看看,我们的二维数组到底是什么样的吧,下面是使用啦print_r输出的二维数组
1 Array 2 ( 3 [all] => Array 4 ( 5 [0] => stdClass Object 6 ( 7 [p_id] => 19 8 [code_number] => 1001 9 [protein_name] => 重组人乳铁蛋白10 [english_name] => Recombinant human lactoferrin (rhLF)11 [country] => 美国12 [commercialization_process] => 上市13 [time] => 200814 [expression_system_plant] => 水稻15 [development_team] => Ventria Bioscience16 [transgene] => hLF(codon-optimized HLF gene)人工合成413/62917 [vector] => pAPI164,ExpressTecTM18 [promoter] => 水稻胚乳特异性谷蛋白(GT1)19 [terminator] => NOS20 [expression_sites] => 种子21 [expression] => 25%总溶解蛋白;0.5%总谷物22 [no_glycosylation] => 是(植物模式的糖基化,多木糖缺唾液酸)23 [toxicity] => 无毒24 [median_lethal_dose_LD50] => >>1000mg/kg(估算)25 [no_toxicity_concentration_NOAEL] => 1000mg/kg26 [acceptable_daily_intake_ADI] => 10mg/kg(估算)27 [sensitization] => 有潜在致敏性
是不是对php的数据库操作用加深印象啦呢??哈哈