dousui6488 2014-04-21 23:18 采纳率: 100%
浏览 55

更新管理页面上的行

I am trying to create an Admin page which will pull up rows from a table and allow the "admin" to make changes. While I can figure out the code. I would like you to suggest me how can I display the row data and make it editable and saveable to the database. If the "admin" needs to update only the Artist Name, how do I manage that keeping the other data intact. I just don't know how to get this done.

The Update page so far :

<?php
//creating MySQL connection
$con=mysqli_connect('localhost','SouravBasuRoy','2525','MyteraArt');
//
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link href="admin-styles.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1>Admin Panel: Paintings | Mytera Art</h1>
<h2>Update a Painting</h2>
<hr>

<div>
<h1>Search by Painting Name :</h1>
<form name="SearchByPainting" action="editpainting.php" method="post">
<input list="paintings" name="frompaintings">
<datalist id="paintings">
<?php
//Insert Query to extract Artist names form Database
$result = mysqli_query($con,'SELECT `ArtName` FROM Paintings');
while($row = mysqli_fetch_array($result))
{
echo '<option value="' . $row['ArtName'] . '">' ;
}
?>
</datalist>
<input type="submit">
</form>
</div>
<!-- Display Area -->
<div>
<?php
if(isset($_POST['frompaintings']))
{
$item = $_POST['frompaintings'] ;

//MySQL Query to extract row by Painting Name
$result = mysqli_query($con,"SELECT * FROM Paintings WHERE `ArtName` = '$item'");
while($row = mysqli_fetch_array($result))
{
echo '<p>' . $row['ArtName'] . '</p>' ;
echo '<p>' . $row['ArtistName'] . '</p>'  ;
echo '<p>' . $row['Price'] . '</p>'  ;
echo '<p>' . $row['FileName'] . '</p>'  ;

echo '' ;
}
}
?>
</div>
</body>
</html>

The table structure is : ID int(11) | ArtName tinytext | ArtDescription text | ArtistName tinytext | ArtistDescription text | Price bigint(11) | FileName varchar(5555)

  • 写回答

2条回答 默认 最新

  • dongqian1925 2014-04-21 23:28
    关注

    Basically, you would have to check form parameters if they are empty or not. Maybe writing a validation class, that checks if specific fields are present not empty.

    Please have a look at the Laravel framework, it has a great validation class from which I believe you can learn a lot.

    Laravel

    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么