Re: Combine 2 Db Columns with an Array?

From: Date: Mon, 13 May 2002 18:48:08 +0000
Subject: Re: Combine 2 Db Columns with an Array?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-97398@lists.php.net to get a copy of this message
This is SQL not PHP.... You should be doing something like SELECT COLUMB + CLOLUM AS Something, SomethingElse, AnotherSomethingElse FROM TABLE Then you can reference Something as a normal colum in any database table.... Such as echo $Something... I'm not to sure about the syntax, have a look through the mysql manuals... It is mentioned there, with examples. Kind Regards, Chris Knipe MegaLAN Corporate InterNetworking Services Tel: +27 21 854 7064 Cell: +27 72 434 7582 ----- Original Message ----- From: "PHP User" <phpuser@chek.com> To: <php-general@lists.php.net> Sent: Monday, May 13, 2002 8:42 PM Subject: [PHP] Combine 2 Db Columns with an Array? > I am trying to find the best way to combine 2 columns in a MySQL Db call into > one by using an array. I've tried array_push, implode, explode, array_merge and > extract all with no luck. I feel I am close but have read all I can and still am > hitting a dead end. > I need to select a Title and Alternate title from a table, and then list the > results by BOTH the Title and Alternate Title. So the list that gets echoed out > would be a combined array of the Title column and the Alt_Title column. The idea > is to have each item listed twice, once by it's title and once by it's alternate > title. > I can not find a way to merge the 2 separate columns. > Here's what I'm trying to do: > > $result = mysql_query("SELECT Title, Alt_Title, Size, Price, More, Comment > ORDER BY title"); > > //magically combine the title & alt_title into on nice variable called > $Title > //or whatever > while ($db = mysql_fetch_array($result)) > { > echo "$Title"; > } > > >

« previous php.general (#97398) next »