Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.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回显html标记,其中包含稍后定义的变量_Php_Html_Echo - Fatal编程技术网

php回显html标记,其中包含稍后定义的变量

php回显html标记,其中包含稍后定义的变量,php,html,echo,Php,Html,Echo,我为数据库的每个元素生成按钮,每个按钮都包含一个currentSlide()函数,我需要定义要打开的滑块。我正在使用一个数组$buttonnums,并将每个元素定义为“-1”,但我想稍后将其定义为另一个数字,并将更改应用到html,方法与我们说class=“”的方法相同,然后我们将$var设置为其他值 while($row = $result->fetch_assoc()) { array_push($buttonnums,"-1");

我为数据库的每个元素生成按钮,每个按钮都包含一个currentSlide()函数,我需要定义要打开的滑块。我正在使用一个数组$buttonnums,并将每个元素定义为“-1”,但我想稍后将其定义为另一个数字,并将更改应用到html,方法与我们说class=“<?php$var?>”的方法相同,然后我们将$var设置为其他值

while($row = $result->fetch_assoc()) {
            array_push($buttonnums,"-1");
            end($buttonnums);
            echo "<button class=\"tablinks\" onclick=\"OpenCoffeeType(event,". $row["id"]."); currentSlide(<?php echo \$buttonnums[".key($buttonnums)."]?>)\"";
            if($count===0)
            {
                echo " id=\"defaultOpen\"";
                $count++;
            }
        echo ">". $row["title"]. " </button>";
    }
while($row=$result->fetch_assoc()){
阵列推送($buttonnums,“-1”);
完(港币);;

回音"你的
echo
命令是错误的。你的
echo
另一个
你的
echo
命令是错误的。你
echo
另一个
我试着这样做,但它只得到了第一个值。当我试图将变量从-1更改为1时,html一直保持-1。谁是$count2?你有项目的Github页面吗ct?查看整个过程可能会有所帮助。您似乎没有更新$buttonnums[0],而是更新$buttonnums[$count2]。但是您打印了$buttonnums[0];您好,我刚刚将项目添加到github,但它仍然无法正常运行,因为它需要一个数据库,但希望您能从那里了解更多内容。我尝试这样做,但它只得到第一个值。当我尝试将变量从-1更改为1时,html保持-1。谁是$count2?您有该项目的github页面吗?了解整个过程可能会有所帮助。您似乎没有更新$buttonnums[0],而是更新$buttonnums[$count2]。但是您打印了$buttonnums[0];您好,我刚刚将项目添加到github,但它仍然无法正常运行,因为它需要一个数据库,但希望您能从中了解更多内容。
while($row2 = $result2->fetch_assoc()) {
                    if ($count===0)
                    {
                        $buttonnums[$count2] = $counter;
                    }
                    echo "<span class=\"dot periexomenakatigorias\"  onclick=\"currentSlide(".$counter.")\">".$row2["title"]."</span>";
                    $counter++;
                }
echo "<button class=\"tablinks\" onclick=\"OpenCoffeeType(event,". $row["id"]."); currentSlide(<?php echo \$buttonnums[".key($buttonnums)."]?>)\"";
echo "<button class=\"tablinks\" onclick=\"OpenCoffeeType(event,". $row["id"]."); currentSlide(.'$buttonnums[".key($buttonnums)."]'.)\"";