Yesterday I posted a HELP message without any code as a reference. A member of this 
list suggests me to post something so here is the story:
The idea is to compare two arrays and substitute information when necessary. I have to 
use PHP3 and PHPLIB templates.
This is my today table showing my actual stock (2001-04-01):



(table 1 - actual date)
t-shirt      blue         L
jacket       black        M
sweater      red          S
shirt        white        M

Then I have a future stock table, it's showing changes for the next month (2001-05-01).



(table 2 - changes for 2001-05-01)
t-shirt      red          L
sweater      green        S

If the user selects in a menu 2001-04 the orginal table 1 should be seen. But if user 
selects 2001-05 this should be display:

(table 3- a mix of table 1 and table 2)
t-shirt       red        L
jacket        black      M
sweater       green      S
shirt         white      M

I tried different code but basically this is the idea and it's not working:

<?php

//MySqlConn - function to connect to db
$mylink=MySqlConn($host,$user,$passw,$db,"error connecting");

$t=new Template();
$t->set_file("internal", "templates/chnl_lu_info_internal.html");
 

// TODAY DATE SHOWS TABLE 1
$today_date=date("Y").'-'.date("m").'-'.date("d");
 

// IF USERS SELECTS A FUTURE DATE, FOR EXAMPLE 2001-05-01, THEN THE TABLE 3 SHOULD BE 
ON THE SCREEN

if($future_dates != $today_date) {

  $sql_changes='select * from stock_changes where stock_id="'.$stock_id.'" and 
activ_date="'.$future_dates.'"';

  // QUERIES, OBVIOUSLY, IS A FUNCTION TO MAKE SQL QUERIES
  $result_changes=queries($sql_changes,"sql error!");
}

$sql='select * from stock where stock_id="'.$stock_id.'"';

$result=queries($sql,"sql error 2!");

// THIS IS THE PART THAT IS NOT WORKING
if (!empty ($result_changes)) {
  while ($ret=mysql_fetch_array($result)) {
    while (list($key,$value)=each($ret)) {
      while ($ret_ch=mysql_fetch_array($result_changes)) {
        if(!empty($ret_ch[$key])) {
          $t->set_var(array($key, $ret_ch[$key]));
        }
        else {
          $t->set_var(array($key, $ret[$key]));
        }
      }
    }
    $t->parse("channel_lineup_info_internal","internal",true);
  }
}
else {

// THIS PART IS WORKING 'COS THERE IS NO COMPARISION HERE- I LEAVE IT AS A REFERENCE
  while ($ret=@mysql_fetch_array($result)) {
    while (list($key,$value)=each($ret)) {
      if ($key=="carriage_type") {
        if ($value=="P") {
          $value='<a 
href="carriage_type.php3?ftime='.$ret['from_time'].'&ttime='.$ret['to_time'].'">'.$value.'</a>';
        }
      }
      $t->set_var(array($key=>$value));
    }
    $t->parse("channel_lineup_info_internal","internal",true);
  }
}
 

// CLOSING CONNECTION TO DB
@mysql_close();

?>


Hope someone can help me.

/paula

Reply via email to