Re: [PHP] Getting knotted with quotes encoding - (one possible solution)

2012-03-19 Thread tamouse mailing lists
On Sun, Mar 18, 2012 at 10:19 PM, Tamara Temple
 wrote:
> On Tue, 13 Mar 2012 16:35:44 +0200, Arno Kuhl  sent:
>
>> From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk]
>> Sent: 13 March 2012 03:25 PM
>> To: a...@dotcontent.net; php-general@lists.php.net
>> Subject: Re: [PHP] Getting knotted with quotes encoding
>>
>>
>> Arno Kuhl  wrote:
>>
>>> I've been battling with quotes encoding when outputting javascript with
>>> php.
>>> It can't be unique, so I'm hoping someone has a working solution
>>> they're willing to share.
>>>
>>> The following works perfectly as long as there aren't any single quotes
>>> in the link text:
>>>        echo ">> class='linkSel'>$sTitle";
>>>
>>> if $sTitle has the value    What's new    it outputs:
>>>        What's new
>>>
>>> It displays fine, but javascript complains with:
>>>        Expected ')'  linkmanager.php Line:525 Char:63
>>>
>>>
>>> So I fix this by swapping the double and single quotes around:
>>>        echo ">> class='linkSel'>$sTitle";
>>>
>>> Now for that specific link it outputs:
>>>        What's new And javascript is happy.
>>>
>>> But elsewhere there's a link     Fred "Buster" Cox     and it outputs:
>>>        Fred "Buster"
>>> Cox
>>>
>>> Again it displays fine, but javascript complains with:
>>>        Expected ')'  linkmanager.php Line:743 Char:77
>>>
>>>
>>> So it looks like I can't have links that include single quotes and
>>> double quotes, only one or the other.
>>>
>>> One work-around I thought of was to convert any link texts that
>>> included double quotes into single quotes when the content is posted,
>>> and it would then be displayed with single quotes even though the user
>>> entered double quotes. It's far from ideal but it would work, though I
>>> can think of a few situations where it would be quite confusing to the
>>> reader. Are there any other solutions that would allow both types of
>>> quotes without any conversions?
>>>
>>> Cheers
>>> Arno
>>>
>>>
>>> --
>>
>>
>> You aren't escaping the quotes correctly when they go into your  output.
>> You're escaping them for html not javascript. Javascript  (like php) escapes
>> single quotes inside a single quote string with a  back slash.
>>
>>
>>  Thanks,
>> Ash
>> http://ashleysheridan.co.uk
>> -
>>
>> Thanks for that Ashley.
>> You're right about the encoding.
>> I had a line prior to that:
>>        $sTitle = htmlentities($title, ENT_QUOTES, 'ISO-8859-1', FALSE);
>> Which encoded the quotes.
>>
>>
>> I couldn't find anything so made a function, which might be useful  for
>> others.
>> It’s a first shot, I'm sure there are ways to improve performance.
>> I also changed the encoding to exclude single quotes.
>> (I'm sure the indenting will get screwed up in the mail)
>>
>>
>> $sTitle = fixSingleQuotes(htmlentities($title, ENT_COMPAT,  'ISO-8859-1',
>> FALSE));
>>
>> .
>>
>>
>> 
>> // convert single quotes to curly quotes, xml compliant
>> // assumes apostrophes must be between 2 alpha chars
>> // and any other ' is a single quote
>> // ‘ = left single quote
>> // ’ = right single quote and apostrophe
>> function fixSingleQuotes($sText)
>> {
>>        if (strpos($sText, "'") !== FALSE) {
>>                // there are quotes to convert
>>                $bOpenQuote = FALSE;
>>                $arrAlpha = explode(' ', "a b c d e f g h i j k l m n o p q
>> r s t  u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
>>                $arrText = str_split($sText);
>>                while (($pos = strpos($sText, "'")) !== FALSE) {
>>                        if ($pos == 0) {
>>                                // must be an open quote in first pos
>>                                $sText = "‘".substr($sText, 1);
>>                                $bOpenQuote = TRUE;
>>                        } else {
>>                                if (in_array($arrText[$pos-1], $arrAlpha)
>>  AND   in_array($arrText[$pos+1], $arrAlpha)) {
>>                                        // apostrophe
>>                                        $quote = "’";
>>                                } else {
>>                                        // quote
>>                                        if (!$bOpenQuote) {
>>                                                $quote = "‘";
>>                                                $bOpenQuote = TRUE;
>>                                        } else {
>>                                                $quote = "’";
>>                                                $bOpenQuote = FALSE;
>>                                        }
>>                                }
>>                                $sText = substr($sText, 0,
>> $pos).$quote.substr($sText, $pos+1);
>>                        }
>>                }
>>        }
>>        return ($sText);
>>
>> } //fixSingleQuotes()
>>
>>
>>
>> Cheers
>> Arno
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscri

Re: [PHP] Parse errors

2012-03-19 Thread tamouse mailing lists
On Sun, Mar 18, 2012 at 2:18 PM, Tim Streater  wrote:
> On 18 Mar 2012 at 17:46, Simon J Welsh  wrote:
>
>> This is expected. The error doesn't occur to the second file is included, so
>> everything in the first included file is parsed and run before execution is
>> halted.
>
> Simon,
>
> Thanks for that. Looks like I should be able to catch most places where an 
> error might occur.

I tend to do a syntax check with php -l on the command line after
editing to see whatever errors might occur before I run the code on
the web site.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] questions about $_SERVER

2012-03-19 Thread tamouse mailing lists
On Sat, Mar 10, 2012 at 7:43 PM, Tedd Sperling  wrote:
> On Mar 10, 2012, at 3:53 PM, tamouse mailing lists wrote:
>> On Sat, Mar 10, 2012 at 9:37 AM, Tedd Sperling  
>> wrote:
>>> That's correct, but to access those variables outside of their scope (such 
>>> as a function) you do via a SuperGlobal, namely $GLOBAL['whatever'].
>>>
>>> As such, there are no "globals" in PHP other than SuperGlobals. As I said, 
>>> if I'm wrong, please show me otherwise.
>>
>> I guess I don't know what you mean by "globals". I know what globals
>> are, but not "globals".
>
> I don't understand your question. I know what questions are, but not your 
> question. :-)

