Solved

Use a css class with a link

Posted on 2011-03-16
5
348 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

617 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