2

I'm working with displaying an output when I count the value of the second query is greater than or equal to 2 , using the first query where second query schedule number is equal to the first query schedule number.

The line that I got an error:

if ($x>=2) {.'<button onclick="CreateRevision('.$row['id'].')" type="button" class="btn btn-primary"><span class="fa fa-copy"></span></button>'.} else{}.'.

I just got this message syntax error, unexpected'.'

My whole code is this:

<?php
    //open connection to mysql db
    include("db_connection.php");
 $data = '                   
                    <table id="tb_jobsched" class="display nowrap table table-bordered" width="100%" cellspacing="0">
                        <thead>
                            <tr>
                                <th width="3%">#</th>
                                <th width="10%">Schedule Number</th>
                                <th width="20%">Item Name</th>
                                <th width="10%">Output</th>                            
                                <th width="10%">Date Created</th>
                                <th width="10%">Expected Date</th>
                                <th width="10%">Prepared By</th>
                                <th width="7%">Status</th>
                                <th width="7%"></th>
                            </tr>
                        </thead>
                        <tfoot>
                            <tr>
                                <th width="3%">#</th>
                                <th width="10%">Schedule Number</th>
                                <th width="20%">Item Name</th>
                                <th width="10%">Output</th>                            
                                <th width="10%">Date Created</th>
                                <th width="10%">Expected Date</th>
                                <th width="10%">Prepared By</th>
                                <th width="7%">Status</th>
                                <th width="7%"></th>
                            </tr>
                        </tfoot>';

    $query = "SELECT * FROM prepressjobs WHERE pj_deleted = 0 ORDER BY pj_datecreated DESC";

            if (!$result = mysqli_query($db,$query)) {
                exit(mysqli_error());
            }

            // if query results contains rows then featch those rows 
            if(mysqli_num_rows($result) > 0)
            {
                $number = 1;
                while($row = mysqli_fetch_assoc($result))
                {
                    $data .= '<tr>
                        <td>'.$number.'</td>
                        <td>'.$row['pj_schednum'].'</td>
                        <td>'.$row['pj_itemname'].'</td>
                        <td>'.$row['pj_output'].'</td>
                        <td>'.$row['pj_datecreated'].'</td>
                        <td>'.$row['pj_expectedfinished'].'</td>
                        <td>'.$row['pj_preparedby'].'</td>
                        <td>'.$row['pj_status'].'</td>
                        <td>
                            <div class="btn-group" role="group" aria-label="Button group with nested dropdown">
                                <button  onclick="GetJobDetails('.$row['id'].')"  type="button" class="btn btn-primary"><span class="fa fa-gear"></span></button> 
                                '.
                                $querya = "SELECT COUNT(rm_schednum) AS jobrevision FROM jobrevisions WHERE rm_schednum ='{$row['pj_schednum']}'";
                                $resulta= mysqli_query($db, $querya);
                                $rowa = mysqli_fetch_assoc($resulta);
                                $x=$rowa['jobrevision'];

                                if ($x>=2) {.'<button  onclick="CreateRevision('.$row['id'].')" type="button" class="btn btn-primary"><span class="fa fa-copy"></span></button>'.} else{}.'
                            </div>
                        </td> 
                    </tr>';
                    $number++;
                }
            }
            else
            {
                // records now found 
                $data .= '<tr><td colspan="8">Records not found!</td></tr>';
            }

    $data .= '</table>';

            echo $data;
?>

What is the following solution about this?

1 Answer 1

3
<?php
        <?php
            //open connection to mysql db
            include("db_connection.php");
         $data = '                   
                            <table id="tb_jobsched" class="display nowrap table table-bordered" width="100%" cellspacing="0">
                                <thead>
                                    <tr>
                                        <th width="3%">#</th>
                                        <th width="10%">Schedule Number</th>
                                        <th width="20%">Item Name</th>
                                        <th width="10%">Output</th>                            
                                        <th width="10%">Date Created</th>
                                        <th width="10%">Expected Date</th>
                                        <th width="10%">Prepared By</th>
                                        <th width="7%">Status</th>
                                        <th width="7%"></th>
                                    </tr>
                                </thead>
                                <tfoot>
                                    <tr>
                                        <th width="3%">#</th>
                                        <th width="10%">Schedule Number</th>
                                        <th width="20%">Item Name</th>
                                        <th width="10%">Output</th>                            
                                        <th width="10%">Date Created</th>
                                        <th width="10%">Expected Date</th>
                                        <th width="10%">Prepared By</th>
                                        <th width="7%">Status</th>
                                        <th width="7%"></th>
                                    </tr>
                                </tfoot>';

            $query = "SELECT * FROM prepressjobs WHERE pj_deleted = 0 ORDER BY pj_datecreated DESC";

                    if (!$result = mysqli_query($db,$query)) {
                        exit(mysqli_error());
                    }

                    // if query results contains rows then featch those rows 
                    if(mysqli_num_rows($result) > 0)
                    {
                        $number = 1;
                        while($row = mysqli_fetch_assoc($result))
                        {


                            $data .= "<tr>
                                <td>{$number}</td>
                                <td>{$row['pj_schednum']}</td>
                                <td>{$row['pj_itemname']}</td>
                                <td>{$row['pj_output']}</td>
                                <td>{$row['pj_datecreated']}</td>
                                <td>{$row['pj_expectedfinished']}</td>
                                <td>{$row['pj_preparedby']}</td>
                                <td>{$row['pj_status']}</td>
                                <td>
                                    <div class='btn-group' role='group' aria-label='Button group with nested dropdown'>
                                        <button  onclick='GetJobDetails({$row['id']})'  type='button' class='btn btn-primary'><span class='fa fa-gear'></span></button> 
                                        ";




                                        $querya = "SELECT COUNT(rm_schednum) AS jobrevision FROM jobrevisions WHERE rm_schednum ='{$row['pj_schednum']}'";
                                        $resulta= mysqli_query($db, $querya);
                                        $rowa = mysqli_fetch_assoc($resulta);
                                        $x = $rowa['jobrevision'];



                                        if ($x>=2) {
                              $data .= "<button  onclick='CreateRevision({$row['id']})' type='button' class='btn btn-primary'><span class='fa fa-copy'></span></button>";
    } else{}
                                   $data .=  "</div>
                                </td> 
                            </tr>";
                            $number++;
                        }
                    }
                    else
                    {
                        // records now found 
                        $data .= "<tr><td colspan='8'>Records not found!</td></tr>";
                    }

            $data .= "</table>";

                    echo $data;
        ?>
Sign up to request clarification or add additional context in comments.

8 Comments

I've got an error at <button onclick="GetJobDetails({$row['id']})" type="button" class="btn btn-primary"><span class="fa fa-gear"></span></button>'; and I've got message at my browser Parse error: syntax error, unexpected 'id' (T_STRING) in C:\xampp\htdocs\pinguin\ajax\count_revision.php on line 58
yea....change it to that....and mind you, i also make some adjustment to your code.
if ($x>=2) { $data .= '<button onclick="CreateRevision({$row['id']})" type="button" class="btn btn-primary"><span class="fa fa-copy"></span></button>'; } else{}
@Lenkens I've got this Parse error: syntax error, unexpected 'id' (T_STRING) in C:\xampp\htdocs\pinguin\ajax\count_revision.php on line 56
{$row['id']} that is your string...let me try help you out
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.