Php 如何在文本显示在页面上之前进行DB查询
我希望我不会让任何人对我的头衔感到困惑。让我先给你看我的代码,然后解释我想做什么 这是主要的浏览页面Php 如何在文本显示在页面上之前进行DB查询,php,Php,我希望我不会让任何人对我的头衔感到困惑。让我先给你看我的代码,然后解释我想做什么 这是主要的浏览页面 <?php $ingame = "*"; require 'includes/header.php'; include 'includes/modzoideditables.php'; include 'includes/zoideditables.php'; include 'includes/offdefvalues.php'; $move = 1; ?> <center
<?php
$ingame = "*";
require 'includes/header.php';
include 'includes/modzoideditables.php';
include 'includes/zoideditables.php';
include 'includes/offdefvalues.php';
$move = 1;
?>
<center>
Choose Your Destination Below
<BR><BR><a href="/gonorth.php">NORTH</a> <BR>
<a href="/goeast.php">EAST</a><BR>
<a href="/gosouth.php">SOUTH</a><BR>
<a href="/gowest.php">WEST</a><BR>
</center>
<BR><BR><center>You are Currently located at <?=$user['uCord1']?>,<?=$user['uCord2']?></center>
<?
require 'includes/footer.php';
?>
<?php
$ingame = "*";
require 'includes/header.php';
include 'includes/modzoideditables.php';
include 'includes/zoideditables.php';
include 'includes/offdefvalues.php';
$move = 1;
$db->query( "UPDATE users SET uCord1=uCord1+$move WHERE uID='" . $user['uID'] . "'" );
?>
<center>
Choose Your Destination Below
<BR><BR><a href="/gonorth.php">NORTH</a> <BR>
<a href="/goeast.php">EAST</a><BR>
<a href="/gosouth.php">SOUTH</a><BR>
<a href="/gowest.php">WEST</a><BR>
</center>
<BR><BR><center>You are Currently located at <?=$user['uCord1']?>,<?=$user['uCord2']?></center>
<?
require 'includes/footer.php';
?>
<?php
$ingame = "*";
require 'includes/header.php';
include 'includes/modzoideditables.php';
include 'includes/zoideditables.php';
include 'includes/offdefvalues.php';
$move = 1;
$db->query( "UPDATE users SET uCord2=uCord2-$move WHERE uID='" . $user['uID'] . "'" );
?>
<center>
Choose Your Destination Below
<BR><BR><a href="/gonorth.php">NORTH</a> <BR>
<a href="/goeast.php">EAST</a><BR>
<a href="/gosouth.php">SOUTH</a><BR>
<a href="/gowest.php">WEST</a><BR>
</center>
<BR><BR><center>You are Currently located at <?=$user['uCord1']?>,<?=$user['uCord2']?></center>
<?
require 'includes/footer.php';
?>
在下面选择您的目的地
您当前所在的位置:,
这是北页
<?php
$ingame = "*";
require 'includes/header.php';
include 'includes/modzoideditables.php';
include 'includes/zoideditables.php';
include 'includes/offdefvalues.php';
$move = 1;
$db->query( "UPDATE users SET uCord2=uCord2+$move WHERE uID='" . $user['uID'] . "'" );
?>
<center>
Choose Your Destination Below
<BR><BR><a href="/gonorth.php">NORTH</a> <BR>
<a href="/goeast.php">EAST</a><BR>
<a href="/gosouth.php">SOUTH</a><BR>
<a href="/gowest.php">WEST</a><BR>
</center>
<BR><BR><center>You are Currently located at <?=$user['uCord1']?>,<?=$user['uCord2']?></center>
<?
require 'includes/footer.php';
?>
很难说,因为您没有向我们展示$user
设置的位置/方式。在我看来,你只需要第二次提出这个问题。另外,要小心。您可能会受到SQL注入攻击。将准备好的/参数化的查询与PDO或类似的方法一起使用以避免此问题。PDO查询不是异步的,可能是缓存问题?请参见请立即停止使用
。哪个require/include文件包含您的select查询?我认为您的数据库值在更新之前就已经被选中了,但仍然保留旧值remain@LiamAllan事实就是这样。我知道了,谢谢你
<?php
$ingame = "*";
require 'includes/header.php';
include 'includes/modzoideditables.php';
include 'includes/zoideditables.php';
include 'includes/offdefvalues.php';
$move = 1;
$db->query( "UPDATE users SET uCord1=uCord1-$move WHERE uID='" . $user['uID'] . "'" );
?>
<center>
Choose Your Destination Below
<BR><BR><a href="/gonorth.php">NORTH</a> <BR>
<a href="/goeast.php">EAST</a><BR>
<a href="/gosouth.php">SOUTH</a><BR>
<a href="/gowest.php">WEST</a><BR>
</center>
<BR><BR><center>You are Currently located at <?=$user['uCord1']?>,<?=$user['uCord2']?></center>
<?
require 'includes/footer.php';
?>
"You are Currently located at <?=$user['uCord1']?>,<?=$user['uCord2']?>"