Jump to content

[SOLVED] Syntax Error in PHP SQL Query


dgmuk

Recommended Posts

Hi,

 

I am trying to get results from a sql query to display in a table, formatted to two columns (i.e.:

 

Result1 Result2

Result3 Result4

Result5 Result6

 

etc!

 

However I am getting this error and I can't work out why:

 

Parse error: syntax error, unexpected ';', expecting ')' in /home/sites/regencynet.com/public_html/phonesearch2.php on line 15

 

This is the script I am using:

 

<?php

//set the number of columns

$columns = 2;

 

mysql_connect('localhost',products-24','4758112542');

mysql_select_db(products-24');

$query = "SELECT * FROM infoproducts ORDER BY IDC";

$result = mysql_query($query);

 

//we add this line because we need to know the number of rows

$num_rows = mysql_num_rows($result);

echo "<TABLE BORDER=\"0\">\n";

 

//changed this to a for loop so we can use the number of rows

for($i = 0; $i < $num_rows; $i++) {

    $row = mysql_fetch_array($result);

    if($i % $columns == 0) {

        //if there is no remainder, we want to start a new row

        echo "<TR>\n";

    }

    echo "<TD>" . $row['IDC'] . "</TD>\n";

    if(($i % $columns) == ($columns - 1) || ($i + 1) == $num_rows) {

        //if there is a remainder of 1, end the row

        //or if there is nothing left in our result set, end the row

        echo "</TR>\n";

    }

}

echo "</TABLE>\n";

?>

 

Can anyone help please?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.