duanmianhong4893 2016-10-13 04:21
浏览 29

从数据库中获取记录模式

I have a table like this in my database.

|   id   |   yes_answer   |   no_answer  |
|   a01  |      a05       |     a04      |
|   a03  |      a16       |     a32      |
|   a04  |      c01       |     a05      |
|   a05  |      a06       |     c06      |
|   a06  |      a08       |     a09      |
|   a08  |      c03       |     a09      |
|   a09  |      a03       |              |
|   a16  |      a33       |     a02      |
|   a32  |      c04       |     a16      |
|   a33  |      c05       |              |

As An Explanation :
1.id column represent an id of question. it is linked to another table on my database.
2.yes_answer column represent the next question (like a01) or conclusion (like c04) you get when you answer the question represented by id column with yes or TRUE or 1 value. 3.no_answer is generally the same as yes_answer column except that you get it when you answer question represented by id column with no, FALSE, 0 value. 4. Every id, yes_answer, no_answer is connected each other. The Result is A Pattern. When you Want to find a path that lead to answer c01 it will be like c05 -> a33,a16,a32,a03,a09,a06,a05,a01.

And Here I am Trying To Bactrack The Pattern From answer column that marked with c like c01 or c02 like above. And I've been able to bactrack only the beginning value of it Like (c05 -> a33) and the rest is blank.

Here is My Code

$sqlQueryYes="SELECT * FROM tbl_path_inference WHERE yes_answer='c05'";
$execQueryYes=mysql_query($sqlQueryYes);<br />
$queryStatus=mysql_num_rows($execQueyYes); //Getting Query Status<br />
if($queryStatus == 1) {
    $getDataYes=mysql_fetch_array($execQueryYes);
    $ansPath=$ansPath." ".$getDataYes['id'];
} else { // if cant find answer on column yes_answer try on no_answer
    $sqlQueryNo="SELECT * FROM tbl_path_inference WHERE no_answer='c05'";
    $execQueryNo=mysql_query($sqlQueryNo);
    $getDataNo=mysql_fetch_array($execQueryNo);
    $ansPath=$ansPath." ".$getDataNo;
}

Anyone Have Solution On It. Im Still working It Now.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
    • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
    • ¥50 需求一个up主付费课程
    • ¥20 模型在y分布之外的数据上预测能力不好如何解决