Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Use a css class with a link

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
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.
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

722 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