我在我的代碼中有一個循環中的代碼,循環使得每個發現的成員都有一個提交按鈕。我需要每個按鈕都具有存儲在其中的成員名稱,通過單擊該按鈕後可以發送的方式發送。林不知道這是可能的後,但我想方式我用URLS做。有誰知道如何做到這一點?如何用php讀取/發送文章數據並在其中保存一個變量
<input type="submit" value="Attack" name="Attack?name=<?php echo $Member_name; ?>" />
<?php
if(isset($_POST['Attack'])){
$sql = "SELECT * FROM users WHERE name='".mysql_real_escape_string($_GET['name'])."'";
$query = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_object($query);
}
這是我試圖以隱藏的形式存儲它的整個代碼,但它只抓住找到的最後一個成員,並不會得到其他成員。
<?php
$sql = "SELECT name, rank FROM users ORDER BY rank DESC"; // Searches the database for every one who has being last active in the last 5 minute
$query = mysql_query($sql) or die(mysql_error());
$count = mysql_num_rows($query);
$i = 1;
while($row = mysql_fetch_object($query)) {
$Member_name = htmlspecialchars($row->name);
$Member_level = htmlspecialchars($row->rank);
?>
<td><?php echo $i; ?></td>
<td><a href="View_Profile.php?name=<?php echo $Member_name; ?>"><?php echo $Member_name; ?></a></td><td><?php echo $Member_level; ?></td><td>
<input type="hidden" name="thename" value="<?php echo $Member_name; ?>">
<input type="submit" value="Attack" name="Attack" />
</td>
<?
if($i != $count) { // this counts the amount of people that are online and display the results.
echo "</tr><tr>";
}
$i++;
}
?>
<?php
if(isset($_POST['Attack'])){
$sql = "SELECT * FROM users WHERE name='".mysql_real_escape_string($_POST['thename'])."'";
$query = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_object($query);
$profile_id = htmlspecialchars($row->id);
$profile_userip = htmlspecialchars($row->userip);
$profile_name = htmlspecialchars($row->name);
$profile_money = htmlspecialchars($row->money);
$profile_gang = htmlspecialchars($row->gang);
$profile_exp = htmlspecialchars($row->exp);
$profile_profile = htmlspecialchars($row->profile);
$profile_rank = htmlspecialchars($row->rank);
$profile_health = htmlspecialchars($row->health);
$profile_defence = htmlspecialchars($row->defence);
$profile_stanima = htmlspecialchars($row->stanima);
?>
「** like 10 buttons **」,所以它們可能不是按鈕?或者可能不是其中的10個? – 2012-08-05 20:27:55
其每個成員的循環現在有10個,但如果其他人制作角色,則會有11個按鈕,然後 – Tprice88 2012-08-05 20:28:36
,如果您可以顯示整個循環,則會有所幫助。 – Anil 2012-08-05 20:40:32