Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PHP中检查其他文件中的值_Php - Fatal编程技术网

在PHP中检查其他文件中的值

在PHP中检查其他文件中的值,php,Php,我试图找出如何比较两个不同文件中的两个不同值。我想将资源从一个方面与另一个方面进行比较。如果我有比我需要的更多的资源,那么我想显示提交按钮。 谢谢大家!! 在这两种代码中,我都将字符串转换为Int,以便于比较。 我的问题是在代码的末尾,我在做一个“IF”语句,我只希望在所有条件都满足时它才有效 文件A中的代码,其中是我的升级成本。数据库将返回所有建筑物和以下升级成本: <table width=\"100%\" border=\"1\"> <tr> <t

我试图找出如何比较两个不同文件中的两个不同值。我想将资源从一个方面与另一个方面进行比较。如果我有比我需要的更多的资源,那么我想显示提交按钮。 谢谢大家!! 在这两种代码中,我都将字符串转换为Int,以便于比较。 我的问题是在代码的末尾,我在做一个“IF”语句,我只希望在所有条件都满足时它才有效

文件A中的代码,其中是我的升级成本。数据库将返回所有建筑物和以下升级成本:

<table width=\"100%\" border=\"1\">
  <tr>
    <td colspan="2"><b><center>Actual</center></b></td>
    <td colspan="7"><b><center>Recursos per passar al proper nivell</center></b></td>
  </tr>
  <tr>
    <td><b><center>Edifici</center></b></td>
    <td><b><center>Nivell Actual</center></b></td>
    <td><b><center>Seguent Nivell</center></b></td>
    <td><b><center>Cristall</center></b></td>
    <td><b><center>Fusta</center></b></td>
    <td><b><center>Marbre</center></b></td>
    <td><b><center>Raim</center></b></td>
    <td><b><center>Sofre</center></b></td>
  </tr>
<?php
include("connexio.php");
  $consulta_edificis="SELECT nom_edifici,nivell FROM edificis ORDER BY id_edifici ASC"; //consultem el nom i el nivell acual del edifici
  $resultat_edificis=mysqli_query($connect,$consulta_edificis);
  while($consulta_nivell=mysqli_fetch_array($resultat_edificis)) //Treiem el nom i nivell actual.
  {
    $nivell_actual=(int)$consulta_nivell['nivell']; //convertim el string a numero enter
    $nivell_actual=$nivell_actual+1; //sumem 1 ja que a la taula de nivells també tenim el nivell 0.
    $consulta_seguent_nivell="SELECT id_nivell,cost_upgrade_cristall,cost_upgrade_fusta,cost_upgrade_marbre,cost_upgrade_raim,cost_upgrade_sofre FROM nivells LIMIT 1 OFFSET $nivell_actual"; //consulta per saber el que ens costarà pujar al seguent nivell.
    $resultat_pujar_nivell=mysqli_query($connect,$consulta_seguent_nivell);
    while($consulta_cost_seguent_nivell=mysqli_fetch_array($resultat_pujar_nivell))
    { //imprimim resultats
      ?>
      <tr>
        <td><?php echo $consulta_nivell['nom_edifici']?></td>
        <td><?php echo $consulta_nivell['nivell']?></td>
        <td><?php echo $consulta_cost_seguent_nivell['id_nivell']?></td>
        <td><?php echo $consulta_cost_seguent_nivell['cost_upgrade_cristall']?></td>
        <td><?php echo $consulta_cost_seguent_nivell['cost_upgrade_fusta']?></td>
        <td><?php echo $consulta_cost_seguent_nivell['cost_upgrade_marbre']?></td>
        <td><?php echo $consulta_cost_seguent_nivell['cost_upgrade_raim']?></td>
        <td><?php echo $consulta_cost_seguent_nivell['cost_upgrade_sofre']?></td>
        <?php
          $cost_cristall=(int)$consulta_cost_seguent_nivell['cost_upgrade_cristall'];
          $cost_fusta=(int)$consulta_cost_seguent_nivell['cost_upgrade_fusta'];
          $cost_marbre=(int)$consulta_cost_seguent_nivell['cost_upgrade_marbre'];
          $cost_raim=(int)$consulta_cost_seguent_nivell['cost_upgrade_raim'];
          $cost_sofre=(int)$consulta_cost_seguent_nivell['cost_upgrade_sofre'];
        ?>
        <?php include("materials.php"); ?>
        <td><?php if ($cristall>$cost_cristall && $fusta>$cost_fusta && $marbre>$cost_marbre && $raim>$cost_raim && $sofre>$cost_sofre): ?>
            <input type="submit" value="enviar">
            <?php else: ?>
            <p>no</p>
            <?php endif; ?></td>
          </tr>
      <?php
    }
  }
mysqli_close($connect);
?>
</table>

实际的
根据帕萨尔尼维尔的经验
大厦
尼维尔实际值
塞古特尼维尔酒店
克瑞丝道
弗斯特船
马尔布雷
雷姆
索弗
没有

文件B中的代码,其中有我的资源:

    <?php
include("connexio.php");
$consulta_valors="SELECT * FROM materials LIMIT 1";
$resultat_valors=mysqli_query($connect,$consulta_valors);
while($consulta=mysqli_fetch_array($resultat_valors))
{
$consulta['cristall'];
$consulta['fusta'];
$consulta['marbre'];
$consulta['raim'];
$consulta['sofre'];
$cristall=(int)$consulta['cristall'];
$fusta=(int)$consulta['fusta'];
$marbre=(int)$consulta['marbre'];
$raim=(int)$consulta['raim'];
$sofre=(int)$consulta['sofre'];
}
mysqli_close($connect);
?>
</table>