...

View Full Version : changing id with php ???



keissfootball
08-31-2006, 08:29 PM
hello. I want to know if it's possible to take an included file and change some lines when echo-ing?

For example, if my code is like this:


<ul id="primary-nav">
<li><a href="#">123</a></li>
<li class="menuparent"><a href="#">456</a>
<ul>
<li><a href="#">789</a></li>
</ul>
</ul>

Can I change the first line to this:

<ul id="secondary-nav">
???

Lee Stevens
08-31-2006, 08:58 PM
Can you explain more, do you mean hiding and showing layers, or diffrent CSS when it'sclicked?

keissfootball
09-01-2006, 05:54 AM
I don't know if it's possible, but I want to include file and then somehow change the first line in it - this would be the first line:

<ul id="secondary-nav">

or simply fopen file and maybe somehow delete that line. Is that possible?

musher
09-01-2006, 06:23 AM
What you'd have to do is set a variable and then use that (something like this.


If (this condition) {
$id_name="primay-nav";
}else{
$id_name="secondary-nav";
}
include_once("includes/your_include_name.php");



<ul id="<?php echo $id_name; ?>">
<li><a href="#">123</a></li>
<li class="menuparent"><a href="#">456</a>
<ul>
<li><a href="#">789</a></li>
</ul>
</ul>

keissfootball
09-01-2006, 06:42 AM
Will it work, if I give something like this:


$condition=$POST['$send']; // $send=send_no
if ($condition="send_yes";) {
$id_name="primay-nav";
}else{
$id_name="secondary-nav";
}
include_once("includes/file.php");


Sorry, that I can't test it myself, I just don't have available server right now.

musher
09-01-2006, 07:41 AM
Yes, that should work


Will it work, if I give something like this:


$condition=$POST['$send']; // $send=send_no
if ($condition="send_yes";) {
$id_name="primay-nav";
}else{
$id_name="secondary-nav";
}
include_once("includes/file.php");

Sorry, that I can't test it myself, I just don't have available server right now.

keissfootball
09-01-2006, 10:46 AM
Do I have to pass it through post??? Because if I leave the code as is, it displays <ul id="">

musher
09-01-2006, 06:15 PM
No, You should have this is your main file


$condition=$_POST['$send']; // $send=send_no
if ($condition="send_yes";) {
$id_name="primay-nav";
}else{
$id_name="secondary-nav";
}
include_once("includes/file.php");
and this in your include

<ul id="<?php echo $id_name; ?>">
Make sure that $_POST['$send'] has something in it i.e. "send_yes " for primay-nav to be true (I would echo it)

arnyinc
09-01-2006, 08:15 PM
Don't forget the underscore.

$_POST["whatever"]

musher
09-02-2006, 06:57 PM
Don't forget the underscore.

$_POST["whatever"]
Good catch arnyinc.:rolleyes:

Fumigator
09-02-2006, 10:54 PM
Don't forget to use the "is this equal to this" rather than the "set this equal to this" (and get rid of that semicolon):


if ($condition="send_yes";) { //wrong
if ($condition == "send_yes") { //right



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum