简体   繁体   English

PHP变量和MySQL查询

[英]PHP Variable and MySQL Querying

Wasn't sure what exactly to search for so apologies if this has been covered elsewhere.. 如果在其他地方已经涵盖了这一点,则不确定该搜索什么道歉。

Basically I have Bulkhead1, Bulkhead2, Bulkhead3 etc and I'm trying to save space by adding 1 each time but I'm going wrong somewhere! 基本上我有Bulkhead1,Bulkhead2,Bulkhead3等,我想通过每次加1来节省空间,但是我在某个地方出错了! :( :(

Something is going wrong here - $row['Bulkhead"'.$it.'"'] 这里出了点问题-$ row ['Bulkhead“'。$ it。'”']

$i=1;
while($x= mysqli_fetch_array($y)) { 
$bh = $row['Bulkhead"'.$it.'"'];
}
$i++;

try; 尝试; $bh = $row['Bulkhead'.$i]; $ bh = $ row ['Bulkhead'。$ i];

I think that the double quotes are misused, also you are using $i and $it, is it a typo? 我认为双引号被滥用,您也使用$ i和$ it,这是错字吗?

$i=1;
while($x= mysqli_fetch_array($y)) { 
    $bh = $row["Bulkhead$i"];
    $i++;
}

I don't really understand what you want but I will try to fix your code: 我不太了解您想要什么,但是我将尝试修复您的代码:

    $i=1;
    while($x= mysqli_fetch_array($y))
    { 
   echo 'Bulkhead'. $i;
   $i++;
    }

Or as an array: 或作为数组:

$bh  = array ();
$i=1;
while($x= mysqli_fetch_array($y))
{ 
   $ bh[ ]= 'Bulkhead'. $i;
   $i++;
}

If I get you wrong, try to explain your question better. 如果我弄错了,请尝试更好地解释您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM