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

x
?
Solved

URGENT!!  odbc_fetch_row return only one rows.

Posted on 2002-03-25
3
Medium Priority
?
691 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 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";
   }
  }
0
 

Author Comment

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

Expert Comment

by:andriv
ID: 6897865
no problem.
0

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