Re: one click - two actions?

From: Date: Sun, 21 Jan 2007 10:34:23 +0000
Subject: Re: one click - two actions?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-247491@lists.php.net to get a copy of this message
At 1/21/2007 01:54 AM, pub wrote:
I am working on my query as you suggested. I have a joint query that seems to work except that I get the name of the company repeated for each job. Could you please help me figure out how to make it echo the company once and list all the jobs next to it on the same line and start a new line with the next company like you suggested bellow?
You want to output the company name only when it changes. I usually do this by keeping a variable equal to the previous value in the loop and compare it each time with the current value: PreviousCompany = ''; while (fetching data records) {
                if (PreviousCompany != CurrentCompany)
                {
                        output CurrentCompany;
                        PreviousCompany = CurrentCompany;
                }
        output Job;
} One markup structure you might consider for this application is the definition list: <dl>
        <dt>Company</dt>
        <dd>job 1</dd>
        <dd>job 2</dd>
        <dd>job 3</dd>
        <dd>job 4</dd>
        <dt>Company</dt>
        <dd>job 1</dd>
        <dd>job 2</dd>
        <dd>job 3</dd>
        <dd>job 4</dd>
        ...
</dl> Regards, Paul __________________________ Juniper Webcraft Ltd. http://juniperwebcraft.com

« previous php.general (#247491) next »