php-general Digest 3 Jul 2008 15:55:08 -0000 Issue 5548

Topics (messages 276241 through 276255):

PHPNews Vs phpns
        276241 by: John Comerford

Re: Log files
        276242 by: Shawn McKenzie
        276243 by: John Comerford
        276244 by: Haluk AKIN
        276245 by: Per Jessen

Re: [SPAM] Re: [PHP] how to create a slide show using PHP5
        276246 by: Chris Scott

PHPExcel
        276247 by: Dan Shirah
        276248 by: Dan Shirah
        276249 by: Jim Lucas
        276250 by: Dan Shirah
        276251 by: Jim Lucas
        276252 by: Robert Cummings
        276254 by: Richard Heyes
        276255 by: Shawn McKenzie

Help with query MySQL and PHP
        276253 by: axis

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message --- I am looking at including news on a website I am putting together. From my google searches it seems the two main players are PHPNews and phpns.

Are these the main open source news systems ?
Is one considered better than the other ?
Anyone got any real world experiences with either of these products ?
Anyone recommend an alternative ?

TIA,
 JC

--- End Message ---
--- Begin Message ---
Mark Bomgardner wrote:
I am writing an application in which I want to create log files.  I am
weighing the difference between using text files and using a database to
house the data.  It appears to me that there is really no advantage either
way or is there?  There are pros and cons to both methods, but I am
concerned about opening and closing a text file some many times that it may
cause and issue. The file may be opened and closed 1,000 or more times a
day.

Opinions please..

markb



Using a database you're hitting a file the same number of times (the database is in a file or files) but you have the mem/cpu overhead of the db itself. Having said that, if you are using a database already for the site then might as well log to it. I wouldn't implement a database only for the purpose of logging.

-Shawn

--- End Message ---
--- Begin Message --- If you are logging errors, then maybe you should look at using a file instead of a database table. I have seen an instance where a system used a table for error logging and writing to the log table caused and error, you can guess where that left things.....

Shawn McKenzie wrote:
Mark Bomgardner wrote:
I am writing an application in which I want to create log files.  I am
weighing the difference between using text files and using a database to
house the data. It appears to me that there is really no advantage either
way or is there?  There are pros and cons to both methods, but I am
concerned about opening and closing a text file some many times that it may
cause and issue. The file may be opened and closed 1,000 or more times a
day.

Opinions please..

markb



Using a database you're hitting a file the same number of times (the database is in a file or files) but you have the mem/cpu overhead of the db itself. Having said that, if you are using a database already for the site then might as well log to it. I wouldn't implement a database only for the purpose of logging.

-Shawn



--
Option Systems Pty. Ltd.
53 Waverley Road, Malvern East, VIC 3145
PO Box 7, Caulfield East, VIC 3145
Phone: 03 9571 0100  Fax: 03 9571 0500

The information in this e-mail is confidential and is intended solely for the addressee. Any views or opinions presented are solely those of the author and do not necessarily represent those of Option Systems Pty.Ltd.
If you are not the intended recipient, please delete this message and
contact the sender.


--- End Message ---
--- Begin Message ---
If you are planning to come up with relations between these errors and other
activities on your website then you need to use a database.
If you will use this error log only for debugging purposes then a text file
should be enough.

>From a coder's perspective the workload of coding both of these methods
should be similar.

Opening and closing a text file 1,000 or more times a day won't be a problem
either. Similarly, opening&closing that many database connections won't be
any problem either. Therefore, if I were you I wouldn't worry about the
performance.

Cheers,
Haluk



