Solved

Use a css class with a link

Posted on 2011-03-16
5
345 Views
Last Modified: 2012-06-27
Hi,

I have a class "page_button" which will make it so there is a background behind Page 1, Page 2, etc....

I'm not that falilliar with PHP and how to incorpoate this. Can you please doctor up my attached code to add the class "page_button" to it?

Thanks
<?
	for ($i = 1; $i <= $pages; $i++) {
		if ($i > 1)
			echo '&nbsp;|';
		if ($i == $page)
			echo '&nbsp;<strong>Page ' . $i . '</strong>';
		else
			echo '&nbsp;<span class='page_button'><a href="event.php?group=' . $group . '&event=' . $event .'&page=' . $i . '">Page ' . $i . '</a></span>';
	}
	?>

Open in new window

0
Comment
Question by:Computer Guy
5 Comments
 
LVL 17

Expert Comment

by:Shinesh Premrajan
ID: 35146387
Hope this helps
<?
	for ($i = 1; $i <= $pages; $i++) {
		if ($i > 1)
			echo '&nbsp;|';
		if ($i == $page)
			echo '&nbsp;<span class='page_button' ><strong>Page ' . $i . '</strong></span>';
		else
			echo '&nbsp;<span class='page_button' ><a href="event.php?group=' . $group . '&event=' . $event .'&page=' . $i . '">Page ' . $i . '</a></span>';
	}
	?>

Open in new window

0
 
LVL 27

Expert Comment

by:Lukasz Chmielewski
ID: 35146475
I think that you should have it on the active page, is it what you want ?
<?php
      for ($i = 1; $i <= $pages; $i++) {
            if ($i > 1)
                  echo '&nbsp;|';
            if ($i == $page)
                  echo '&nbsp;<span class='page_button' ><strong>Page ' . $i . '</strong></span>';
            else
                  echo '&nbsp;<a href="event.php?group=' . $group . '&event=' . $event .'&page=' . $i . '">Page ' . $i . '</a>';
      }
      ?>
0
 
LVL 3

Author Comment

by:Computer Guy
ID: 35146562
Hi,

I got this error (PHP Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' on line 83) which is this one: echo '&nbsp;<span class='page_button' ><strong>Page ' . $i . '</strong></span>';
for ($i = 1; $i <= $pages; $i++) {
		if ($i > 1)
			echo '&nbsp;|';
		if ($i == $page)
			echo '&nbsp;<span class='page_button' ><strong>Page ' . $i . '</strong></span>';
		else
			echo '&nbsp;<span class='page_button' ><a href="event.php?group=' . $group . '&event=' . $event .'&page=' . $i . '">Page ' . $i . '</a></span>';
	}

Open in new window

0
 
LVL 17

Accepted Solution

by:
Shinesh Premrajan earned 500 total points
ID: 35146603
this is corrected one
for ($i = 1; $i <= $pages; $i++) {
		if ($i > 1)
			echo '&nbsp;|';
		if ($i == $page)
			echo '&nbsp;<span class="page_button" ><strong>Page ' . $i . '</strong></span>';
		else
			echo '&nbsp;<span class="page_button" ><a href="event.php?group=' . $group . '&event=' . $event .'&page=' . $i . '">Page ' . $i . '</a></span>';
	}

Open in new window

0
 
LVL 3

Expert Comment

by:pius_babbun
ID: 35146679
This is helpful I hope

echo '&nbsp;<span class="page_button"><a href="event.php?group=' . $group . '&event=' . $event .'&page=' . $i . '">Page ' . $i . '</a></span>';
<?php
	
	//Just added for Checking
	$group = 'Group Name';
	$group = 'Event';
	$pages = 5;
	$page  = 2;
	//End
	
	
	for ($i = 1; $i <= $pages; $i++) {
		if ($i > 1)
			echo '&nbsp;|';
		if ($i == $page)
			echo '&nbsp;<strong>Page ' . $i . '</strong>';
		else
			echo '&nbsp;<span class="page_button"><a href="event.php?group=' . $group . '&event=' . $event .'&page=' . $i . '">Page ' . $i . '</a></span>';
	}
?>

Open in new window

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now