Solved

Use a css class with a link

Posted on 2011-03-16
5
343 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:shinuq
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:
shinuq 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

706 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

19 Experts available now in Live!

Get 1:1 Help Now