RE: [PHP] putting a list of data into 3 columns?

2001-04-09 Thread Stewart Taylor
Here is a basic (untested) example. $link = mysql_connect("localhost", "username", "password"); mysql_select_db("database", $link); $result = mysql_query("SELECT product_name FROM products", $link); $num_rows = mysql_num_rows($result); // read in data while ($row = mysql_fetch_array

Re: [PHP] putting a list of data into 3 columns?

2001-04-09 Thread Lindsay Adams
okay. your solution is not going to scale well, is it. if you have more than nine items, you have to rewrite your code. here is what I did: I created this table in mysql from the command line as follows: mysql create table tabletest ( - id int unsigned primary key not null auto_increment);

Re: [PHP] putting a list of data into 3 columns?

2001-04-09 Thread DRN
Lindsay Adams [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... okay. your solution is not going to scale well, is it. if you have more than nine items, you have to rewrite your code. I (sort of) understand your solution, but I don't see how my solution is not

[PHP] putting a list of data into 3 columns?

2001-04-07 Thread DRN
Hi, I would like to display a list of products from a MySQL database in 3 columns. as shown below: Product A Product D Product G Product B Product E Product H Product C Product F The problem I have is I don't know how many products there will be, so I can't just print

[PHP] putting a list of data into 3 columns?

2001-04-07 Thread DRN
Hi, I would like to display a list of products from a MySQL database in 3 columns. as shown below: Product A Product D Product G Product B Product E Product H Product C Product F The problem I have is I don't know how many products there will be, so I can't just print

RE: [PHP] putting a list of data into 3 columns?

2001-04-07 Thread Jack Dempsey
You don't need to count...in your loop you can do something like this: if($current_pos%3==0){ //then you're at a multiple of three //code to start new column here } -jack -Original Message- From: DRN [mailto:[EMAIL PROTECTED]] Sent: Saturday, April 07, 2001 2:55 PM To: [EMAIL

Re: [PHP] putting a list of data into 3 columns?

2001-04-07 Thread Lindsay Adams
Assuming your items are in an array $items =array() //assume a bunch of items in this array For($i = 0; $i (count($items)/3); $i +=1){ printf("%s\t%s\t%s",$items[$i],$items[$i+3],$items[$i+6]); } Should print 3 columns of tab separated text. Note: typed this quickly, untested, but the theory

Re: [PHP] putting a list of data into 3 columns?

2001-04-07 Thread DRN
Lindsay Adams [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... | Assuming your items are in an array | $items =array() //assume a bunch of items in this array | For($i = 0; $i (count($items)/3); $i +=1){ |

RE: [PHP] putting a list of data into 3 columns?

2001-04-07 Thread Jack Dempsey
the method i gave you will do this..if you use the if clause i showed and work with it for more than a minute you'll see how you can test to see if you should add an /tdtd to your data, and this will let you make your columns.play with it and you'll see.. -jack -Original

Re: [PHP] putting a list of data into 3 columns?

2001-04-07 Thread Lindsay Adams
This is exactly what I sent you. You have to realize that you can't print down one column, and then start a new one. You have to print across, left to right before you go down. You have to modify the print statement to put it into a table, but that is easy: Print should be: