私はHTMLページを作成してPHPを使用してデータベースからデータを取り出し、作成したテーブルに格納します。どのように私はそれを得ることができるので、ユーザーがボタンをクリックすると、それはphpを使用してテーブルの行に従って特定のタスクをプリフォームするでしょうか?PHPテーブルを作成し、ユーザーがテーブルから情報を取得できるようにします
私はデータベースから情報を取り出し、HTMLテーブルに新しい行を作成したいと考えています。それらの行にはデータベースからのデータがあり、各行にはボタンもあります。ユーザーがそのボタンをクリックすると、変数$ namで表される指定された '名前'を使用して関数を呼び出すようにします。
<?php
ob_start();
session_start();
require_once 'dbconnect.php';
if(!isset($_SESSION['user'])) {
header("Location: index.php");
exit;
}
$deny = array("222.222.222", "333.333.333");
if (in_array ($_SERVER['REMOTE_ADDR'], $deny)) {
header("location: http://www.google.com/");
exit();
}
$res=mysqli_query($con,"SELECT * FROM users WHERE userId=".$_SESSION['user']);
$userRow=mysqli_fetch_array($res);
?>
<!DOCTYPE html>
<html>
<?php header("Access-Control-Allow-Origin: http://www.py69.esy.es"); ?>
<head>
<title>ServiceCoin</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="assets/css/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="scripts/home/index.css" />
</head>
<body>
<center>
<h3>Welcome, <?php echo $userRow['userName']; ?>. You Currently Have <span id="services"><?php echo $userRow['userServices']; ?></span> Services</h3>
<p id="error"></p>
<button onclick="send_coins()" class="button">Send Coins</button>
<button onclick="create_service()" class="button">Create A Service</button>
<button onclick="send_coins()" class="button">My Services</button>
<h3>View Services</h3>
<span><?php
$users = 1;
$num = 1;
echo "<center><table width=1000><th>Buy</th><th>Service Name</th><th>Service Cost</th><th>Service Description</th><th>Service Provider Name</th>";
while($users < 100 && $num < 100){
$res=mysqli_query($con,"SELECT * FROM users WHERE userId=".$users);
$userRow=mysqli_fetch_array($res);
$id = 0;
while($id != 10){
$id = $id + 1;
if($userRow['userService'.$id] === 'null'){
}else if(!empty($userRow['userService'.$id])){
echo "<tr><td name=$num ><input type=submit value=buy ></td><td class=services width=250 align=center>".$userRow['userService'.$id]."</td><td class=services width=250 align=center>".$userRow['userServiceCost'.$id]."</td><td class=services class=services width=500 align=center>".$userRow['userServiceDes'.$id]."<td class=services width=500 align=center>".$userRow['userServiceName'.$id]."</tr>";
//echo $id."Error: ".$con->error;
$num = $num + 1;
$id = $id + 1;
}
}
$users = $users + 1;
}
echo "All Services Loaded";
echo "</table></center>";
?></span>
<span class="text-danger"><?php echo $msg; ?></span>
</center>
</body>
<script lang="text/javascript" src="scripts/home/index.js"></script>
</html>
<?php ob_end_flush(); ?>
かなり広いですが、本質的には、テーブル行にフォームを作成し、それらのフォームにサブミットボタンを配置することをお勧めします。フォームを送信するとPHPページが呼び出され、そのフォームのデータがPHPページに提供されます。 – David
javascriptを使って 'task'や簡単なフォームの投稿を開始しますか? – RamRaider
はい、あなたが言っているように、私はそれを更新して、できるだけ多くの情報を入れようとしています。 –