Solved

URGENT!!  odbc_fetch_row return only one rows.

Posted on 2002-03-25
3
670 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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
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