Announcement

Collapse
No announcement yet.

How can I show the number of records in a field

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How can I show the number of records in a field

    Hello friends,

    I have a link field with an image that leads to a grid of customer's orders. I'd like to show behind the link image the number of orders (and 0 if there aren't any)

    How could this be done?

    Joe

  • #2
    Why not just put the count above or below the image
    Easier and neater imho

    Comment


    • #3
      Thank you Kdriscoll, but what code do I need to generate the counting?

      Joe

      Comment


      • #4
        in onRecord (executed for each record loaded) run something like the following:

        Code:
        $sqlq = 
           "SELECT ".
           "	COUNT( * ) ".
           "FROM ".
        	"tblCustomers ".
        	"INNER JOIN tblOrders ".
        	 "ON tblCustomers.CustomerID = tblOrders.CustomerID ".
           "WHERE ".
        	"tblOrders.CustomerID = " . {CustomerID} .";";
        
        sc_lookup(my_data, $sqlq);
        
        if ({my_data} === false) {
        	echo "<script type='text/javascript'>alert('Access error. Message = " . {my_data_erro} . "');</script>";
        
        } elseif (empty({my_data})) {
           {Num_of_Orders} = 0;
        
        } else {
           {Num_of_Orders} = {my_data[0][0]};	
        }

        Comment


        • #5
          Thank you adz1111,

          I will try that to fit it my application.

          Joe

          Comment

          Working...
          X