0

This error is completely different now:

Parse error: syntax error, unexpected '>' in C:\xampp\htdocs\xampp\onlinebookstore\order.php on line 19

What IDE / editor do you use? It should show you the error in syntax. Have you misstyped something?

0

Then why is it now different error. Can you post the last version of order.php.

Edited by broj1

0
<?php
// if there were any checkboxes selected, they will be returned as an array
// of selected codes, if no checkboxes were selected, the array will not be set
// this is why you first check whether the $_GET['check'] array is set an not empty
if(isset($_GET['check']) and !empty($_GET['check'])) {
    // you can use print_r function to display the contents of array for debugging
    // print_r($_GET['check']);
    // from values in $_GET['check'] array create a string of codes, separated
    //  with commas that willserve as an IN condition for sql query
    // see implode manual on php.net
    $code_list = implode(',', $_GET['check']);
    // construct your query

    $query = "SELECT * FROM books where Code IN (1100,1102);
     //die($query);

    $result= mysql_query($query);
    // begin table and table header
    echo "<div><table border=0 cellspacing='15' align=center id=table1><tr>
    <th>Title</th>
    <th>Price</th>
    </tr>";
    // display rows
    while($row = mysql_fetch_array($result)) {
        echo "<td align=center>".$row['Title']."</td>";
        echo "<td align=center>".$row['Price']."</td>";
    }
    // end table
    echo '</table>';
// if $_GET['check'] array is not set or is empty display error message (or do
// whatever you think is appropriate)
} else {
    echo 'Sorry, no checkboxes were selected.';
}
?>

Edited by diafol: apply code tags

0

You are missing double quote at the end of the following statement:

$query = "SELECT * FROM books where Code IN (1100,1102);

It should be:

$query = "SELECT * FROM books where Code IN (1100,1102)";
0

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\xampp\onlinebookstore\order.php on line 24

this is line 24: while($row = mysql_fetch_array($result)) {

0

OK, we are back to the beginning. Please uncomment the following line:

// print_r($_GET['check']);

and post what you get.

One more thing: I am leaving in 35 minutes and will not be availabel for 3 - 4 hours.

0

Array ( [0] => 1100 )

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\xampp\onlinebookstore\order.php on line 24
Title Price
that shows.I hope you come back soon huhu

0

After the line that says:

$code_list = implode(',', $_GET['check']);

put the following code:

die(code_list);

and post here.

0

Since I have to go I am posting a quick checklist for debugging:

$_GET['check'] array should contain array of the Codes you checked with checkboxes
$code_list should be a string of the same codes, separated by commas (it is created from $_GET['check'] array using implode() function)
SELECT query should use $code_list to select all rows that have selected codes (that is why you use IN statement). It should look something like SELECT * FROM books where Code IN (1100,1102).

To debug first inspect the $_GET['check'] array. You do this with print_r($_GET['check']) command. It should display something like Array ( [0] => 1100 [1] => 1102 )
When it is OK you can check the $code_list string that comes from the array. YOu use die($code_list) command for that. $code_list should be something like '1100,1101,1102'.
You can also inspect the query using die($query). You can copy displayed query nto phpmyadmin (look for SQL tab) and see if it return correct rows.

Hope that helps.

0

it says: Array ( [0] => 1103 )
Notice: Use of undefined constant code_list - assumed 'code_list' in C:\xampp\htdocs\xampp\onlinebookstore\order.php on line 13
code_list

0

change

$result= mysql_query($query);

to:

$result= mysql_query($query) or die(mysql_error());
0

and hows this work:

    <?php
    // if there were any checkboxes selected, they will be returned as an array
    // of selected codes, if no checkboxes were selected, the array will not be set
    // this is why you first check whether the $_GET['check'] array is set an not empty
    if(isset($_GET['check']) && !empty($_GET['check'])){
        // you can use print_r function to display the contents of array for debugging
        // print_r($_GET['check']);
        // from values in $_GET['check'] array create a string of codes, separated
        // with commas that willserve as an IN condition for sql query
        // see implode manual on php.net
        if(is_array($_GET['check'])){
            $code_list = implode(',', $_GET['check']);
        }else{
            $code_list = $_GET['check'];
        }
        // construct your query
        $query = "SELECT * FROM `books` WHERE `Code` IN ({$code_list})";
         //die($query);
        $result= mysql_query($query) or die(mysql_error());
        // begin table and table header
        echo "<div><table border=0 cellspacing='15' align=center id=table1><tr>
        <th>Title</th>
        <th>Price</th>
        </tr>";
        // display rows
        while($row = mysql_fetch_array($result)) {
            echo "<tr>";
            echo "<td align=center>".$row['Title']."</td>";
            echo "<td align=center>".$row['Price']."</td>";
            echo "</tr>";
        }
        // end table
        echo '</table>';
        // if $_GET['check'] array is not set or is empty display error message (or do
        // whatever you think is appropriate)
    }else{
        echo 'Sorry, no checkboxes were selected.';
    }
    ?>

Edited by Biiim

0

@broj1 thank you for your time even you are working you consider helping me. Thats a lot. A BIG THANKS broj1=)

0

No worries, mate. It is important that your problem has been solved. This forum is kind a great :-)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.