Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jun 2012
    Posts
    44
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Question Nested sql problem.

    Hi guys,

    I met a problem here with microsoft access db + PHP
    Code:
    $sql20 = "SELECT orderStatusID, orderStatusName, picName, picIconDisplay, iconCount
    		  FROM groupStatus
    		  WHERE picIconDisplay = '1' AND groupID = '$_SESSION[group_ID]'";
    $row = odbc_exec($conn, $sql20);
    while(odbc_fetch_row($row))
    {
    	$orderStatusID = odbc_result($row, 1);
    	$orderStatusNameRS = odbc_result($row, 2);
    	$picName = odbc_result($row, 3);
    	$picIconDisplay = odbc_result($row, 4);
    	$iconCount = odbc_result($row, 5);
    	
    	echo "<a href='display.php?statusID=$orderStatusID&Page=1'><img src='$picName' width='20' height='20' title='$orderStatusNameRS'></a>";
    	
    	$sql21 = "SELECT COUNT(orderStatusID) AS totalSO
    	FROM serviceOrder
    	WHERE orderStatusID = $orderStatusID";
    	$row = odbc_exec($conn, $sql21);
    	$totalSO = odbc_result($row, 1);
    	echo '<br />('.$totalSO.')';
    }
    I just will loop for the first result only, instead of for the rest. So, any solution or suggestion? It should be 5 orderStatusID & 5 pictures to display after looping.

    Thanks & cheers!

  • #2
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    Have you run the queries in any kind of query analyzer and know that you are getting the expected data?
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • #3
    New Coder
    Join Date
    Jun 2012
    Posts
    44
    Thanks
    17
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by WolfShade View Post
    Have you run the queries in any kind of query analyzer and know that you are getting the expected data?
    Hi WolfShade,

    So sorry, I not really get your meaning

  • #4
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,930
    Thanks
    46
    Thanked 203 Times in 202 Posts
    he/she means you should create the query in the access DB and then execute it and make sure what you are expecting to get back is what you really do get back

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • Users who have thanked alykins for this post:

    mwx6205 (07-14-2012)

  • #5
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    Precisely. Run the query in Access (outside of the browser) to make sure that the data that is being retrieved is the data you want.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • Users who have thanked WolfShade for this post:

    mwx6205 (07-14-2012)

  • #6
    New Coder
    Join Date
    Jun 2012
    Posts
    44
    Thanks
    17
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by WolfShade View Post
    Precisely. Run the query in Access (outside of the browser) to make sure that the data that is being retrieved is the data you want.
    Quote Originally Posted by alykins View Post
    he/she means you should create the query in the access DB and then execute it and make sure what you are expecting to get back is what you really do get back
    Hi alykins & WolfShade,

    Thanks again.

    Okay, I got yours meaning. Actually I'm not that familiar with access, but I got tried in my PHP side, I got what I want, but it just some problems during my looping. It loops for 1 time only. Which mean execute $sql20 & $sql21, then it won't be back to $sql20 to loop again for the rest. The value for my $orderStatusID is up to 5 but it just execute for $orderStatusID = 1 only.

    Perhaps, can I post to PHP that part?

    Cheers!!
    Regards,
    mwx6205.

  • #7
    New Coder
    Join Date
    Jun 2012
    Posts
    44
    Thanks
    17
    Thanked 0 Times in 0 Posts
    [resolved]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •