2012-04-29 2 views
-4

예를 들어 특정 테이블의 기사가 7 일을 경과 한 다음 페이지에 알림 창이 표시되면 이전 기사를 업데이트해야하는 웹 페이지가 표시됩니다.동일한 디자인의 여러 테이블에서 값을 확인하려면 어떻게합니까?

날짜를 여러 번 확인하려면 어떻게해야합니까? 테이블?

$sql = "select topic.* 
      , id.* 
     from $table_1 
      , $table2 
     where (date of the article) < (<date of the article+ 7 days...>)" ; 
     // the arctile has passed 7 days 
$rs  = mysql_query($sql); 
$nos = mysql_num_rows($rs); 
$obj = mysql_fetch_object($rs); 
if($row = mysql_fetch_array($sql)) 
{ 
    // I want to display window that display note 
    // there is artiles need to be updated and list of those topics" 
    <script language="javascript" type="text/javascript"> 
     function print_msg(opt,id) 
     { 
      if(confirm("show old topics")) 
      { 
       window.location="home.php"; 
      } 
      else 
      { 
       return false; 
      } 
     } 
    </script> 
    //here are the topics need to be updated   
    echo obj->topic; 
} 
+1

우선 SQL에 " – riso

+0

"이 누락되었습니다. 둘째, 질문이 명확하지 않으며 코드가 아닙니다. –

+0

수정하려고 시도합니다. – Iman25

답변

0

나는 당신이 두 테이블의 행을 가입 UNION ALL를 사용하는 것 같아요. 행을 결합한 후 파생 테이블 출력에서 ​​SELECT를 수행하여 날짜 조건을 점검 할 수 있습니다. 다음은 SQL 쿼리입니다. PHP 구문에 대해서는 잘 모릅니다.

당신이 두 테이블 사이에 별개의 행을 가져 UNION 모든에 UNION을 변경하려면

.

쿼리 : MySQL의이 줄에있는 것. 상기 쿼리

SELECT id, topic, date 
FROM 
(
    SELECT id, topic, date FROM table1 
    UNION ALL 
    SELECT id, topic, date FROM table1 
) T1 
WHERE DATEDIFF(date, DATE(NOW())) <= 7 

T1 파생 테이블 출력 별명을 나타낸다.

+0

7 일 또는 몇 초 또는 년? 다른 아이디어 – Iman25

관련 문제