Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
292 views
in Technique[技术] by (71.8m points)

mysql - How can I make a multiple condition using mysqli_num_rows using PHP

My problem is checking of data. I have solved my question few days ago. So my goal is if the data is already used for example is I input ABC 1000..ABC 1005 I got the ABC 1005 and in my next record I can use the ABC 1005 to add more quantity. Now the problem is I got the ABC 1005 but can't get the other not used data. I'm stuck in this problem

Here is my PHP code

    <?php 

include("../include/connect.php");

 
    if(isset($_POST['tools_id'])){
        
        $ID = $_POST['tools_id'];

        $query = "SELECT * FROM tools_masterlist LEFT JOIN tools_spec ON tools_masterlist.tools_id = tools_spec.tools_id
        WHERE status = 1 AND tools_name = '$ID'";

        // $result=mysqli_query($con, "CALL GetAjaxForToolsRegistration('$ID')");
        $con->next_result();
        $result=mysqli_query($con, $query);
        if(mysqli_num_rows($result)>0)
        {
            while($row = mysqli_fetch_assoc($result))
            {
                $baseQuery = "SELECT MAX(CONCAT(tools_registration.reg_control_num, '' ,tools_registration.reg_input)) 
                AS reg_input , tools_masterlist.tools_id, tools_registration.reg_tools_name, tools_spec.model_num,
                tools_masterlist.control_no
                FROM tools_registration 
                LEFT JOIN tools_masterlist ON tools_registration.tools_id = tools_masterlist.tools_id 
                LEFT JOIN tools_spec ON tools_masterlist.tools_id = tools_spec.tools_id WHERE tools_name = '$ID'";
                $con->next_result();
                $baseResult = mysqli_query($con, $baseQuery);
                if(mysqli_num_rows($baseResult)>0)
                {
                    while($regrow = mysqli_fetch_assoc($baseResult))
                    {
                        echo $regrow['reg_input'] . "@" . '<option value="'.$row['model_num'].'">'. $row['model_num'] .'</option>' . "@" . $regrow['tools_id'] ."@";
                    }
                }
                else 
                {
                    // echo $row['control_no'] . "@" . '<option value="'.$row['model_num'].'">'. $row['model_num'] .'</option>' . "@" . $regrow['tools_id'] ."@"; 
                }
            }
        }

        else
        {
           
        }
    }
?>

Here is the 1st photo

enter image description here

2nd photo

enter image description here

Here is my table

enter image description here

I have a hard time picking up, any suggestions would be great, advance thanks!

question from:https://stackoverflow.com/questions/65914001/how-can-i-make-a-multiple-condition-using-mysqli-num-rows-using-php

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...