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
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);
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
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
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
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){
|
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
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:
8 matches
Mail list logo