2011-06-05 96 views
1

我想作一個簡單的計劃: enter image description here 我沒有這樣的事:簡單的計劃 - 架構數據庫

 
CREATE TABLE IF NOT EXISTS `plan` (
    `id` int(20) NOT NULL AUTO_INCREMENT, 
    `a` varchar(25) NOT NULL, 
    `b` varchar(25) NOT NULL, 
    `c` varchar(25) NOT NULL, 
    `d` varchar(25) NOT NULL, 
    `e` varchar(25) NOT NULL, 
    PRIMARY KEY (`id`) 
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; 

,但它不工作也很好......

祝每個單元在TD中都有唯一的ID。

現在是:

 

    foreach($rows as $row) 
    { 
      
      id(); ?>>id() ?> 
      id(); ?>>A() ?> 
      id(); ?>>B() ?> 
      id(); ?>>C() ?> 
      id(); ?>>D() ?> 
      id(); ?>>E() ?> 
      
    } 

,現在我不能指單個TD。我會像編輯例如只編號:20。

如何最好的計劃數據庫?

感謝您的幫助!

回答

1

每個單元/ <td>不需要一個ID。正如你在數據庫模式中所做的那樣,將ID放在行/ <tr>上。

之後,它應該是一項簡單的任務,以確定每行不同的列。

數據庫:

| id | a | b | c | d | e | 
-------------------------- 
| 1 | t | t | t | t | t | 

的HTML:

<table> 
    <tr> 
     <th>id</th> 
     <th>a</th> 
     <th>b</th> 
     <th>c</th> 
     <th>d</th> 
     <th>e</th> 
    </tr> 
    <tr class="id-1"> 
     <td class="id">1</td> 
     <td class="a">t</td> 
     <td class="b">t</td> 
     <td class="c">t</td> 
     <td class="d">t</td> 
     <td class="e">t</td> 
    </tr> 
    <tr class="id-2"> 
     <td class="id">2</td> 
     <td class="a">u</td> 
     <td class="b">u</td> 
     <td class="c">u</td> 
     <td class="d">u</td> 
     <td class="e">u</td> 
    </tr> 
</table> 

還是我誤解你;)

+0

感謝,但現在:

 id | a | b | c | d | e ----------------------- 1 | t | t | t | t | t 2 | t | t | t | t | t 
例如:1A == 2A, 1e == 2e,所以我不能編輯只有2e,但是然後編輯1e – andanosy 2011-06-05 15:44:49

+0

對不起,做了一些編輯。有什麼問題?您的評論看起來剪輯。例如# – Znarkus 2011-06-05 15:46:09

+0

在css中編輯#id_2e {background-color:red}; – andanosy 2011-06-05 15:49:02