我在PHP中显示表时遇到问题。我已经安装了shortcode exec php插件。
这是我所做的代码:
if(mysql_num_rows($raw_results) > 0){
while($results = mysql_fetch_array($raw_results)){
echo "<p><h3>".$results['id']."</h3>"."Student Name :".$results['name']." </p>" . "</br>";
echo "Age : ".$results['age']." Years old.</br>";
echo "Course : ".$results['course']."</br>";
echo "Gender : ".$results['gender']."</br></br>";
echo "<HR>";
}
}
我可以知道如何在表格中对数据进行排序吗?我尝试的任何表格代码似乎都没有显示..
答案 0 :(得分:2)
<table>
<tr>
<td>Student name</td>
<td>Age</td>
<td>Course</td>
<td>Gender</td>
</tr>
<?php
if(mysql_num_rows($raw_results) > 0){
while($results = mysql_fetch_array($raw_results)){
echo "<tr><td>".$results['id']."</td>";
echo "<td>".$results['age']."</td>";
echo "<td>".$results['course']."</td>";
echo "<td>".$results['gender']."</td></tr>";
}
}
?>
</table>
答案 1 :(得分:0)
简单地回显html表标签,如下所示:
echo "<table border='1'>
<tr>
<th>Id</th>
<th>Age</th>
<th>Course</th>
<th>Gender</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['course'] . "</td>";
echo "<td>" . $row['age'] . "</td>";
echo "</tr>";
}
echo "</table>";
答案 2 :(得分:0)
<table>
<tr>
<th>ID</th>
<th>Student Name</th>
<th>Age</th>
<th>Course</th>
<th>Gender</th>
</tr>
while($results = mysql_fetch_array($raw_results)){
echo "<tr>";
echo "<td>".$results['id']."</td>";
echo "<td>".$results['name']."</td>";
echo "<td>".$results['age']." Years old.</td>";
echo "<td>".$results['course']."</td>";
echo "<td>".$results['gender']."</td>";
echo "</tr>";
}
echo "</table>";
答案 3 :(得分:0)
您需要连接数据库,然后将数据提取到数据库
function onSubmit(e){
var sheet = e.range.getSheet();
var ss = sheet.getParent();
var form = FormApp.openByUrl(ss.getFormUrl());
// Choose destination sheet according to Select the worker:
var destSheet = getSheet(ss, e.namedValues['Select The Worker:']);
// Store the current response in destination sheet
destSheet.appendRow(e.values);
/**
* Get the sheet with given name. Create sheet if it doesn't exist.
* New sheet will be created with optional headings, if provided.
*
* From:
*
* @param {Spreadsheet} spreadsheet Google Spreadsheet object.
* @param {String} sheetName Sheet name to get.
* @param {String[]} headings Optional array of headings (for new sheet).
*
* @returns {Sheet} Sheet object.
*/
function getSheet( spreadsheet, sheetName, headings ) {
spreadsheet = SpreadsheetApp.getActive();
var sheet = spreadsheet.getSheetByName(sheetName);
if (sheet == null) {
// Not found, so add new sheet
sheet = spreadsheet.insertSheet(sheetName);
if (headings && headings.constructor === Array) {
sheet.getRange(1,1,1,headings.length).setValues([headings]);
}
}
return sheet;
}
}