Insert content in middle of url

i have page name properties.php which contain list of properties listing from array(static listing without database), when user click on view-details achor tag

<a href="details.php?show=<?php echo $id;?>">View-details</a>

details.php contains all details of the file which is ok works fine but what i want is that i want to insert content in details.php like details-locations.php location will change according but if insert location from array into details.php like:

<a href="details<?php echo $location?>".php?show=<?php echo $id;?>">View-details</a>

it will definite broke the details.php page, so how can i insert location in-between details.php not after details.php?show=…

is it poosible to insert in the middle of detials.php like detials-<?php echo $location?>.php and can easily get array details without breaking page

Well, look at the coloring that the forum has applied to your attempt vs your first bit of code. Note where it goes wrong. That will probably tell you what you need to fix…

Should it be <?php echo $location; ?> instead of <?php echo $location?>

1 Like

yes, you’re correct (which is what i was pointing the user at…). That or just shorthand the echo down to <?= $location ?>

You could have MANY locations which would then require multiple detailslocation.php pages.
If your list of properties can be sorted by the location, then you could make a form to control what location is shown on the page. Think of it like a pre-filter for your list.

<?= Only if short tags are enabled.

Also as you are already using php to loop through your array and define your variable, why jump back into html? Just stay in php echo the link without all the in-and-out or back and forth.

echo '<a href="details.php?show='.$id.'">View-details</a>';

Short echo tags have been enabled by default since version 5.4

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.