Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to substitute the special href in PHP?

Posted on 2013-05-23
5
Medium Priority
?
331 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

963 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