-----Original Message-----
From: John Comerford [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 03, 2008 12:54 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Re: Log files

If you are logging errors, then maybe you should look at using a file 
instead of a database table.  I have seen an instance where a system 
used a table for error logging and writing to the log table caused and 
error, you can guess where that left things.....

Shawn McKenzie wrote:
> Mark Bomgardner wrote:
>> I am writing an application in which I want to create log files.  I am
>> weighing the difference between using text files and using a database to
>> house the data.  It appears to me that there is really no advantage 
>> either
>> way or is there?  There are pros and cons to both methods, but I am
>> concerned about opening and closing a text file some many times that 
>> it may
>> cause and issue. The file may be opened and closed 1,000 or more times a
>> day.
>>
>>  
>>
>> Opinions please..
>>
>>  
>>
>> markb
>>
>>
>
> Using a database you're hitting a file the same number of times (the 
> database is in a file or files) but you have the mem/cpu overhead of 
> the db itself.  Having said that, if you are using a database already 
> for the site then might as well log to it.  I wouldn't implement a 
> database only for the purpose of logging.
>
> -Shawn
>


-- 
Option Systems Pty. Ltd.
53 Waverley Road, Malvern East, VIC 3145
PO Box 7, Caulfield East, VIC 3145
Phone: 03 9571 0100  Fax: 03 9571 0500
 
The information in this e-mail is confidential and is intended solely for
the addressee. 
Any views or opinions presented are solely those of the author 
and do not necessarily represent those of Option Systems Pty.Ltd.
If you are not the intended recipient, please delete this message and
contact the sender.


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


--- End Message ---
--- Begin Message ---
Mark Bomgardner wrote:

> way or is there?  There are pros and cons to both methods, but I am
> concerned about opening and closing a text file some many times that
> it may cause and issue. The file may be opened and closed 1,000 or
> more times a day.

1000 times?  Nothing to worry about.  Even if you were talking about
100,000 times a day.



/Per Jessen, Zürich


--- End Message ---
--- Begin Message ---

> -----Original Message-----
> From: philip [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, July 02, 2008 10:03 PM
> To: Bastien Koert
> Cc: [EMAIL PROTECTED]
> Subject: [SPAM] Re: [PHP] how to create a slide show using PHP5
> Importance: Low
> 
> Bastien Koert wrote:
> >
> >
> > On Wed, Jul 2, 2008 at 4:37 PM, philip <[EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]>> wrote:
> >
> >     Hi everyone,
> >
> >     I want to create a slide show of photos for my web site. How is
> >     this done using php5? I am using Opensuse 10.3, Apache, PHP5.
> >
> >     TIA for any assistance,
> >
> >     Philip
> >
> >     --
> >     Philip Ramsey
> >     learning PHP and MySQL for building a better world
> >     philipramsey.is-a-geek.net <http://philipramsey.is-a-geek.net>
> >
> >     --
> >     PHP General Mailing List (http://www.php.net/)
> >     To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> > 2 parts to this
> >
> > 1. pull a series on [random] images from the system to show the user
> > 2. client side javascript code to load the images in a slide show
fashion
> >
> > You may want to get an existing one and pull it apart to see how
> > they've done it
> >
> > --
> >
> > Bastien
> >
> > Cat, the other other white meat
> Hi Bastien,
> 
> Thank you for your quick response. Where may I find sample? I tried
> searching the web but only found samples and tutorials that required
> flash for the actual slide show. Since I run Linux and
Adobe/Macromedia
> do not make a flash editor for Linux, flash is not an option.
> 
> TIA,
> 
> Philip
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

Flash is still an option if you use Ming:
http://uk.php.net/manual/en/book.ming.php



--- End Message ---
--- Begin Message ---
Happy 4th of July!

I am having a little bit of a problem using PHPExcel. I think I'm doing
everything right but apparently not! I am basically trying to output results
of a query to Excel using PHPExcel.

My query works fine, my variables are being passed correctly, my database
connection is fine...within my while () loop the echo "This ".$stat_year."
".$stat_month."<br />\n"; properly returns all of the years and months for
my query. But for whatever reason when I try and put those vaules in the
Excel objects and export the spreadsheet, the values of my cells are always
blank.

Any ideas?


/** PHPExcel */
include 'PHPExcel.php';

/** PHPExcel_Writer_Excel2007 */
include 'PHPExcel/Writer/Excel5.php';

// Create new PHPExcel object
echo date('H:i:s') . " Create new PHPExcel object<br />\n";
$objPHPExcel = new PHPExcel();

// Add some data, we will use printing features
$name_code = $_GET['name'];
// echo $name;
$case_age = $_GET['case_age'];
// echo $case_age;
$case_cat = $_GET['case_cat'];
// echo $case_cat;
$case_status = $_GET['case_status'];
// echo $case_status;
include 'Conn/prpr_ifx.php';
 if (!$connect_id = ifx_connect("[EMAIL PROTECTED]", $user, $pass)) { // THE
ACTUAL CONNECTION
     echo "Unable to connect to Informix Database\n"; // DISPLAY IF
CONNECTION FAILS
    exit();
 }
$sql = "SELECT * FROM brev_pending_summary_detail WHERE name =
'$name_code'";
 if (!empty($case_age)) {
  $sql.=" AND case_age_group = '$case_age'";
 }
 if (!empty($case_cat)) {
  $sql.=" AND case_category = '$case_cat'";
 }
 if (!empty($case_status)) {
  $sql.=" AND case_status = '$case_status'";
 } // Start our query of the database
$query = ifx_query($sql, $connect_id);

echo date('H:i:s') . " Add some data<br />\n";
if(!empty($query)) {
while ($row = ifx_fetch_row($query)) {
 $stat_year = $row['stat_year'];
 $stat_month = $row['stat_month'];
 echo "This ".$stat_year." ".$stat_month."<br />\n";
 $objPHPExcel->getActiveSheet()->setCellValue('A' . $stat_year);
 $objPHPExcel->getActiveSheet()->setCellValue('B' . $stat_month);
 }
}

// Set header and footer. When no different headers for odd/even are used,
odd header is assumed.
echo date('H:i:s') . " Set header/footer<br />\n";
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&C&HPlease
treat this document as confidential!');
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' .
$objPHPExcel->getProperties()->getTitle() . '&RPage &P of &N');

// Set page orientation and size
echo date('H:i:s') . " Set page orientation and size<br />\n";
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);

