Jump to content

echo <a href>

- - - - -

  • Please log in to reply
1 reply to this topic

#1
newphpcoder

newphpcoder

    Programming Professional

  • Members
  • PipPipPipPipPipPip
  • 479 posts
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
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?

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
Remember,
'$myLink' != "$myLink"
PHP: Strings - Manual
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users