Solved

How to substitute the special href in PHP?

Posted on 2013-05-23
5
264 Views
Last Modified: 2013-05-30
Hi Experts

I'm facing a difficulty to deal with the anchor
<tr><td><a href="examples/?eid=grid/array-grid">Array Grid</a></td>

How could it be understood and changed?

In how to substitute it with something like that
  <tr><td><a href="examples/grid/array-grid.php">Array Grid</a></td>

since if I do that the effects are unwanted, accordingly with the Picture:

Img001
Original code

	<h4>Forms</h4>
<table cellspacing="0">
			<tr><td><a href="examples/?eid=grid/array-grid">Array Grid</a></td>
            
            <tr><td><a href="examples/grid/array-grid.php">Array Grid</a></td>

				<td><a href="examples/?eid=grid/json-grid">JSON Grid</a></td></tr>			
			<tr><td><a href="examples/?eid=grid/xml-grid">XML Grid</a></td>
				<td><a href="examples/?eid=grid/edit-grid">Editor Grid</a></td></tr>
			<tr><td><a href="examples/?eid=grid/grouping">Array Grouping Grid</a></td>
				<td><a href="examples/?eid=grid/grouping_json-grid">JSON Grouping Grid</a></td></tr>			
		</table>			


		</table>
		<h4>Grids</h4>

Open in new window


Code planned:

		<h4>Grids</h4>
		<table cellspacing="0">
			<!--tr><td><a href="examples/?eid=grid/array-grid">Array Grid</a></td-->
            
            <tr><td><a href="examples/grid/array-grid.php">Array Grid</a></td>

				<td><a href="examples/?eid=grid/json-grid">JSON Grid</a></td></tr>			
			<tr><td><a href="examples/?eid=grid/xml-grid">XML Grid</a></td>
				<td><a href="examples/?eid=grid/edit-grid">Editor Grid</a></td></tr>
			<tr><td><a href="examples/?eid=grid/grouping">Array Grouping Grid</a></td>
				<td><a href="examples/?eid=grid/grouping_json-grid">JSON Grouping Grid</a></td></tr>			
		</table>

Open in new window


Here the Project structure under Apache htdocs, it's the PHP-Ext libraries.

Img002
Since I'd like to use the code in a different context without this kind of anchor, what must be done?

Thanks in advance!
0
Comment
Question by:Eduardo Fuerte
  • 3
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
Jagadishwor Dulal earned 500 total points
ID: 39191046
I don't know how did you generate the above links but no problem it's may be static or dynamic generated. Ok lets create a function for this work will be better to reuse every where you need. I assume that each of your a links are separated using examples/?eid= that's why I am exploding them in array see the function below first:

 <?php
																	function manageUrl($url){
																		$vals=explode('/?eid=',$url);
																		$j= count($vals)-1;
																		for($i=0; $i<sizeof($vals); $i++){
																			if($j>$i){
																			echo $vals[$i]."/";
																			}else{
																				echo $vals[$i].".php";
																			}
																		}
																	}
																	?>

Open in new window


Now call the function in your a link

<h4>Forms</h4>
		<table cellspacing="0">
			<tr><td><a href="<?php echo manageUrl('examples/?eid=form/anchoring');?>">Anchoring</a></td>
			<td><a href="<?php echo manageUrl('examples/?eid=form/combos');?>">Combos</a></td></tr>
			<tr><td><a href="<?php echo manageUrl('examples/?eid=form/custom');?>">Custom</a></td>
			<td><a href="<?php echo manageUrl('examples/?eid=form/dynamic');?>">Dynamic</a></td></tr>
			<tr><td><a href="<?php echo manageUrl('examples/?eid=form/form-grid');?>">Form Grid</a></td>
			<td><a href="<?php echo manageUrl('examples/?eid=form/forum-search');?>">Forum Search</a></td></tr>
			<tr><td colspan="2"><a href="<?php echo manageUrl('examples/?eid=form/xml-form');?>">Xml Form</a></td></tr>
		</table>
		<h4>Grids</h4>
		<table cellspacing="0">
			<!--tr><td><a href="examples/?eid=grid/array-grid">Array Grid</a></td-->
            
            <tr><td><a href="examples/grid/array-grid.php">Array Grid</a></td>

				<td><a href="<?php echo manageUrl('examples/?eid=grid/json-grid');?>">JSON Grid</a></td></tr>			
			<tr><td><a href="<?php echo manageUrl('examples/?eid=grid/xml-grid');?>">XML Grid</a></td>
				<td><a href="<?php echo manageUrl('examples/?eid=grid/edit-grid');?>">Editor Grid</a></td></tr>
			<tr><td><a href="<?php echo manageUrl('examples/?eid=grid/grouping');?>">Array Grouping Grid</a></td>
				<td><a href="<?php echo manageUrl('examples/?eid=grid/grouping_json-grid');?>">JSON Grouping Grid</a></td></tr>			
		</table>

Open in new window

0
 
LVL 15

Expert Comment

by:Jagadishwor Dulal
ID: 39191050
Sorry I use php code in above see the function here:
function manageUrl($url){
	$vals=explode('/?eid=',$url);
	$j= count($vals)-1;
	for($i=0; $i<sizeof($vals); $i++){
		if($j>$i){
		echo $vals[$i]."/";
		}else{
			echo $vals[$i].".php";
		}
	}
}																	}

Open in new window

0
 

Author Comment

by:Eduardo Fuerte
ID: 39191149
It's not a simple kind of get transformed one string in another...
The problem remains the same.
0
 
LVL 15

Expert Comment

by:Jagadishwor Dulal
ID: 39191178
What Exactly you want to do?? As you start:

I'm facing a difficulty to deal with the anchor
<tr><td><a href="examples/?eid=grid/array-grid">Array Grid</a></td>

How could it be understood and changed?

In how to substitute it with something like that
  <tr><td><a href="examples/grid/array-grid.php">Array Grid</a></td>

since if I do that the effects are unwanted, accordingly with the Picture:
0
 

Author Comment

by:Eduardo Fuerte
ID: 39191293
I just want to call directly a .php without to get the unwanted effects instead of get the code executed.

Maybe if you could download the PHP-ext and test it by yourself it could be easier to understand.

By the way, thank you for your efforts!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

746 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

9 Experts available now in Live!

Get 1:1 Help Now