Well, I've been pondering this for a while, and now I'm sure.

 -> kill file

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] CMS identification

2012-03-19 Thread Stuart Dallas
On 19 Mar 2012, at 02:20, Robert Cummings wrote:

> On 12-03-18 06:42 PM, Stuart Dallas wrote:
>> On 18 Mar 2012, at 22:32, Alain Roger wrote:
>> 
>>> ok so here it is: 
>>> http://i220.photobucket.com/albums/dd277/alainroger/cms-login.png
>> 
>> Pass, not one I'm familiar with and a Google Image search for cms login 
>> doesn't show anything similar. If I were you I'd tell him to give me access 
>> to it so I can have a look for myself.
> 
> On google image search click on the camera icon... then paste in the URL with 
> the screen shot.

How freakin' awesome is that?!?!?

http://www.idep-support.com/page.php?srid=33

Thanks Rob!

-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] Re: Got HTML5 History API + caching LICKED, I think,

2012-03-19 Thread rene7705
On Mon, Mar 19, 2012 at 11:07 AM, Ege Sertçetin wrote:

> Press F12 for developer tools. Then select browser mode to ie8 or ie7.
>
> Oh SWEET :) Didn't know that, will do it right now! :)


Re: [PHP] Re: Got HTML5 History API + caching LICKED, I think,

2012-03-19 Thread rene7705
On Mon, Mar 19, 2012 at 11:24 AM, rene7705  wrote:

>
>
> On Mon, Mar 19, 2012 at 11:07 AM, Ege Sertçetin wrote:
>
>> Press F12 for developer tools. Then select browser mode to ie8 or ie7.
>>
>> Oh SWEET :) Didn't know that, will do it right now! :)
>

With this tip, I've just fixed the remaining IE8 and IE7 bugs.
http://mediabeez.ws and the zip available for download there have been
updated just now..


[PHP] Using a stream filter to do a search and replace on an XML file.

2012-03-19 Thread Richard Quadling
Hello.

Just learning about stream filtering and have 2 questions I hope
someone can give me some pointers on.


1 - Bucketing.

In reading a bit about how this works, the data is passed in chunks
through the filter - known as a bucket brigade.

How does this work if, for example, the search string is chopped by
the bucketing system? It would seem that you would end up with 2 parts
of the search element, neither would be matched for replacing and then
the whole element would be reconstituted in the output.

My filter method is ...

