PDA

View Full Version : Whats wrong with this?



VistaBoy
15-09-2008, 10:34 AM
Okay its shows no thing it has conent in the template.


$sql_dashboard_tickets = $db->select('*', 'tickets', array('assigned' => $laydesk->user['uid'], 'waiting' => '1'), array('limit' => '0,5'));

while ($dashboard_tickets = $db->fetch_array($sql_dashboard_tickets))
{
eval("\$staff_dashboard_tickets = \"".$template->get('staff_dashboard_tickets')."\";");
}

now that does not show nothing but it has stuff in that template but when i do this


$i = 1;
while ($i <= 10) {
$yoz = $i++;
eval("\$staff_dashboard_tickets = \"".$template->get('staff_dashboard_tickets')."\";");
}

It shows the stuff in the template???

Agnostic Bear
16-09-2008, 10:20 AM
Okay its shows no thing it has conent in the template.


$sql_dashboard_tickets = $db->select('*', 'tickets', array('assigned' => $laydesk->user['uid'], 'waiting' => '1'), array('limit' => '0,5'));

while ($dashboard_tickets = $db->fetch_array($sql_dashboard_tickets))
{
eval("\$staff_dashboard_tickets = \"".$template->get('staff_dashboard_tickets')."\";");
}now that does not show nothing but it has stuff in that template but when i do this


$i = 1;
while ($i <= 10) {
$yoz = $i++;
eval("\$staff_dashboard_tickets = \"".$template->get('staff_dashboard_tickets')."\";");
}It shows the stuff in the template???



$sql_dashboard_tickets = $db->select('*', 'tickets', array('assigned' => $laydesk->user['uid'], 'waiting' => '1'), array('limit' => '0,5'));

while ($dashboard_tickets = $db->fetch_array($sql_dashboard_tickets))
{
eval("\$staff_dashboard_tickets = \"".$template->get('staff_dashboard_tickets')."\";");
}
What? You've got a select query to count something. Use this:


$tickets = mysql_query( 'SELECT COUNT(`id`) FROM `tickets` WHERE `assigned` = \'whatever\' AND `waiting` = \'1\' LIMIT 0,5' );
$tickets = mysql_fetch_array( $tickets );then do:





for( $i = 0; $i < $tickets[ 0 ]; $tickets++ )
{
// whatever
}



Edit:
also you have this, what is the point in it?


eval("\$staff_dashboard_tickets = \"".$template->get('staff_dashboard_tickets')."\";");

You're just setting the $staff_dashboard_tickets over and over again. It doesn't need an eval.

VistaBoy
16-09-2008, 11:52 AM
$sql_dashboard_tickets = $db->select('*', 'tickets', array('assigned' => $laydesk->user['uid'], 'waiting' => '1'), array('limit' => '0,5'));

while ($dashboard_tickets = $db->fetch_array($sql_dashboard_tickets))
{
eval("\$staff_dashboard_tickets = \"".$template->get('staff_dashboard_tickets')."\";");
}
What? You've got a select query to count something. Use this:


$tickets = mysql_query( 'SELECT COUNT(`id`) FROM `tickets` WHERE `assigned` = \'whatever\' AND `waiting` = \'1\' LIMIT 0,5' );
$tickets = mysql_fetch_array( $tickets );then do:





for( $i = 0; $i < $tickets[ 0 ]; $tickets++ )
{
// whatever
}

Edit:
also you have this, what is the point in it?


eval("\$staff_dashboard_tickets = \"".$template->get('staff_dashboard_tickets')."\";");You're just setting the $staff_dashboard_tickets over and over again. It doesn't need an eval.

What you lost me :S

"You've got a select query to count something" - hows that a count its getting info from the database :S

That for loop did not work and i do not think it will fit in to what i want to do??

also i need the eval as if i do not have it my template system will not work right ;)

but i fixed it using



$sql_dashboard_tickets = $db->select('*', 'tickets', NULL, array('limit' => '0,5'));

while ( $dashboard_tickets = $db->fetch_array( $sql_dashboard_tickets ) )
{
if ( $dashboard_tickets['assigned'] == $laydesk->user['username'] )
{
if ( $dashboard_tickets['waiting'] == '1' )
{
eval("\$staff_dashboard_tickets = \"".$template->get('staff_dashboard_tickets')."\";");
}
}
else
{
$staff_dashboard_tickets = 'No tickets for you!';
}
}
is that right or is there a better why?

Agnostic Bear
16-09-2008, 01:48 PM
What you lost me :S

"You've got a select query to count something" - hows that a count its getting info from the database :S

That for loop did not work and i do not think it will fit in to what i want to do??

also i need the eval as if i do not have it my template system will not work right ;)

but i fixed it using



$sql_dashboard_tickets = $db->select('*', 'tickets', NULL, array('limit' => '0,5'));

while ( $dashboard_tickets = $db->fetch_array( $sql_dashboard_tickets ) )
{
if ( $dashboard_tickets['assigned'] == $laydesk->user['username'] )
{
if ( $dashboard_tickets['waiting'] == '1' )
{
eval("\$staff_dashboard_tickets = \"".$template->get('staff_dashboard_tickets')."\";");
}
}
else
{
$staff_dashboard_tickets = 'No tickets for you!';
}
}
is that right or is there a better why?

1) You didn't put any indication that you needed any results picking out
2) If you need to use eval in your template system, you're doing it wrong.
3) If it works it's right

VistaBoy
17-09-2008, 11:57 PM
How is using eval in a template system wrong its done by many softwares out there look at some forum softwares they do it. Also how you you do a template system not wrong :S

Agnostic Bear
17-09-2008, 11:59 PM
It's right but wrong at the same time, eval wastes time, just set the variable there and then, you don't need eval to come along and say "oh yes lets set that as that" just do it without going through it. It's faster.

VistaBoy
18-09-2008, 12:07 AM
I tryed that is you do not eval the code it just shows this on the page and not the data coming from the database

{$dashboard_tickets['title']} also does not work if you remove the { and }

Agnostic Bear
18-09-2008, 12:08 AM
Post the full code you're using.

VistaBoy
18-09-2008, 12:11 AM
if ( $laydesk->user['aid'] >= 1 )
{
$sql_dashboard_tickets = $db->select('*', 'tickets', NULL, array('limit' => '0,5'));

while ( $dashboard_tickets = $db->fetch_array( $sql_dashboard_tickets ) )
{
if ( $dashboard_tickets['assigned'] == $laydesk->user['username'] )
{
if ( $dashboard_tickets['waiting'] == '1' )
{
$staff_dashboard_tickets = $template->get('staff_dashboard_tickets'):
}
}
else
{
$staff_dashboard_tickets = 'non';
}
}

echo $staff_dashboard_tickets;
and template system



function get ( $title, $eslashes = 1 )
{
$filename = '../templates/'. LayDesk::$setting['template'] .'/'. $title .'.tpl';

if ( file_exists($filename) )
{
$template = file_get_contents($filename);
}
else
{
die('<b>LayDesk Error</b> - Template not found: '. $filename);
}

$template = str_replace ( "\\'", '\'', addslashes ( $template ) );

return $template;
}

Agnostic Bear
18-09-2008, 12:13 AM
I see no problem w/ that code.

VistaBoy
18-09-2008, 12:16 AM
Hmm as with out the eval it shows

{$dashboard_tickets['status']} and not OPEN but i do not have to have eval on the $staff_dashboard_tickets = 'non'; only the info coming from the template system :S

Want to hide these adverts? Register an account for free!