繁体   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