// Rename sheet
echo date('H:i:s') . " Rename sheet<br />\n";
$objPHPExcel->getActiveSheet()->setTitle('Pending Summary');


// Set active sheet index to the first sheet, so Excel opens this as the
first sheet
$objPHPExcel->setActiveSheetIndex(0);


// Save Excel 5 file
echo date('H:i:s') . " Write to Excel2005 format<br />\n";
$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
$objWriter->save(str_replace('.php', '.xls', __FILE__));

// Echo done
echo date('H:i:s') . " Done writing file.\r\n";

--- End Message ---
--- Begin Message ---
Okay, I found PART of my problem.

$objPHPExcel->getActiveSheet()->setCellValue('A' . $stat_year);
$objPHPExcel->getActiveSheet()->setCellValue('B' . $stat_month);

I must have mistyped and put period "." instead of comma "," to seperate the
cell number from the variable.  Fixed that and now I get something...what I
get now is one row of data printed out on row 65,536 in Excel (I believe
this is the very last row of data allowed by Excel)

So, instead of printing out the 128 results I should get form the loop, it
only prints out one result on the max row available in Excel.

Ideas?

--- End Message ---
--- Begin Message ---
Dan Shirah wrote:
Happy 4th of July!

I am having a little bit of a problem using PHPExcel. I think I'm doing
everything right but apparently not! I am basically trying to output results
of a query to Excel using PHPExcel.

My query works fine, my variables are being passed correctly, my database
connection is fine...within my while () loop the echo "This ".$stat_year."
".$stat_month."<br />\n"; properly returns all of the years and months for
my query. But for whatever reason when I try and put those vaules in the
Excel objects and export the spreadsheet, the values of my cells are always
blank.

Any ideas?


/** PHPExcel */
include 'PHPExcel.php';

/** PHPExcel_Writer_Excel2007 */
include 'PHPExcel/Writer/Excel5.php';

// Create new PHPExcel object
echo date('H:i:s') . " Create new PHPExcel object<br />\n";
$objPHPExcel = new PHPExcel();

