이 코드는 코드에 루프로 있습니다. 루프는 발견 된 모든 멤버에 대해 하나의 제출 버튼을 만듭니다. 단추를 클릭 할 때 게시 할 수있는 방식으로 각 단추에 구성원 이름이 저장되어 있어야합니다. 이것이 포스트와 함께 가능한지 확실하지 않은 Im 그러나 나는 URL과 함께 그것을하는 길을 시험해보고 있었다. 누구든지이 작업을 수행하는 방법을 알고 있습니까?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);
?>
"** 좋아하는 10 버튼 **"그래서 그들은 버튼이 아닐 수 있습니까? 또는 아마 그들 중 10 아닌가요? –
각 멤버에 대한 루프가 있습니다. 지금은 10 개가 있지만, 누군가가 캐릭터를 만들면 11 개의 버튼이 표시되고 – Tprice88
은 전체 루프를 표시하면 도움이됩니다. – Anil