[thelist] php display 3x2

Andrew Maynes andrew at humanbehaviour.co.uk
Mon Dec 2 12:34:01 CST 2002

can someone point me in the right direction for displaying the results of this
table so that it is 3x2 only

I have changed everything and it just aint happening

code is: Courtesy of Jay :)

//connect to & select database
if(!($connect = mysql_pconnect("localhost", "root", "xxx"))){
	print("Failed to connect to database!\n");
if(!mysql_select_db("hifi", $connect)){
	print("Failed to select database!\n");
// do the query
$sql = "SELECT image, title FROM book_shop ";
$result = mysql_query($sql, $connect);


//set a base number to keep track of the columns
$record_column == 3;
while($row = mysql_fetch_object($result)){
// how many columns do we want...3
   if($record_column <=3){
//if this is the first column we need to print the table row tag
      if($record_column == 0){
// print out 3 books for this column with proper tags
      print("<td>" . $row->image . $row->title . "</td>");
// increase the column number by one and get the next record
   } else {
// if there are 3 columns (like set above) then print the end tag
// reset the column record to begin new row
	  $record_column = 1;

More information about the thelist mailing list