function filter($r_In, $r_Out, &$i_Consumed, $b_Closing)
{
while ($o_Bucket = stream_bucket_make_writeable($r_In))
{
$o_Bucket->data = preg_replace('`<(/?)(\d+)`', 
'<$1fixed_$2',
$o_Bucket->data);
$i_Consumed += $o_Bucket->datalen;
stream_bucket_append($r_Out, $o_Bucket);
}

return PSFS_PASS_ON;
}

This is working fine (so far as I can tell as SimpleXMLIterator is now
happy to read the XML file), but I'm guessing I'm missing something
here if my understanding is correct.




2 - Stream wrapping.

At the moment, we download a .gz file and decompress it into the .xml
file. I know I can use a zlib:// stream wrapper to save me having to
decode the .gz file first. This means smaller downloads and less
storage. We can even use the zlib:// filter on the URL, but we cache
the .gz file locally, so that isn't important.

But for a small set of files (their origin is known, so I can create a
rule for this issue), I have to expand the .gz file first and then fix
the file using the filter above. I then have two paths to load the xml
- either a zlib:// decompress stream or a straight local file.

I'd like to work out how to create a stream wrapper to allow me to say
SOMETHING like ...

$o_MySXI = new 
SimpleXMLIterator('xml.NoNumericTags://compress.zlib:///development/BadlyFormed.gz');

If this was possible, I'd be a LOT happier and could simply stream
from the .gz files without needing to hold onto anything.


Ideas/suggestions/examples/code gratefully received.

Regards,

Richard.

-- 
Richard Quadling
Twitter : EE : Zend : Fantasy Shopper
@RQuadling : http://e-e.com/M_248814.html : http://bit.ly/9O8vFY :
http://fan.sh/106/5tw

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Getting knotted with quotes encoding - (one possible solution)

2012-03-19 Thread Arno Kuhl
-Original Message-
From: tamouse mailing lists [mailto:tamouse.li...@gmail.com] 
Sent: 19 March 2012 10:28 AM
To: php-general@lists.php.net
Subject: Re: [PHP] Getting knotted with quotes encoding - (one possible 
solution)

On Sun, Mar 18, 2012 at 10:19 PM, Tamara Temple 
 wrote:
