Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

links inside <div> tags...

Status
Not open for further replies.

bigbird3156

Programmer
Feb 20, 2001
183
AU
if I place a .php page inside another .php page like this...

Code:
<div id="mainContent">
  <?php require('cat_menu.php');  ?>
    </div>

Can I put a link in cat_menu.php that will replace itself with the new page inside the div tags of the original page?

if so how?

that sounds confusing...

index.php calls cat_menu.php within the mainContent Div tags
cat_menu.php has a link to view_all_cat.php that is to replace cat_menu.php inside index.php

sorry, I have looked around the web a fair bit for the answer to this one, but I don't know what to search under

[wiggle]The Bird from Down Under- Bigbird 3156
Programmer?? - I thought the option was pretender not programmer!![jester]
 
Hi

Like this ?
Code:
[red]<?php
$page=$_GET['page'].'.php';
if (strpos($page,'/')!==false || !file_exists("$page)) $page='cat_menu.php';
?>[/red]

<div id="mainContent">
  <?php require([red]$page[/red]);  ?>
    </div>
Code:
<a href="index.php[red]?page=view_all_cat[/red]">View all categories</a>
Code:
<a href="index.php[red]?page=cat_menu[/red]">View categories menu</a>

Feherke.
 
thanks for that...

there was a " missing in the bit that says ("$page)... but once i fixed that it worked fine...

The next logical progression of this is that you have a page set up into 2 parts... the header with a navbar and the main content...

the header always stays and the main content changes... if you had a button on the navbar highlighted depending on the page in main content, you would need to control this in a similar way I am assuming... (particularly if someone went directly to a page other than the main page)

can you suggest any leads on tutorials or anything that would help me explore this? - I realise answering a question like that would be a really big effort

[wiggle]The Bird from Down Under- Bigbird 3156
Programmer?? - I thought the option was pretender not programmer!![jester]
 
Hi

Not sure which part(s) of the page are included dynamically and how those parts are related. One try would be :
Code:
<?php
$page=$_GET['page'].'.php';
if (strpos($page,'/')!==false || !file_exists($page)) $page='cat_menu.php';
?>

<ul>
<li><a href="index.php?page=cat_menu"[red]<?php if ($page=='cat_menu') echo ' class="highlighted"'; ?>[/red]>Category menu</a></li>
<li><a href="index.php?page=view_all_cat"[red]<?php if ($page=='view_all_cat') echo ' class="highlighted"'; ?>[/red]>All categories</a></li>
</ul>

<div id="mainContent">
  <?php require($page);  ?>
    </div>
Note that the red PHP code with the separate [tt]if[/tt] statements is stupid, and the whole list should be generated. I just kept it simple for now.

Feherke.
 
Ignoring the bit above about the header nav bar thingy... I have added to your original href code to make it point to a specific record...

Code:
<a href="catalogue.php?page=biography&?rec_num=<?php echo $row_view_catalogue['rec_num']; ?>">

when I had the link call straight to biography.php (ie. not in mainContent of index.php but as aseperate page in it's own right) it worked fine... but when I make the link look like it does above it does not work - even though the url seems to be in order...

eg: .../catalogue.php?page=biography&?rec_num=9

it loads the page but does not insert the selected record.

any ideas?

[wiggle]The Bird from Down Under- Bigbird 3156
Programmer?? - I thought the option was pretender not programmer!![jester]
 
Never mind..

had a second ? after the &

[wiggle]The Bird from Down Under- Bigbird 3156
Programmer?? - I thought the option was pretender not programmer!![jester]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top