dt246813579 2017-08-08 09:39 采纳率: 0%
浏览 8

PHP检查数据库中的数字

I need to check if number in database is 1 or 0, and which number it is from beggining, for example, in my SQL column I have information like this:

0 0 0 1 0

And it has number 1 in it's SQL, and it's the fourth number from beginning, and I need to loop through all variables and check where is and what is this number, code something like this:

for($i = 0; $<5; $i++) {
    while(//what to do here?) {
        //Code
    }
}

And, more examples:

if($Array[$i] == 1) { //Checks if the number is 1
    echo "The number 1 in your column is at position:". $Variable .";

Shows where is the number from the beggining, in this case it is 4. So, thanks for help, sorry for my bad english.

  • 写回答

1条回答 默认 最新

  • dplp5928 2017-08-08 14:08
    关注

    Well, I readed your comments, and tried to do this myself, and I did, here is how I done this:

        else {
            $arr = explode(" ", $row["skins"]);
            for($a = 0; $a < count($arr); $a++) {
                if($arr[$a] == 1) {
                    //Rest of the code
                }
            }
        }
    

    It's not full code, but it works. Thanks for your support, and your motivation that I can do it myself :)

    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)