FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


PHP OCI8 question





tekanubis
I'm trying to do two seperate select statements and it doesn't want to display the second one. I'm new to php, and I can't figure this out. Here's the basic code.

Code:
$db_conn = ocilogon("$user", "$pass", "$db");

  if (!$db_conn) {
   echo "<h2>Bad Login</h2>";
   exit;
  }
echo "<html><body><center>";


$query="select class1, class2, class3, class4, class5,\n
class6, class7, class8, class9, class10,\n
class11, class12, class13 ,class14, class15, time_key";

$cmdstr = $query. " from tms.rawdata tr, calendar c\n
      where tr.calendar_key=c.calendar_key\n
      and linkid=".$linkid."\n
      and direction=".$direction."\n
      and datex between '".$sday."-".$smonth."-".$syear."' and '".$eday."-".$emonth."-".$eyear."'";


$parsed = ociparse($db_conn, $cmdstr);
ociexecute($parsed);

$zrows = ocifetchstatement($parsed, $results1);

echo $zrows;

$cmdstr0="select distinct lane, direction from tms.rawdata tr, calendar c\n
      where tr.calendar_key=c.calendar_key\n
      and linkid=".$linkid."\n
      and direction=".$direction."\n
      and datex = '".$sday."-".$smonth."-".$syear."'";

$parsed0 = ociparse($db_conn, $cmdstr0);
ociexecute($parsed0);


$nrows = ocifetchstatement($parsed0, $results);

$laneTotal = $nrows;
echo $nrows;
Fire Boar
Hmm... I'm not too knowledgeable about OCI8 but I suspect you might gain some insight by replacing the line:

echo $nrows;

With:

print_r($results);

That should get you the array structure of the results, which you can display by doing echo $results['array_key'];


On second thoughts, this might be a better way:

Code:
if ($nrows > 0) {
   echo "<table border=\"1\">\n";
   echo "<tr>\n";
   foreach ($results as $key => $val) {
      echo "<th>$key</th>\n";
   }
   echo "</tr>\n";

   for ($i = 0; $i < $nrows; $i++) {
      echo "<tr>\n";
      foreach ($results as $data) {
         echo "<td>$data[$i]</td>\n";
      }
      echo "</tr>\n";
   }
   echo "</table>\n";
} else {
   echo "No data found<br />\n";
}
tekanubis
yeah, I don't know, after the second ociexecute() is run there are no results. I can get all the data from the first query until I run the second ociexecute. Then I can't get the data from the first query(which I'd expect), but I also can't get the second query at all. I'm stumped
Related topics
PHP/MySQL question
PHP Editing Question
PHP magic_quotes_gpc question
[PHP] n00b question
Please help with php-quick question
php, css question (wordpress)
php SESSIONS question
votre avie sur mon nv site .
php nuke question
php/sql question
The last foolish PHP/MySQL Question of the Year....
PHP MySQL Question
PHP Form Question
Newbie PHP/MySQL question
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.