[請益] 我的判斷式有啥問題阿??

看板PHP作者 (ROLL)時間17年前 (2009/02/03 00:40), 編輯推噓3(302)
留言5則, 3人參與, 最新討論串1/1
<? @session_start(); require("connect.php"); $current_pid = $_POST[current_pid]; $start = $_POST[start]; $end = $_POST[end]; $uid = $_SESSION["id"]; $str1 = "select * from WeekReport where wrstart = '$start' and wrend = '$end'"; $result1 = mysql_query($str1); echo mysql_num_rows($result1); ?> <html xmlns="" rel="nofollow">http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>產生週報</title> <link rel="stylesheet" href="table.css" type="text/css" /> <link rel="stylesheet" type="text/css" href="project_menu.css" /> <script type="text/javascript"> function generate_id() { var d=new Date(); var r="W"+d.getYear(); r+=d.getMonth()+1 < 10 ? "0"+(d.getMonth()+1) : (d.getMonth()+1); r+=d.getDate() < 10 ? "0"+d.getDate() : d.getDate(); r+=d.getHours() < 10 ? "0"+d.getHours() : d.getHours(); r+=d.getMinutes() < 10 ? "0"+d.getMinutes() : d.getMinutes(); document.getElementById('wid').value = r; document.getElementById('w_date').value = d.getYear() + "-" + ( d.getMonth()+1 < 10 ? "0"+d.getMonth()+1 : d.getMonth()+1) + "-" + (d.getDate() < 10 ? "0"+d.getDate() : d.getDate()); } function check() { if(window.confirm("確定要產生週報?")) { window.myform.submit(); } } </script> </head> <body onload="generate_id()"> <div id="masthead"> <img src="pic\Title.gif" alt="成大馬達中心" width="856" height="64" /></div> <div id="container"> <div id="left_col"> <? include("project_menu_bar.php"); ?> </div> <div id="page_content"> <? if(mysql_num_rows($result1) != 0) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ { echo "該週報已經產生過了"; } else { /*$str2 = "select r.rid,r.date,r.start,r.end,p.pid,p.name,u.name as username,r.status from Record r,Project p,User u,PvsR pr,UserProject up where p.pid=pr.pid and r.rid=pr.rid and p.pid=up.CPJID and u.uid=up.CUID and u.uid='$uid' and r.date between '$start' and '$end' and p.pid='$current_pid' order by r.rid DESC";*/ $str = "select r.rid,r.date,r.start,r.end,u.name as writer,r.status,r.content from Record r,PvsR pr,Project p,User u where r.rid = pr.rid and p.pid = pr.pid and r.CUID = u.uid and p.pid = '$current_pid' and r.CUID = '$uid' and r.submit=0 and r.date between '$start' and '$end' order by r.rid DESC"; $result = mysql_query($str); ?> <form name="myform" method="post" action="generate_week_report.php" style="height: 280px"> <fieldset name="Group1" style="height: 198px"> <legend>搜尋結果</legend> <input name="current_pid" type="hidden" value="<? echo $current_pid;?>"> <input id="wid" name="wid" type="text"> <input id="w_date" name="date" type="text"> <table class="datatable"> <tr> <th>呈閱</th> <th>紀錄編號</th> <th>紀錄日期</th> <th>工作時程</th> <th>工作內容</th> <th>填寫者</th> <th>狀態</th> </tr> <? $i=1; while($row = mysql_fetch_object($result)) { echo "<tr>"; echo "<td><input name=\"submit[$i]\" type=\"checkbox\" value=\"1\"/></td>"; echo "<td>"; echo $row->rid; echo "<input name=\"rid[$i]\" type=\"hidden\" value=\"$row->rid\">"; echo "</td>"; echo "<td>"; echo $row->date; echo "</td>"; echo "<td>"; echo $row->start."~".$row->end; echo "</td>"; echo "<td>"; echo $row->content; echo "</td>"; echo "<td>"; echo $row->writer; echo "</td>"; echo "<td>"; if($row->status == 1) echo " 簽核 "; else if($row->status == 2) echo " 提交 "; else if($row->status == 3) echo " 私人 "; else echo " 重提 "; echo "</td>"; $i += 1; echo "</tr>"; } $i = $i - 1; echo "<input name=\"sum\" type=\"text\" value=\"$i\">"; echo "<input name=\"start\" type=\"text\" value=\"$start\">"; echo "<input name=\"end\" type=\"text\" value=\"$end\">"; ?> </table> <p style="text-align: center"> <input onclick="check()" name="submit1" type="button" value="產生週報" style="color: #0000FF; background-color: #FFFF00" /></p> </fieldset> </form> <? } ?> </div> </div> 為什麼我想要檢查改筆資料的報告是否產生過了,檢查的方法是比對開始和結束日期 但是不管檢查的結果是0還是1,都是顯示週報已產生過的結果??為什麼啊?? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 203.70.75.252

02/03 01:29, , 1F
中間有藏了幾個include,該不會名稱有重疊?
02/03 01:29, 1F

02/03 01:30, , 2F
include("project_menu_bar.php"); 這個看看
02/03 01:30, 2F

02/03 01:30, , 3F
問題出在SQL嗎?
02/03 01:30, 3F

02/03 01:32, , 4F
比對的前一行再印一次echo 看看~
02/03 01:32, 4F

02/10 23:24, , 5F
謝謝一樓,解決了~~果然名稱有重疊~= =
02/10 23:24, 5F
文章代碼(AID): #19Xo81n3 (PHP)
文章代碼(AID): #19Xo81n3 (PHP)