> On Tue, 13 Mar 2012 16:35:44 +0200, Arno Kuhl  sent:
>
>> From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk]
>> Sent: 13 March 2012 03:25 PM
>> To: a...@dotcontent.net; php-general@lists.php.net
>> Subject: Re: [PHP] Getting knotted with quotes encoding
>>
>>
>> Arno Kuhl  wrote:
>>
>>> I've been battling with quotes encoding when outputting javascript 
>>> with php.
>>> It can't be unique, so I'm hoping someone has a working solution 
>>> they're willing to share.
>>>
>>> The following works perfectly as long as there aren't any single 
>>> quotes in the link text:
>>>echo ">> class='linkSel'>$sTitle";
>>>
>>> if $sTitle has the valueWhat's newit outputs:
>>>>> onclick="insertLink('article/whats-new.html','What's
>>> new')" class='linkSel'>What's new
>>>
>>> It displays fine, but javascript complains with:
>>>Expected ')'  linkmanager.php Line:525 Char:63
>>>
>>>
>>> So I fix this by swapping the double and single quotes around:
>>>echo ">> class='linkSel'>$sTitle";
>>>
>>> Now for that specific link it outputs:
>>>>> onclick='insertLink("article/whats-new.html","What's
>>> new")' class='linkSel'>What's new And javascript is happy.
>>>
>>> But elsewhere there's a link Fred "Buster" Cox and it outputs:
>>>>> onclick='insertLink("article/fred-buster-cox.html","Fred
>>> "Buster" Cox")' class='linkSel'>Fred "Buster" 
>>> Cox
>>>
>>> Again it displays fine, but javascript complains with:
>>>Expected ')'  linkmanager.php Line:743 Char:77
>>>
>>>
>>> So it looks like I can't have links that include single quotes and 
>>> double quotes, only one or the other.
>>>
>>> One work-around I thought of was to convert any link texts that 
>>> included double quotes into single quotes when the content is 
>>> posted, and it would then be displayed with single quotes even 
>>> though the user entered double quotes. It's far from ideal but it 
>>> would work, though I can think of a few situations where it would be 
>>> quite confusing to the reader. Are there any other solutions that 
>>> would allow both types of quotes without any conversions?
>>>
>>> Cheers
>>> Arno
>>>
>>>
>>> --
>>
>>
>> You aren't escaping the quotes correctly when they go into your  output.
>> You're escaping them for html not javascript. Javascript  (like php) 
>> escapes single quotes inside a single quote string with a  back slash.
>>
>>
>>  Thanks,
>> Ash
>> http://ashleysheridan.co.uk
>> -
>>
>> Thanks for that Ashley.
>> You're right about the encoding.
>> I had a line prior to that:
>>$sTitle = htmlentities($title, ENT_QUOTES, 'ISO-8859-1', 
>> FALSE); Which encoded the quotes.
>>
>>
>> I couldn't find anything so made a function, which might be useful  
>> for others.
>> It’s a first shot, I'm sure there are ways to improve performance.
>> I also changed the encoding to exclude single quotes.
>> (I'm sure the indenting will get screwed up in the mail)
>>
>>
>> $sTitle = fixSingleQuotes(htmlentities($title, ENT_COMPAT,  
>> 'ISO-8859-1', FALSE));
>>
>> .
>>
>>
>> /
>> /// // convert single quotes to curly quotes, xml compliant 
>> // assumes apostrophes must be between 2 alpha chars // and any other 
>> ' is a single quote // ‘ = left single quote // ’ = right 
>> single quote and apostrophe function fixSingleQuotes($sText) {
>>if (strpos($sText, "'") !== FALSE) {
>>// there are quotes to convert
>>$bOpenQuote = FALSE;
>>$arrAlpha = explode(' ', "a b c d e f g h i j k l m n 
>> o p q r s t  u v w x y z A B C D E F G H I J K L M N O P Q R S T U V 
>> W X Y Z");
>>$arrText = str_split($sText);
>>while (($pos = strpos($sText, "'")) !== FALSE) {
>>if ($pos == 0) {
>>// must be an open quote in first pos
>>$sText = "‘".substr($sText, 1);
>>$bOpenQuote = TRUE;
>>} else {
>>if (in_array($arrText[$pos-1], 
>> $arrAlpha)
>>  AND   in_array($arrText[$pos+1], $arrAlpha)) {
>>// apostrophe
>>$quote = "’";
>>} else {
>>// quote
>>if (!$bOpenQuote) {
>>$quote = "‘";
>>$bOpenQuote = TRUE;
>>} else {
>>   

[PHP] mysql list to two-column list

2012-03-19 Thread Tom Sparks
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 "";
  }
"

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)

--
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

2012-03-19 Thread Ashley Sheridan
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 "";
>   }
> "
> 
> 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

2012-03-19 Thread Tom Sparks
--- On Tue, 20/3/12, Ashley Sheridan  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 "";
>>  }
>>"

>>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

2012-03-19 Thread Ashley Sheridan
On Mon, 2012-03-19 at 16:09 -0700, Tom Sparks wrote:

> --- On Tue, 20/3/12, Ashley Sheridan  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 "";
> >>  }
> >>"
> 
> >>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

2012-03-19 Thread Govinda
>> 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

2012-03-19 Thread Tom Sparks
--- On Tue, 20/3/12, Ashley Sheridan  wrote:

From: Ashley Sheridan 
Subject: Re: [PHP] mysql list to two-column list
To: "Tom Sparks" 
Cc: "php-general" 
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  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 "";
>>  }
>>"

>>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

2012-03-19 Thread Tom Sparks
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  wrote:

> From: Tom Sparks 
> Subject: Re: [PHP] mysql list to two-column list
> To: a...@ashleysheridan.co.uk
> Cc: "php-general" 
> Received: Tuesday, 20 March, 2012, 10:41 AM
> --- On Tue, 20/3/12, Ashley Sheridan
> 
> wrote:
> 
> From: Ashley Sheridan 
> Subject: Re: [PHP] mysql list to two-column list
> To: "Tom Sparks" 
> Cc: "php-general" 
> 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 
> 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 "";
> >>  }
> >>"
> 
> >>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

2012-03-19 Thread Stuart Dallas
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 "";
>  }
> "


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 '';
$column = 1;
while ($row = mysql_fetch_assoc($result))
{
  if ($column == 1) {
echo ''.PHP_EOL;
  }
  echo '  '.$row['LastName'].' '.$row['FirstName'].' 
'.$row['CustomNo'].'';
  $column++;
  if ($column > 2) {
echo ''.PHP_EOL;
$column = 1;
  }
}
if ($column == 2) {
  echo ' '.PHP_EOL;
}
echo '';

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