Solved

How to substitute the special href in PHP?

Posted on 2013-05-23
5
314 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
[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
  • 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

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