dgmuk Posted July 3, 2007 Share Posted July 3, 2007 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? Quote Link to comment Share on other sites More sharing options...
pedrobcabral Posted July 3, 2007 Share Posted July 3, 2007 I don't know how you can solve it, but php for loop only takes 3 parameters and you are using 4. http://pt2.php.net/manual/en/control-structures.for.php Quote Link to comment Share on other sites More sharing options...
dgmuk Posted July 3, 2007 Author Share Posted July 3, 2007 * * bump * * Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.