Solved

URGENT!!  odbc_fetch_row return only one rows.

Posted on 2002-03-25
3
667 Views
Last Modified: 2006-11-17
Hi Guys,

Pls help me..
I try to select record from oracle table usign php. Code below:

  $query = "SELECT * FROM category ORDER BY c_name";
  $resultcat =  odbc_exec($odbc_link, $query);
  while(odbc_fetch_row($resultcat)){
     $cat_id = odbc_result($resultcat,1);
     $cat_name = odbc_result($resultcat,2);
     if ($cat_name == "General") {
         print "<option  value=\"$cat_id\" selected>$cat_name</option>\n";
     }
     else {
         print "<option value=\"$cat_id\">$cat_name</option>\n";
    }
   }
/////////////////////////////////////////

FYI, I'm using ODBC connection and the connection is work fine. When I run the above code, it's only return one row result instead of 3 in the database. How can I get all the rows?

hope someone can help me.

TQ
zamir
0
Comment
Question by:zamirjalil
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
andriv earned 100 total points
ID: 6895771
This shouldn't make a difference but try storing the result in the while loop in a variable:

 while($row = odbc_fetch_row($resultcat)){
    $cat_id = odbc_result($row,1);
    $cat_name = odbc_result($row,2);
    if ($cat_name == "General") {
        print "<option  value=\"$cat_id\" selected>$cat_name</option>\n";
    }
    else {
        print "<option value=\"$cat_id\">$cat_name</option>\n";
   }
  }
0
 

Author Comment

by:zamirjalil
ID: 6896166
Thanks andriv.
0
 
LVL 5

Expert Comment

by:andriv
ID: 6897865
no problem.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question