// Add some data, we will use printing features
$name_code = $_GET['name'];
// echo $name;
$case_age = $_GET['case_age'];
// echo $case_age;
$case_cat = $_GET['case_cat'];
// echo $case_cat;
$case_status = $_GET['case_status'];
// echo $case_status;
include 'Conn/prpr_ifx.php';
 if (!$connect_id = ifx_connect("[EMAIL PROTECTED]", $user, $pass)) { // THE
ACTUAL CONNECTION
     echo "Unable to connect to Informix Database\n"; // DISPLAY IF
CONNECTION FAILS
    exit();
 }
$sql = "SELECT * FROM brev_pending_summary_detail WHERE name =
'$name_code'";
 if (!empty($case_age)) {
  $sql.=" AND case_age_group = '$case_age'";
 }
 if (!empty($case_cat)) {
  $sql.=" AND case_category = '$case_cat'";
 }
 if (!empty($case_status)) {
  $sql.=" AND case_status = '$case_status'";
 } // Start our query of the database
$query = ifx_query($sql, $connect_id);

echo date('H:i:s') . " Add some data<br />\n";
if(!empty($query)) {
while ($row = ifx_fetch_row($query)) {
 $stat_year = $row['stat_year'];
 $stat_month = $row['stat_month'];
 echo "This ".$stat_year." ".$stat_month."<br />\n";
 $objPHPExcel->getActiveSheet()->setCellValue('A' . $stat_year);
 $objPHPExcel->getActiveSheet()->setCellValue('B' . $stat_month);
 }
}


I see you calling the method getActiveSheet(). My guess is that it does exactly what it says it does. Problem is, is that you are not **setting** the active sheet until after this point. Maybe try setting all the paramaters before you start adding data to the sheet? That might fix it.

// Set header and footer. When no different headers for odd/even are used,
odd header is assumed.
echo date('H:i:s') . " Set header/footer<br />\n";
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&C&HPlease
treat this document as confidential!');
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' .
$objPHPExcel->getProperties()->getTitle() . '&RPage &P of &N');

// Set page orientation and size
echo date('H:i:s') . " Set page orientation and size<br />\n";
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);

// Rename sheet
echo date('H:i:s') . " Rename sheet<br />\n";
$objPHPExcel->getActiveSheet()->setTitle('Pending Summary');


// Set active sheet index to the first sheet, so Excel opens this as the
first sheet
$objPHPExcel->setActiveSheetIndex(0);


// Save Excel 5 file
echo date('H:i:s') . " Write to Excel2005 format<br />\n";
$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
$objWriter->save(str_replace('.php', '.xls', __FILE__));

// Echo done
echo date('H:i:s') . " Done writing file.\r\n";



--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare


--- End Message ---
--- Begin Message ---
Jim,

I placed it above like you said, but i get the same result. I think I need
to do something like the below:

if(!empty($query)) {
while ($row = ifx_fetch_row($query)) {
for ($i = 3; $i <= 50; $i++) {
 $stat_year = $row['stat_year'];
 $stat_month = $row['stat_month'];
 $name = $row['_name'];
 $case_number = $row['case_number'];
 echo "This ".$stat_year." ".$stat_month." ".$j_name." ".$case_number."<br
/>\n";
 $objPHPExcel->getActiveSheet()->setCellValue('A' . $i, $stat_year);
 $objPHPExcel->getActiveSheet()->setCellValue('B' . $i, $stat_month);
 $objPHPExcel->getActiveSheet()->setCellValue('C' . $i, $name);
 $objPHPExcel->getActiveSheet()->setCellValue('D' . $i, $case_number);
 }
 }
}

To get it to work I need to set the $i value to the starting cell I want.
so, $i = 3 means that setCellValue('A' . $i) means the output will start
populating the data in Excel cell A3. If I use the code above I get an
output of the exact same record in rows 1-50.  Maybe I need to put my query
results into an array and use the $i value to select that row of data from
the array also?

--- End Message ---
--- Begin Message ---
Dan Shirah wrote:
Jim,

