gpt4 book ai didi

php - 无法将类分配给用于 sql 选择/更新的表

转载 作者:太空宇宙 更新时间:2023-11-04 11:05:09 25 4
gpt4 key购买 nike

我正在运行一个查询,该查询输出到我用来更新记录的表。由于我正在使用侧边栏,该表对于我的页面来说太大了。我试着给它分配一个类,然后使用 CSS 调整它的大小,使其适合我想要的位置,但我收到了这个错误:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in...

我在我的网页的其他地方使用了一个类似的类,它运行良好。任何帮助修复它的帮助将不胜感激。这是代码:

<!DOCTYPE HTML>
<html lang = "en">
<head>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<title>Tech Order Department.html</title>
<meta charset = "UTF-8" />

<style>

div {
text-align: justify;
}

.section {
margin-left: auto;
margin-right: auto;
width: 70%;
}
</style>


</head>

<body>

<nav>

<h1>Yulista</h1>
<br>
<h2>Explore</h2>
<ul>
<br>

<form>
<INPUT Type="BUTTON" Value="Home Page" Onclick="window.location.href='http://www.oldgamer60.com/Project/sidebar.php'">
</form>

<form>
<p><b>Project Status<br/></b>
<select name="select" onChange="window.open(this.options[this.selectedIndex].value,'_self')">
<option value="">Select one</option>
<option value="http://www.oldgamer60.com/Project/CurrentProjects.php">Current Projects</option>
<option value="http://www.oldgamer60.com/Project/ProjectsInFinalReview.php">In Final Review</option>
<option value="http://www.oldgamer60.com/Project/DeliveredProjects.php">Delivered</option>
<option value="http://www.oldgamer60.com/Project/CompletedProjects.php">Completed Projects</option>
</select>
</p>
</form>

<form>
<p><b>Updates<br/></b>
<select name="select" onChange="window.open(this.options[this.selectedIndex].value,'_self')">
<option value="">Select one</option>
<option value="http://www.oldgamer60.com/Project/ClientUpdates.php">Client Updates</option>
<option value="http://www.oldgamer60.com/Project/mynewform.php">Project Updates</option>
</select>
</p>
</form>

<form>
<p><b>New Business<br/></b>
<select name="select" onChange="window.open(this.options[this.selectedIndex].value,'_self')">
<option value="">Select one</option>
<option value="http://www.oldgamer60.com/Project/NewProject.php">New Project</option>
<option value="http://www.oldgamer60.com/Project/NewClients.php">New Clients</option>
</select>
</p>
</form>



<br>
</ul>
</nav>

<h1>Logistics</h1>

<br>
<h2>Updates</h2>


<?php
$servername = "localhost";
$username = "oldga740_Tonymm";
$password = "JtAjDm#6";
$dbname = "oldga740_SeniorProject";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

if (isset($_POST['update'])){
$UpdateQuery = "UPDATE Projects SET Project='$_POST[project]', Client='$_POST[client]', LastName='$_POST[lastname]', DateReceived='$_POST[datereceived]', FinalReviewDate='$_POST[finalreviewdate]', DateDelivered='$_POST[datedelivered]', DateAccepted='$_POST[dateaccepted]' WHERE Project='$_POST[hidden]'";
mysqli_query($conn, $UpdateQuery);
};

$sql = "SELECT * FROM Projects";
$result = $conn->query($sql);

echo "<table class="smaller">
<tr>
<th>Project</th>
<th>Client</th>
<th>Last Name</th>
<th>Date Received</th>
<th>Final Review Date</th>
<th>Date Delivered</th>
<th>Date Accepted</th>
</tr>";

while($record = mysqli_fetch_array($result))
{
if ($result->num_rows > 0){

echo "<form action='mynewform.php' method='post'>";
echo "<tr>";
echo "<td>" . "<input type='text' name='project' value='" . $record['Project'] . "' /></td>";
echo "<td>" . "<input type='text' name='client' value='" . $record['Client'] . "'/></td>";
echo "<td>" . "<input type='text' name='lastname' value='" . $record['LastName'] . "' /></td>";
echo "<td>" . "<input type='text' name='datereceived' value='" . $record['DateReceived'] . "' /></td>";
echo "<td>" . "<input type='text' name='finalreviewdate' value='" . $record['FinalReviewDate'] . "' /></td>";
echo "<td>" . "<input type='text' name='datedelivered' value='" . $record['DateDelivered'] . "' /></td>";
echo "<td>" . "<input type='text' name='dateaccepted' value='" . $record['DateAccepted'] . "' /></td>";
echo "<td>" . "<input type='hidden' name='hidden' value='" . $record['Project'] . "' /></td>";
echo "<td>" . "<input type='submit' name='update' value='update' /></td>";
echo "<td>" . "<input type='submit' name='delete' value='delete' /></td>";
echo "</tr>";
echo "</form>";
}
}
echo "</table>";



?>

<?php
$conn->close();
?>



</body>

</html>

我的CSS:

table.smaller { width:80%; }

最佳答案

您的代码中存在一个小的语法错误。这是修复:

// your code

echo "<table class=\"smaller\">
<tr>
<th>Project</th>
<th>Client</th>
<th>Last Name</th>
<th>Date Received</th>
<th>Final Review Date</th>
<th>Date Delivered</th>
<th>Date Accepted</th>
</tr>";

// your code

关于php - 无法将类分配给用于 sql 选择/更新的表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34033219/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com