簡體   English   中英

如何使用php保存表格中的顏色更改

[英]how to save colour changes in table using php

如何將顏色保存到數據庫中? 這是我的編碼。.我可以更改表格顏色,但是不能保存到數據庫中。 當我再次打開它時,顏色將恢復正常。

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>

<body>
<html>
<title>Test</title>
<head>
<script type="text/javascript">
function colourRow1(rowNumber) {
    //some code to change the colour of the row indicated by the number
    alert("change row 1 background colour");

    var tr = document.getElementById('table1')
                 .getElementsByTagName('tr')[rowNumber-1];
    tr.style.backgroundColor = 'blue';


}
</script>
</head>
<body>
<table name="table1" id="table1" border="1">
<thead>
<th>heading1</th>
<th>heading2</th>
<th>heading3</th>
</thead>
<tbody>
<tr id="row1">
<td>1,1</td>
<td>1,2</td>
<td>1,3</td>
</tr>
<tr id="row2">
<td>2,1</td>
<td>2,2</td>
<td>2,3</td>
</tr>
<tr id="row3">
<td>3,1</td>
<td>3,2</td>
<td>3,3</td>
</tr>
</tbody>
</table>
<button type="button"  onClick="colourRow1(1)" action="colourupdate.php">Change Row 1</button>
</body>
</html>

如何將顏色保存到數據庫中? 這是我的編碼。.我可以更改表格顏色,但是不能保存到數據庫中。 當我再次打開它時,顏色將恢復正常。

您需要維護另一個表來存儲顏色歷史記錄。

id | rowno | color

您需要使用ajax調用存儲每個按鈕單擊的行號和顏色。

另一種方法是將行ID和顏色存儲為特定時間段內的會話。

$_SEESION['rowid']=$value;
$_SEESION['rowid']=$color;

暫無
暫無

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

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