I placed it above like you said, but i get the same result. I think I need
to do something like the below:

if(!empty($query)) {
while ($row = ifx_fetch_row($query)) {
for ($i = 3; $i <= 50; $i++) {
 $stat_year = $row['stat_year'];
 $stat_month = $row['stat_month'];
 $name = $row['_name'];
 $case_number = $row['case_number'];
 echo "This ".$stat_year." ".$stat_month." ".$j_name." ".$case_number."<br
/>\n";
 $objPHPExcel->getActiveSheet()->setCellValue('A' . $i, $stat_year);
 $objPHPExcel->getActiveSheet()->setCellValue('B' . $i, $stat_month);
 $objPHPExcel->getActiveSheet()->setCellValue('C' . $i, $name);
 $objPHPExcel->getActiveSheet()->setCellValue('D' . $i, $case_number);
 }
 }
}

To get it to work I need to set the $i value to the starting cell I want.
so, $i = 3 means that setCellValue('A' . $i) means the output will start
populating the data in Excel cell A3. If I use the code above I get an
output of the exact same record in rows 1-50.  Maybe I need to put my query
results into an array and use the $i value to select that row of data from
the array also?


Looking at the example at the following URL
http://www.codeplex.com/PHPExcel/Wiki/View.aspx?title=Examples&referringTitle=Home

You can see that infact they do give the column/row combo in the setCellValue() method.
--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare


--- End Message ---
--- Begin Message ---
On Thu, 2008-07-03 at 08:59 -0400, Dan Shirah wrote:
> Happy 4th of July!

How did you know it was my sisters birthday today? Been an exciting
week, first Canada's birthday was on Monday, now my sister's birthday
today. What a thrill ride.

>:)

Cheers,
Rob.


> I am having a little bit of a problem using PHPExcel. I think I'm doing
> everything right but apparently not! I am basically trying to output results
> of a query to Excel using PHPExcel.
> 
> My query works fine, my variables are being passed correctly, my database
> connection is fine...within my while () loop the echo "This ".$stat_year."
> ".$stat_month."<br />\n"; properly returns all of the years and months for
> my query. But for whatever reason when I try and put those vaules in the
> Excel objects and export the spreadsheet, the values of my cells are always
> blank.
> 
> Any ideas?
> 
> 
> /** PHPExcel */
> include 'PHPExcel.php';
> 
> /** PHPExcel_Writer_Excel2007 */
> include 'PHPExcel/Writer/Excel5.php';
> 
> // Create new PHPExcel object
> echo date('H:i:s') . " Create new PHPExcel object<br />\n";
> $objPHPExcel = new PHPExcel();
> 
> // Add some data, we will use printing features
> $name_code = $_GET['name'];
> // echo $name;
> $case_age = $_GET['case_age'];
> // echo $case_age;
> $case_cat = $_GET['case_cat'];
> // echo $case_cat;
> $case_status = $_GET['case_status'];
> // echo $case_status;
> include 'Conn/prpr_ifx.php';
>  if (!$connect_id = ifx_connect("[EMAIL PROTECTED]", $user, $pass)) { // THE
> ACTUAL CONNECTION
>      echo "Unable to connect to Informix Database\n"; // DISPLAY IF
> CONNECTION FAILS
>     exit();
>  }
> $sql = "SELECT * FROM brev_pending_summary_detail WHERE name =
> '$name_code'";
>  if (!empty($case_age)) {
>   $sql.=" AND case_age_group = '$case_age'";
>  }
>  if (!empty($case_cat)) {
>   $sql.=" AND case_category = '$case_cat'";
>  }
>  if (!empty($case_status)) {
>   $sql.=" AND case_status = '$case_status'";
>  } // Start our query of the database
> $query = ifx_query($sql, $connect_id);
> 
> echo date('H:i:s') . " Add some data<br />\n";
> if(!empty($query)) {
> while ($row = ifx_fetch_row($query)) {
>  $stat_year = $row['stat_year'];
>  $stat_month = $row['stat_month'];
>  echo "This ".$stat_year." ".$stat_month."<br />\n";
>  $objPHPExcel->getActiveSheet()->setCellValue('A' . $stat_year);
>  $objPHPExcel->getActiveSheet()->setCellValue('B' . $stat_month);
>  }
> }
> 
> // Set header and footer. When no different headers for odd/even are used,
> odd header is assumed.
> echo date('H:i:s') . " Set header/footer<br />\n";
> $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&C&HPlease
> treat this document as confidential!');
> $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' .
> $objPHPExcel->getProperties()->getTitle() . '&RPage &P of &N');
> 
> // Set page orientation and size
> echo date('H:i:s') . " Set page orientation and size<br />\n";
> $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
> $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
> $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);
> $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
> 
> // Rename sheet
> echo date('H:i:s') . " Rename sheet<br />\n";
> $objPHPExcel->getActiveSheet()->setTitle('Pending Summary');
> 
> 
> // Set active sheet index to the first sheet, so Excel opens this as the
> first sheet
> $objPHPExcel->setActiveSheetIndex(0);
> 
> 
> // Save Excel 5 file
> echo date('H:i:s') . " Write to Excel2005 format<br />\n";
> $objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
> $objWriter->save(str_replace('.php', '.xls', __FILE__));
> 
> // Echo done
> echo date('H:i:s') . " Done writing file.\r\n";
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
Happy 4th of July!

