Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Use a css class with a link

Posted on 2011-03-16
5
Medium Priority
?
350 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
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.
Suggested Courses

971 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