Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


URGENT!!  odbc_fetch_row return only one rows.

Posted on 2002-03-25
Medium Priority
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);
     $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.

Question by:zamirjalil
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

Accepted Solution

andriv earned 400 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";

Author Comment

ID: 6896166
Thanks andriv.

Expert Comment

ID: 6897865
no problem.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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 and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

618 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