Results 1 to 10 of 10
  1. #1

    Default I need insights sa SQL data accessing using PHP. it displays nothing.


    Hi istoryans please tabangi ko and akong code kay dili sya mo display sa $row['product_name'] wala man unta koy problem nga na encounter completely blank jud sya, anyways seperate sila ug tables mao duha ka parameters ug pag query akong gigamit please help me!

    I'm having trouble displaying the $row[product_name] it says blank while the $row2['index'] seems to be doing fine all the data is being display, what seems to be the problem here? or it is illegal to put two parameters in while statement , any insights?

    heres my code.
    Code:
        
    
        $sql = mysql_query("SELECT * FROM product_detail LIMIT 5") or die(mysql_error());
        $sql2 = mysql_query("SELECT * FROM product LIMIT 5") or die(mysql_error());
        
    
        if($sql && $sql2){
            
        while($row = mysql_fetch_array($sql) && $row2 = mysql_fetch_array($sql2)){
            
         $product_name = $row["product_name"]; echo $row["product_name"] ;
         $product_id = $row2["product_id"];
         $product_qty = $row2["balance_qty"];
         $product_price = $row2["unit_price"];    
        
                                
                            echo '    <tr>
                                    <td>'.$product_id.'</td>
                                    <td>'.$product_name.'</td>
                                    <td>'.$product_price.'</td>
                                    <td>'.$product_qty.'</td>
                                    </tr><br/>';
                              
         
         
            }

  2. #2

    Default Re: I need insights sa SQL data accessing using PHP. it displays nothing.

    two queries? i havent tried it yet, but i think dili na siya pwede, you need to use UNION then GROUP BY...

  3. #3

    Default Re: I need insights sa SQL data accessing using PHP. it displays nothing.

    dlini madala ug JOIN? refer ani bro SQL Joins

  4. #4

    Default Re: I need insights sa SQL data accessing using PHP. it displays nothing.

    SQL Join nalang bro.. mas sure pa ka nga sakto ang data sa product and product detail..

  5. #5

    Default Re: I need insights sa SQL data accessing using PHP. it displays nothing.


  6. #6

    Default Re: I need insights sa SQL data accessing using PHP. it displays nothing.

    gamit ug JOIN TS...

  7. #7

    Default Re: I need insights sa SQL data accessing using PHP. it displays nothing.

    use inner join bro.

  8. #8
    Elite Member
    Join Date
    Jun 2010
    Gender
    Male
    Posts
    1,018

    Default Re: I need insights sa SQL data accessing using PHP. it displays nothing.

    Determine first if the while statement was used.
    One way of doing it is place an echo statement after the while.
    If that echo statement shows up, that means the loop was used.
    Example: echo 'Loop starts here';

    If it doesn't enter the loop there is a problem with your resultsets

    If it does enter the loop.
    Determine the values of $row and $row2.
    One way is to use print_r($value) on both $row and $row2 to determine actual values.
    Case sensitive baya na ang associative array sa PHP.
    And sometimes, some SQL Servers return the columns in UPPERCASE

  9. #9
    Elite Member
    Join Date
    Aug 2008
    Posts
    1,053
    Blog Entries
    1

    Default Re: I need insights sa SQL data accessing using PHP. it displays nothing.

    Quote Originally Posted by Lorenzo View Post
    Hi istoryans please tabangi ko and akong code kay dili sya mo display sa $row['product_name'] wala man unta koy problem nga na encounter completely blank jud sya, anyways seperate sila ug tables mao duha ka parameters ug pag query akong gigamit please help me!

    I'm having trouble displaying the $row[product_name] it says blank while the $row2['index'] seems to be doing fine all the data is being display, what seems to be the problem here? or it is illegal to put two parameters in while statement , any insights?

    heres my code.
    Code:
        
    
        $sql = mysql_query("SELECT * FROM product_detail LIMIT 5") or die(mysql_error());
        $sql2 = mysql_query("SELECT * FROM product LIMIT 5") or die(mysql_error());
        
    
        if($sql && $sql2){
            
        while($row = mysql_fetch_array($sql) && $row2 = mysql_fetch_array($sql2)){
            
         $product_name = $row["product_name"]; echo $row["product_name"] ;
         $product_id = $row2["product_id"];
         $product_qty = $row2["balance_qty"];
         $product_price = $row2["unit_price"];    
        
                                
                            echo '    <tr>
                                    <td>'.$product_id.'</td>
                                    <td>'.$product_name.'</td>
                                    <td>'.$product_price.'</td>
                                    <td>'.$product_qty.'</td>
                                    </tr><br/>';
                              
         
         
            }
    i dont have php and mysql knowledge but is it ur query returns boolean? does it enters ur if statemen why not use LEFT JOIN? on product id? are you trying to create a master-detail view? i hope u have similar to datagridview. d

  10. #10

    Default Re: I need insights sa SQL data accessing using PHP. it displays nothing.

    This case is solved na istoryans, I used inner join to combine two tables and then, loop them using one variable.

    Salamat sa help istoryans more power!

  11.    Advertisement

Similar Threads

 
  1. NEED HELP: where can i loan using ATM CARD as collateral?
    By +art+ in forum Business, Finance & Economics Discussions
    Replies: 50
    Last Post: 11-18-2017, 08:11 AM
  2. Replies: 87
    Last Post: 08-29-2015, 10:58 AM
  3. need help sa linux be version 9
    By kermesh in forum Computer Hardware
    Replies: 3
    Last Post: 03-01-2013, 03:10 PM
  4. Guys need help sa business na carwash
    By mack0y in forum Business, Finance & Economics Discussions
    Replies: 7
    Last Post: 01-29-2013, 12:41 AM
  5. need help sa SQL Server 2005
    By icechan83 in forum Computer Hardware
    Replies: 2
    Last Post: 06-28-2009, 01:46 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top