Re: [PHP] mysql list to two-column list
On Mon, 2012-03-19 at 15:43 -0700, Tom Sparks wrote: I have a members list witch I print out once a week, I would like to make the list into two-column list, but I dont know where to start looking to change the code? here is the code $result = mysql_query(SELECT * FROM customers ORDER BY LastName); while($row = mysql_fetch_array($result)) { echo $row['LastName']; echo . $row['FirstName']; echo . $row['CustomNo']; echo br /; } example output: Bond James Bond 007 Quagmire Glenn 101 Griffin Peter 102 etc --- tom_a_sparks It's a nerdy thing I like to do Please use ISO approved file formats excluding Office Open XML - http://www.gnu.org/philosophy/no-word-attachments.html Ubuntu wiki page https://wiki.ubuntu.com/tomsparks 3 x (x)Ubuntu 10.04, Amiga A1200 WB 3.1, UAE AF 2006 Premium Edition, AF 2012 Plus Edition, Sam440 AOS 4.1.2, Roland DXY-1300 pen plotter, Cutok DC330 cutter/pen plotter Wanted: RiscOS system, GEOS system (C64/C128), Atari ST, Apple Macintosh (6502/68k/PPC only) How do you mean? In your example, it's a 3-column list (surname, forename, customer number) although you've added a 'cute' field to the first entry for giggles. It's a simple thing to join the first two fields, but what do you determine to be a single column? -- Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] mysql list to two-column list
--- On Tue, 20/3/12, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Mon, 2012-03-19 at 15:43 -0700, Tom Sparks wrote: I have a members list witch I print out once a week, I would like to make the list into two-column list, but I dont know where to start looking to change the code? here is the code $result = mysql_query(SELECT * FROM customers ORDER BY LastName); while($row = mysql_fetch_array($result)) { echo $row['LastName']; echo . $row['FirstName']; echo . $row['CustomNo']; echo br /; } example output: Bond James 007 Quagmire Glenn 101 Griffin Peter 102 etc --- tom_a_sparks It's a nerdy thing I like to do Please use ISO approved file formats excluding Office Open XML - http://www.gnu.org/philosophy/no-word-attachments.html Ubuntu wiki page https://wiki.ubuntu.com/tomsparks How do you mean? my goal is to do something phonebook like In your example, it's a 3-column list (surname, forename, customer number) although you've added a 'cute' field to the first entry for giggles. It's a simple thing to join the first two fields, but what do you determine to be a single column? -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql list to two-column list
On Mon, 2012-03-19 at 16:09 -0700, Tom Sparks wrote: --- On Tue, 20/3/12, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Mon, 2012-03-19 at 15:43 -0700, Tom Sparks wrote: I have a members list witch I print out once a week, I would like to make the list into two-column list, but I dont know where to start looking to change the code? here is the code $result = mysql_query(SELECT * FROM customers ORDER BY LastName); while($row = mysql_fetch_array($result)) { echo $row['LastName']; echo . $row['FirstName']; echo . $row['CustomNo']; echo br /; } example output: Bond James 007 Quagmire Glenn 101 Griffin Peter 102 etc --- tom_a_sparks It's a nerdy thing I like to do Please use ISO approved file formats excluding Office Open XML - http://www.gnu.org/philosophy/no-word-attachments.html Ubuntu wiki page https://wiki.ubuntu.com/tomsparks How do you mean? my goal is to do something phonebook like In your example, it's a 3-column list (surname, forename, customer number) although you've added a 'cute' field to the first entry for giggles. It's a simple thing to join the first two fields, but what do you determine to be a single column? Your reply of 9 words adds no extra information. Rather than have us all guess what you want, try and tell us specifically what it is that you want. -- Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] mysql list to two-column list
my goal is to do something phonebook like Your reply of 9 words adds no extra information. Rather than have us all guess what you want, try and tell us specifically what it is that you want. Hi Tom I *think* what want to be asking is, what HTML do I change/add such that my data coming from the database will format on the page in the browser like a phone book (in columns)? If so, then: This is a PHP list where people mostly discuss PHP-specific things.. whereas it seem what you need is to learn some basic HTML which will allow you to format content on a page so it looks like a phone book. I would say: Forget your database data for a day. Start with seeing if you can just write some static HTML that looks like what you want (formatted like a phone book), and THEN alter your real PHP code so that it spits out the HTML that mimics what you mocked up. If you get stuck with the HTML part of this task, then consult a good HTML list. If you get stuck with something specific to PHP, then ask again about that, here. Good luck, -Govinda -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql list to two-column list
--- On Tue, 20/3/12, Ashley Sheridan a...@ashleysheridan.co.uk wrote: From: Ashley Sheridan a...@ashleysheridan.co.uk Subject: Re: [PHP] mysql list to two-column list To: Tom Sparks tom_a_spa...@yahoo.com.au Cc: php-general php-general@lists.php.net Received: Tuesday, 20 March, 2012, 10:15 AM On Mon, 2012-03-19 at 16:09 -0700, Tom Sparks wrote: --- On Tue, 20/3/12, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Mon, 2012-03-19 at 15:43 -0700, Tom Sparks wrote: I have a members list witch I print out once a week, I would like to make the list into two-column list, but I dont know where to start looking to change the code? here is the code $result = mysql_query(SELECT * FROM customers ORDER BY LastName); while($row = mysql_fetch_array($result)) { echo $row['LastName']; echo . $row['FirstName']; echo . $row['CustomNo']; echo br /; } example output: Bond James 007 Quagmire Glenn 101 Griffin Peter 102 etc --- tom_a_sparks It's a nerdy thing I like to do Please use ISO approved file formats excluding Office Open XML - http://www.gnu.org/philosophy/no-word-attachments.html Ubuntu wiki page https://wiki.ubuntu.com/tomsparks How do you mean? my goal is to do something phonebook like In your example, it's a 3-column list (surname, forename, customer number) although you've added a 'cute' field to the first entry for giggles. It's a simple thing to join the first two fields, but what do you determine to be a single column? Your reply of 9 words adds no extra information. Rather than have us all guess what you want, try and tell us specifically what it is that you want. Cleveland Brown | Griffin family Cleveland Brown, Jr. | Brian Griffin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql list to two-column list
please delete me --- tom_a_sparks It's a nerdy thing I like to do Please use ISO approved file formats excluding Office Open XML - http://www.gnu.org/philosophy/no-word-attachments.html Ubuntu wiki page https://wiki.ubuntu.com/tomsparks 3 x (x)Ubuntu 10.04, Amiga A1200 WB 3.1, UAE AF 2006 Premium Edition, AF 2012 Plus Edition, Sam440 AOS 4.1.2, Roland DXY-1300 pen plotter, Cutok DC330 cutter/pen plotter Wanted: RiscOS system, GEOS system (C64/C128), Atari ST, Apple Macintosh (6502/68k/PPC only) --- On Tue, 20/3/12, Tom Sparks tom_a_spa...@yahoo.com.au wrote: From: Tom Sparks tom_a_spa...@yahoo.com.au Subject: Re: [PHP] mysql list to two-column list To: a...@ashleysheridan.co.uk Cc: php-general php-general@lists.php.net Received: Tuesday, 20 March, 2012, 10:41 AM --- On Tue, 20/3/12, Ashley Sheridan a...@ashleysheridan.co.uk wrote: From: Ashley Sheridan a...@ashleysheridan.co.uk Subject: Re: [PHP] mysql list to two-column list To: Tom Sparks tom_a_spa...@yahoo.com.au Cc: php-general php-general@lists.php.net Received: Tuesday, 20 March, 2012, 10:15 AM On Mon, 2012-03-19 at 16:09 -0700, Tom Sparks wrote: --- On Tue, 20/3/12, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Mon, 2012-03-19 at 15:43 -0700, Tom Sparks wrote: I have a members list witch I print out once a week, I would like to make the list into two-column list, but I dont know where to start looking to change the code? here is the code $result = mysql_query(SELECT * FROM customers ORDER BY LastName); while($row = mysql_fetch_array($result)) { echo $row['LastName']; echo . $row['FirstName']; echo . $row['CustomNo']; echo br /; } example output: Bond James 007 Quagmire Glenn 101 Griffin Peter 102 etc --- tom_a_sparks It's a nerdy thing I like to do Please use ISO approved file formats excluding Office Open XML - http://www.gnu.org/philosophy/no-word-attachments.html Ubuntu wiki page https://wiki.ubuntu.com/tomsparks How do you mean? my goal is to do something phonebook like In your example, it's a 3-column list (surname, forename, customer number) although you've added a 'cute' field to the first entry for giggles. It's a simple thing to join the first two fields, but what do you determine to be a single column? Your reply of 9 words adds no extra information. Rather than have us all guess what you want, try and tell us specifically what it is that you want. Cleveland Brown | Griffin family Cleveland Brown, Jr. | Brian Griffin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql list to two-column list
On 19 Mar 2012, at 22:43, Tom Sparks wrote: I have a members list witch I print out once a week, I would like to make the list into two-column list, but I dont know where to start looking to change the code? here is the code $result = mysql_query(SELECT * FROM customers ORDER BY LastName); while($row = mysql_fetch_array($result)) { echo $row['LastName']; echo . $row['FirstName']; echo . $row['CustomNo']; echo br /; } The following is untested so it may contain syntax errors, but I'm pretty sure the logic is sound and I think it will give you what you want. You may want to play with the cellpadding value to adjust the amount of space between the table cells. echo 'table cellspacing=0 cellpadding=5 border=0'; $column = 1; while ($row = mysql_fetch_assoc($result)) { if ($column == 1) { echo 'tr'.PHP_EOL; } echo ' td'.$row['LastName'].' '.$row['FirstName'].' '.$row['CustomNo'].'/td'; $column++; if ($column 2) { echo '/tr'.PHP_EOL; $column = 1; } } if ($column == 2) { echo 'tdnbsp;/td'.PHP_EOL; } echo '/tr/table'; Assuming I'm right in my interpretation of what you want, the following needs to be said... this is *very* basic HTML being rendered by *very* basic PHP. I suggest you learn about basic HTML first, then learn basic PHP, then work out how to use logic in PHP to build the HTML you want. If you're unsure how the above works, start by viewing the source of the page in your browser. If it's still not clear, run it in your head. Use two pieces of paper, one to store the variables and the other to keep track of the output. Go through each loop and for each line update the variables and update the output for each echo statement. If I got what you want wrong then I have absolutely no clue what you're after. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql list
[snip] if anyone is on the mysql list why do i keep getting this , i can post anything dammit To bypass the filter you must include one of the following words in your message: sql,query [/snip] Follow the directions to make sure the message gets to the list. My original reply to this got bounced from the PHP list. HTH! Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php