I have a standard html/css page that displays a top horizontal menu, and a left vertical menu.
When I select an option from the left menu it’s calling a php program that loads a template (basically a form for each option).
My problem is I want to display the form to the right of the existing vertical menu and below the horizontal menu. Currently it displays like a new page, and a look at the page source shows the form detials without the rest of the calling page!
What do I need to do? I probably haven’t explained this very well
Hi Salient. It’s not really clear what your situation is, so any further explanation you can give would be helpful.
If this is just a positioning issue, please post the generated HTML and the CSS that goes with it so we can help you with positioning. If it’s a PHP issue, we can move the thread to that forum.
Okay step by step going down the files, and cutting down to the relevant lines
Admin.php
<?php
include_once("./template/admin_head.html");
?>
...
<li><a href="admin_country.php?mod=cadd">Add a Country</a></li>
In the admin_head.html we load the <head> section of the html, including css and js etc.
A menu exists on the left hand side of the pafe with one of the options being “Add a Country”. Okay that displays fine
admin_country.php
function countryadd()
{
global $templates, $admin_lang;
include($templates."admin_new_country.php");
exit();
}
We drop into the countryadd function, in next version will be a class, that basically loads the “admin_new_country.php” template where we enter Country details.
When I look at page source I get the template html and nothing else So basically it’s losing the css and previous html, almost like it’s creating a fresh page. Think I’m missing something here, but not sure what.
Have checked google but either am not entering the correct search criteria or this isn’t a common occurance
Strangely it’s finding the language includes and translating those.
Sorry, but all this is over my head. Everything you’ve posted above is just PHP stuff, and doesn’t show what’s actually happening on your page once it reaches the browser. (All PHP gets stripped out on the server, before the page is sent to the browser.)
Not sure what that means.
Again, if this is an HTML/ CSS issue, please post the page as it’s seen by the browser, with the full HTML and CSS. That way we can assess any layout issues. If, instead, this is an issue of functionality, then your really need to be over in the PHP or WordPress forums.
Basically we are getting the template displayed with the language translates (via php echos) having been done.
I’m wondering if because our main page has the page ending tags (</body> </html>), the browser is displaying that and then sees the template as a separate page when I click through onto it? Might explain the situation.
This may require the whole page to be re-generate on each option click? We could do this with includes easily enough, but it kind of defeats the purpose somewhat
Uhmm no it’s an html question, now know what the problem is, trying to sort a solution that doesn’t involve a complete rebuild of the page from scratch
You ask for admin_country.php and that’s what you get. You didn’t ask for the original page with admin_country.php inserted into the middle.
What I guess you should be doing (and I know no PHP as I said above) is requesting the original page again but modifying it with the results from the form submission so that your new data is visible.
However it seems that perhaps some sort of ajax request would be more suitable.
Hopefully one of the PHP experts will see this thread and advise the best way to do this.
if(isset($_GET['mod']))
{
$mod = $_GET['mod'];
} else {
$mod = '';
}
if(isset($_GET['id']))
{
$id = $_GET['id'];
} else {
$id = '';
}
switch($mod)
{
case 'cadd':
countryadd();
break;
case 'newcountry':
countrywrite();
break;
case 'del':
countrydel();
break;
case 'edit':
countryedit();
break;
case 'mod':
countrymod();
break;
default:
showall();
break;
}
As Paul has pointed out above it’s a request of a new page that is causing us an issue. The removal of all php from the scripts and a simple test with html elicits the same issue
So I guess the question becomes, how to keep the original page and insert the form somehow, or do I need to redisplay the entire page with the form html included?
Sorry, the form calls another function to write the record, the form is being displayed correctly via the correct link.
The problem is the browser is interrupting a new page submission when it hits the form, that’s the issue I need to work around somehow.
A couple of people on another forum have suggested ajax, but since I don’t know that it’s problematic for me at this stage as we simply want to get it up and running and worry about smoothing the rough edges out in a later version.
Don’t worry about it, have the answer on another forum and will follow their lead on a work around.
As stated, and people seem not to be getting this, the issue is one with html and page display, not with php or anything else. As it turns out we simply fell into a gotcha and will have to take a couple of steps back to move forward on this project. Slightly irritating but I should have thought things through move thoroughly before splitting the project amongst the team
Code was posted on request
Thanks for the answers guys, but we have a workable solution now that is being implemented overnight (our time in Oz).