Log in

View Full Version : echo <a href>



rhodarose
05-12-2011, 05:42 AM
Good day!

I want to know if how can I edit my code to echo my <a href>

here is my <a href> code



<a href="machine1.php?pageno=1&field_name=<?php echo $data_sort; ?>&sorting=<?php echo $sort; ?>">FIRST</a>
<a href="machine1.php?pageno=<?php echo $prevpage;?>&field_name=<?php echo $data_sort; ?>&sorting=<?php echo $sort; ?>">PREV</a>



Thank you so much

rhodarose
05-12-2011, 07:00 AM
my colleagues gave me an example of the link of page:


$paging = '<a href="?page=1">First</a> | ';
$paging .= '<a href="?page=1">Next</a> ';
$paging .= 'Page 1 of 5 ';
$paging .= '<a href="?page=1">Previous</a> | ';
$paging .= '<a href="?page=5">Last</a>';

$tpl->set_var(array('pagination' => $paging,
));

then he puts {pagination} in his html code

but in my case I have an if and else condition, so I tried this code.and I encountered problem.


if ($pageno == 1) {
echo " FIRST PREV ";
} else {
$myLink = ' <a href="machine1.php?pageno=1&field_name='.$data_sort.'&sorting='.$sort.'">FIRST</a>';
$prevpage = $pageno-1;
$myLink .= ' <a href="machine1.php?pageno='.$prevpage.'&field_name='.$data_sort.'&sorting='.$sort.'">PREV</a>';
}
$paging = 'Page $pageno of $lastpage ';
//echo " ( Page $pageno of $lastpage ) ";
if ($pageno == $lastpage) {
echo " NEXT LAST ";
} else {
$nextpage = $pageno+1;
$pagination2 .= ' <a href="machine1.php?pageno='.$nextpage.'&field_name='.$data_sort.'&sorting='.$sort.'">NEXT</a>';
$pagination2 .= ' <a href="machine1.php?pageno='.$lastpage.'&field_name='.$data_sort.'&sorting='.$sort.'">LAST</a>';
}


and I set_var


$tpl->set_var(array('pagination' => '$myLink',
'paging' => '$paging',
'pagination2' => '$pagination2'
));


and i add in my html this code:


{pagination} {paging} {pagination2}

and the output is:
$myLink FIRST PREV

whats wrong with my code?

traq
05-12-2011, 02:04 PM
it seems you're using some cms or function library (e.g., $tpl->set_var(); etc.). I have no idea what those functions do or how the overall system works, so I'm afraid there's not much help I could offer.

You mention your "colleagues", and your "boss" in another thread. is this a system your work is using? do they have any resources, or people who could help familiarize you with the system?