Solved

URGENT!!  odbc_fetch_row return only one rows.

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now