So you are taking your results and putting it in an array, right? And you basically want to create two rows in your result array, for each row in the table?
$result = mysql_query("SELECT Title, Alt_Title, Size, Price, More, Comment FROM table"); while($row = mysql_fetch_array($result)) { $Title["Title"][] = $row["Title"]; $Title["Size"][] = $row["Size"]; $Title["Price"][] = $row["Price"]; $Title["More"][] = $row["More"]; $Title["Comment"][] = $row["Comment"]; if($row["Alt_Title"] != "") { $Title["Title"][] = $row["Alt_Title"]; $Title["Size"][] = $row["Size"]; $Title["Price"][] = $row["Price"]; $Title["More"][] = $row["More"]; $Title["Comment"][] = $row["Comment"]; } } ?? Like that. That'll basically take the results and for each row in the result, make two rows in $Title, one with the title set to the DB:Title, the other to DB:Alt_Title. It only creates the second row if the alt_title isn't an empty string, too. Don't know if that's nec. in your case. I'm sure there are other ways...maybe a different table design would be better, too. ---John Holmes... ----- Original Message ----- From: "PHP User" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, May 13, 2002 2: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"; > } > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php