How did you know it was my sisters birthday today? Been an exciting
week, first Canada's birthday was on Monday, now my sister's birthday
today. What a thrill ride.

Isn't it the 3rd?

--
Richard Heyes

Employ me:
http://www.phpguru.org/cv

--- End Message ---
--- Begin Message ---
Richard Heyes wrote:
Happy 4th of July!

How did you know it was my sisters birthday today? Been an exciting
week, first Canada's birthday was on Monday, now my sister's birthday
today. What a thrill ride.

Isn't it the 3rd?

It is in the great Republic of Texas.

-Shawn

--- End Message ---
--- Begin Message ---
Hi,

I want to create a new column or table from queries of the values of columns I( already have.

My table is :

PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS
products_id     products_extra_fields_id     products_extra_fields_value
1 1 Blond 1 2 Green 1 3 1.75 1 4 24 2 1 Brunette 2 2 Hazel 2 3 1.56 2 4 28


with this Select query >>>

function get_extra($extra_array = '') {
  if (!is_array($extra_array)) $extra_array = array();

$extra_query = db_query("select products_extra_fields_value from " . TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS . " where products_extra_fields_id = '1'");
  while ($extra = db_fetch_array($extra_query)) {
$extra_array[] = array('id' => $extra['products_extra_fields_id'], 'text' => $extra['products_extra_fields_value']);
  }

  return $extra_array;
}

This function uses the query: select products_extra_fields_value from PRODUCTS_EXTRA_FIELDS where products_extra_fields_id = 1;

and returns Rubia and Morocha which is fine, now I need to

either create a new column or table in order to be able to have those values in their own column

my knowledge of mysql is limited so please give me suggestions as what to use in order to create a function to retrieve values and add them automatically to my table or columns

The table or columns have to be something like:

ID     Hair             Eyes
      Blond          Green
      Brunette      Hazel

so I can call them later by selecting from a column in a table like TABLE_PRODUCTS_EXTRA_FIELDS_TO_PRODUCTS_EXTRA_FIELDS_VALUE

pef2pev.hair, pef2pev.eyes ... and so on

here is my current switch

for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
  switch ($column_list[$i]) {
    case 'PRODUCT_LIST_MODEL':
      $select_column_list .= 'p.products_model, ';
      break;
    case 'PRODUCT_LIST_MANUFACTURER':
      $select_column_list .= 'm.manufacturers_name, ';
      break;
      // aDD eXTRA FIELdS
    case 'PRODUCT_LIST_HAIR':
               $select_column_list .= 'pef2pev.hair, ';
        break;

and so on ...

   break;
  }
}

Thanks


Rick Fitzgerald



--- End Message ---

Reply via email to