Need a 'second pair of eyes' to check code..

A place for users and developers of the Xataface to discuss and receive support.

Need a 'second pair of eyes' to check code..

Postby danw » Mon Jun 15, 2009 7:43 am

I need a pair of eyes to double check. Code works on 1 table, not the other.
I can SEE RESULTS from the "sysFunction" - - but I only see ". ()" for the sysStatus.
Code seems IDENTICAL.

==================table layouts ===================

sysFunction
id
function

sysStatus
id
status

both id = smallints
both fuction & status varchars

________________ ~/actions _______________

browse_by function = WORKS
Code: Select all
<?php
  class actions_browse_by_function  {

  function handle(&$params){

  $sql = "select id as func_id, function as func_function from sysFunction order by function";

  $res = mysql_query($sql, df_db());
  $functions = array();
   while ( $row = mysql_fetch_assoc($res) ){
  print_r($row);

    $sql2 = "select count(*) as num from Systems where function rlike '[[:<:]]".$row['func_id']."[[:>:]]'";
    $res2 = mysql_query($sql2, df_db());
            list($num) = mysql_fetch_row($res2);
            if ( $num ){

    $functions[] = array('name'=>$row['func_function'],
                                        'id'=>$row['func_id'],
                                    'num'=>$num);
            }
            @mysql_free_result($res2);
        }
        @mysql_free_result($res);
        $num_funcs = count($functions);
        $per_column = ceil($num_funcs/6);

df_display(array('functions'=>$functions, 'per_column'=>$per_column), 'browse_by_function.html');
    }
}

?>


_______________ browse by status _________ DOES NOT WORK


Code: Select all
php

class actions_browse_by_status {
  function handle(&$params){

  $statii = array();

  $sql = "select id as stat_id, status as stat_status from sysStatus order by id";
  $res      = mysql_query($sql, df_db());

   while ( $row = mysql_fetch_assoc($res) ){
print_r($row);

    $sql2 = "select count(*) as num from Systems where status rlike  '[[:<:]]".$row['stat_id']."[[:>:]]'";
    $res2 = mysql_query($sql2, df_db());

            list($num) = mysql_fetch_row($res2);

print "NUM: $num<br>";

            if ( $num ){

                $statii[] = array('name'=>$row['stat_status'],
                                  'id'=>$row['stat_id'],
                                  'num'=>$num);
            }
            @mysql_free_result($res2);
        }
        @mysql_free_result($res);

        $num_status = count($statii);
        $per_column = ceil($num_status/4);

df_display(array('statii'=>$statii, 'per_column'=>$per_column), 'browse_by_status.html');

    }

}
?>


the print_r($row) & NUM shows the following for "sysStatus":
Array ( [stat_id] => 1 [stat_status] => Production ) NUM: 1790
Array ( [stat_id] => 2 [stat_status] => In-Storage ) NUM: 415
Array ( [stat_id] => 3 [stat_status] => No-Automation ) NUM: 225
Array ( [stat_id] => 4 [stat_status] => Test-Sandbox-Lab ) NUM: 79
Array ( [stat_id] => 5 [stat_status] => Unassigned ) NUM: 151
Array ( [stat_id] => 6 [stat_status] => Parts-Salvage ) NUM: 4
Array ( [stat_id] => 7 [stat_status] => Deleted ) NUM: 55




________________ ~/templates _______________

( for function )

'browse_by_function.html' - - WORKS

Code: Select all
use_macro file="Dataface_Main_Template.html"}

{fill_slot name="main_section"}

<h1>Browse Systems by Function</h1>

  {foreach from=$functions item=function key=ctr}
   {if $ctr%$per_column == 0}
   {if $ctr>0}</ul></div>{/if}<div style="width: 15%; float: left; margin: 0; padding: 0; padding-top: 1em; "><ul>
   {/if}
<li>
<a href="{$ENV.DATAFACE_SITE_HREF}?-table=Systems&-action=list&function={$function.id}">{$function.name}</a> <em>({$function.num})</em></li>
        {/foreach}
        </ul></div>
        <div style="clear: both"/>
    {/fill_slot}
{/use_macro}



=============== for status ===========
'browse_by_status.html' - Don't see counts or names etc

Code: Select all

use_macro file="Dataface_Main_Template.html"}
{fill_slot name="main_section"}

<h1>Browse Systems by Status</h1>
  {foreach from=$statii item=status key=ctr}
   {if $ctr%$per_column == 0}

  {if $ctr>0}</ul></div>{/if}<div style="width: 15%; float: left; margin: 0; padding: 0; padding-top: 1em; "><ul>
   {/if}

<li>
<a href="{$ENV.DATAFACE_SITE_HREF}?-table=Systems&-action=list&status={$stat.id}">{$stat.status}</a><em>({$num})</em></li>
        {/foreach}
        </ul></div>
        <div style="clear: both"/>
    {/fill_slot}
{/use_macro}



SO, I'm getting data, just doesn't seem to be passing? Anybody see anything?

In advance, thanks
dan


========= END POST LAST LINE =========
danw
 
Posts: 9
Joined: Wed Jan 02, 2008 8:32 am

Re: Need a 'second pair of eyes' to check code..

Postby silma » Mon Jun 15, 2009 9:39 am

The only difference i see is there :

=============== for status ===========
'browse_by_status.html' - Don't see counts or names etc

Code: Select all

use_macro file="Dataface_Main_Template.html"}
{fill_slot name="main_section"}

<h1>Browse Systems by Status</h1>
  {foreach from=$statii item=status key=ctr}
   {if $ctr%$per_column == 0}

  {if $ctr>0}</ul></div>{/if}<div><ul>
   {/if}

<li>
<a>{$stat.status}</a><em>({$num})</em></li>
        {/foreach}
        </ul></div>
        <div>
    {/fill_slot}
{/use_macro}


<em>({$num})</em> should maybe be <em>({$statii.num})</em></li>

Hope this help,

Silma
silma
 
Posts: 87
Joined: Tue Apr 28, 2009 11:47 pm

Postby danw » Mon Jun 15, 2009 11:56 am

Go figure: working: Had 'name' instead of 'status'

WORK's: <a href="{$ENV.DATAFACE_SITE_HREF}?-table=Systems&-action=list&status={$status.id}">{$status.name}</a> <em>({$status.num})</em></li>

DOES NOT WORK:

<a href="{$ENV.DATAFACE_SITE_HREF}?-table=Systems&-action=list&status={$stat.id}">{$stat.status}</a><em>({$num})</em></li>

cheers!
dan
danw
 
Posts: 9
Joined: Wed Jan 02, 2008 8:32 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 23 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved