簡體   English   中英

分頁腳本-從兩個表中獲取數據

[英]Pagination script - getting data from two tables

我有一個分頁腳本,可以在這里查看: http : //www.automotori6282.tk/phpsandbox/

這是源代碼:

http://pastebin.com/raw.php?i=63dCvfxD(PmcPagination.php

http://pastebin.com/raw.php?i=3k4nqwRB(demo.php ,其中包含代碼的頁面)

http://www.automotori6282.tk/phpsandbox/的 index.php只是使用PHP的include()函數顯示demo.php

我想做的是從兩個表中分頁。

這是我當前的數據庫結構:


programme   varchar(255)    
channel     varchar(255)    
episode     varchar(255)
series  varchar(255)            
setreminder     varchar(255)    

但是,我將情節存儲在單獨的表中,並且想進行查詢,該查詢從epdata167和情節表中提取(情節表僅具有情節,系列編號,情節編號和描述作為其字段)。

我在分頁腳本中犯的一個錯誤顯示在這里:

TV Show showing on Channel 1 August 3rd - 12:30pm "" Set Reminder
TV Show showing on Channel 1 August 3rd - 8:30pm "Episode 1" Set Reminder

事件發生后仍然很久。

這是應該如何工作的:

 TV Show showing on Channel 1 August 3rd - 12:30pm  
 TV Show showing on Channel 1 August 3rd - 2:45pm Set Reminder
TV Show showing on Channel 1 August 3rd - 8:30pm "Episode 1" Set Reminder

請注意,事件發生時“設置提醒”字段如何不顯示,並且如果未選擇劇集,則不會帶引號。

(setreminder字段基本上是一個鏈接,用戶可以單擊該鏈接向用戶發送提醒,說“電視節目在8月3日第1頻道播出-第1集:8:30pm”或“電視節目今天在8:30 pm播出。 1“。但是,當前正在播放的節目不會顯示,它將顯示為:

    TV Show showing on Channel 1 August 3rd - 12:30pm 

這是導致麻煩的分頁代碼:

$ result = mysql_query(“ SELECT程序,頻道,廣播,到期,情節,系列,setreminder from epdata167,其中airdate> curdate()GROUP by airdate”);

這是我為嘗試使用ifelse語句而編輯的分頁代碼的一部分,但不確定該怎么做:

class paginationData {
private $program;
private $channel;
private $airdate;
private $exiration;
private $episode;
private $series;
private $setReminder;

public function __construct($program, $channel, $airdate, $expiration, $episode, $setReminder)
{
    $this->program = $program;
    $this->channel = $channel;
  $this->airdate = strtotime($airdate);
    $this->expiration = $expiration;
    $this->episode = $episode;
    $this->setReminder = $setReminder;
}

//This function shows the data
public function display()
{
    if(date('Y-m-d') == date('Y-m-d', $this->airdate)) $dateFormat = 'g:ia';
    elseif(date('Y') == date('Y', $this->airdate)) $dateFormat = 'F jS - g:ia';
    else $dateFormat = 'F jS, Y - g:ia';

    echo '<tr>'."\n".
         '  <td><strong>'.$this->program.'</strong></td>'."\n".
         '  <td>showing on '.$this->channel.'</td>'."\n".
         '  <td>'.date($dateFormat, $this->airdate).'</td>'."\n".
         '  <td><b>"'.$this->episode.'"</b><br></td>'. "\n".
         '  <td>'.$this->setReminder.'</td>'."\n".
         '</tr>'."\n";
}

}

基本上,我在嘗試在項目中嘗試獲取數據時遇到了麻煩:

     TV Show showing on Channel 1 August 3rd - 12:30pm  
 TV Show showing on Channel 1 August 3rd - 2:45pm Set Reminder
TV Show showing on Channel 1 August 3rd - 8:30pm "Episode 1"
                                                  Series 1, episode 1 Set Reminder

(如果情節是具有編號的系列的一部分)

不確定使用什么JOIN以及在何處使用,因為我已使分頁生效,因此為使此工作正常進行,我們將不勝感激; 只是試圖使更好的細節起作用!

我不是在要求別人為我做,我一直在學習自己,並且已經完成了研究。

抱歉,這似乎有點長,但是我希望我已經解釋了所有這一切。

謝謝。

您需要使用UNION才能使其正常工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM