Jump to content
xisto Community
coldasice

[php]diffrent Type Of Template [id] With Includes ;)

Recommended Posts

<?PHP?><html><head><title>Example</title><style><!--        A                         { color: #003366; text-decoration: none; }        A:link                { color: #003366; text-decoration: none; }        A:visited        { color: #003366; text-decoration: none; }        A:active        { color: #54622D;  }        A:hover        { color: #54622D;  }BODY,TD,TR{                font-family: verdana, arial, sans-serif;                color:#000;                font-size:11;                font-weight:normal;}.banner {        font-family: georgia, verdana, arial, sans-serif;        color:white;        font-size:x-large;        font-weight:bold;        border-left:1px solid #FFF;        border-right:1px solid #FFF;        border-top:1px solid #FFF;        background:#003366;        padding:7px;}.description{        font-family:verdana, arial, sans-serif;        font-size:x-small;        font-weight:bold;}//--></style></head><body bgcolor="#ffffff"><div align="center"><center><table border="0" width="700" cellspacing="0" cellpadding="0"><tr>        <td class=banner >        Put here your title<br>        <span class="description">and this is your description</span>        </td></tr><tr><td>  </center> <table border="0" width="100%" cellspacing="0" cellpadding="6"><tr>  <td width="180" valign=top style="border-right: 1px dotted #000000;"><table border="0" width=93% cellspacing="0" cellpadding="0"> <tr><td width="100%" style="border-top: 1 solid #000000; border-bottom: 1 solid #000000" bgcolor="#F3F4F5" height="26"><p align="left"> <b><font color="#003366">Navigation</font></b></p></td> </tr> <tr><td width="100%"> </td> </tr> <tr><td width="100%"> <a href="">main page</a></td> </tr> <tr><td width="100%"> <a href="?do=admin">admin</a></td> </tr> <tr><td width="100%"> <a href="?id=$id">edit admin</a></td> </tr> <tr><td width="100%"> <a href="?do=main">other link</a></td> </tr> <tr><td width="100%"> <a href="">other link</a></td> </tr> <tr><td width="100%"> </td> </tr> <tr><td width="100%" style="border-top: 1 solid #000000; border-bottom: 1 solid #000000" bgcolor="#F3F4F5" height="26"><p align="left"> <font color="#003366"><b>Quick search</b></font></p></td> </tr> <tr><td width="100%"></td> </tr> <tr><!-- The Quick Search Form --><form method="post"><td width="100%" align="center"> <br><input type="text" name="story" size="14"><input type="hidden" name="do" value="search"></td></form><!-- End of the Search Form --> </tr> <tr><td width="100%"> </td> </tr> <tr><td width="100%" style="border-top: 1 solid #000000; border-bottom: 1 solid #000000" bgcolor="#F3F4F5" height="26"><p align="left"> <b><font color="#003366">banners/sponsors</font></b></p></td> </tr> <center><tr><td width="100%"> </td></tr><tr><td width="100%"> put some banners here</td></tr><tr><td width="100%"> </td></tr><tr><td width="100%"> and another banners here</td></tr><tr><td width="100%"> </td></tr><tr><td width="100%" style="border-top: 1 solid #000000; border-bottom: 1 solid #000000" bgcolor="#F3F4F5" height="26"><p align="left"> <font color="#003366"><b>Friends</b></font></p></td></tr><tr><td width="100%"> </td></tr><tr><td width="100%"> </td></tr><tr><td width="100%"> <a href="http://news.google.com/news?cf=all&hl=en&pz=1&ned=us&q&js=0; target="_blank">Google News</a></td></tr><tr><td width="100%"> <a href="https://www.mozilla.org/en-US/; target="_blank">Mozilla.org</a></td></tr>  </table>    <p align="center"><br><br>    <br>    <br>    <br>    </center>  </td>  <td width="520" valign="top" align="center"><table border="0" width="453" cellspacing="1" cellpadding="3"><tr><td width="441"><?PHP/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  Here we decide what page to include ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */if($_POST['do'] == "search" or $_GET['dosearch'] == "yes"){ $subaction = "search"; $dosearch = "yes"; include("./search.php"); }elseif($_GET['do'] == "admin"){ include("./admin.php"); }elseif($_POST['do'] == "admin" || $_POST['&id'] == '$id') { include("./edit.admin.php"); } //tryed.. but dont work =Delseif($_POST['do'] == "admin") { include("./admin.php"); }?></td></tr></table> </td>      </tr>    </table>    </td>  </tr></table><br><br><center><table border=0 width=700 style="border-top: 1px dotted #000000;"><tr><td>    <p align="center">put your footer and copyright here</td></tr></table></body></html>

well basicly what i wonder here is if this is a good way.. :)it works perfectly...well another thing is.. it works with like do=asdbut how can i do . do=asd&id=1231&google=123if its possible that is.. as u see i tryed.. ;O

Share this post


Link to post
Share on other sites

HA!... I thought the code looked familiar...

http://forums.xisto.com/no_longer_exists/

Let me know if you want a copy of the script or Template. BH and I worked on that some time ago. We have a w3c valid div/css based version on the Annex site that does an Image swap based on the menu selection.

To answer your question about using several values in the Query string, handle the first element and then the second gets checked based on the first value, etc. essentially, you need to have nested if statement blocks.

if ( do == admin) { // first if block starts hereif ( add ) {... add an id here ...}if ( edit ) {... find the id number and edit it here...}if (delete ) {... delete the id here ...}} // first if block ends here
Hope this helps.

Share this post


Link to post
Share on other sites

HA!... I thought the code looked familiar...
http://forums.xisto.com/no_longer_exists/

Let me know if you want a copy of the script or Template. BH and I worked on that some time ago. We have a w3c valid div/css based version on the Annex site that does an Image swap based on the menu selection.

To answer your question about using several values in the Query string, handle the first element and then the second gets checked based on the first value, etc. essentially, you need to have nested if statement blocks.

if ( do == admin) { // first if block starts hereif ( add ) {... add an id here ...}if ( edit ) {... find the id number and edit it here...}if (delete ) {... delete the id here ...}} // first if block ends here
Hope this helps.

hmm.. didnt quite understand :(


so u say if i do somthing like this`?

elseif($_POST['do'] == "admin") { elseif ($_POST['&id'] == '$id'){include("./edit.admin.php");} }

it will enter edit.admin.php with these tags? do=admin&id=1 ?

btw i guess u know where i found this.. can this be done inside the edit.admin.php or a function?

i just thought it way of doing this was awsome.. the other ones i just get blank side of.. nvm this.. just slipped.. <- delete :)

Share this post


Link to post
Share on other sites
elseif($_POST['do'] == "admin") { elseif ($_POST['&id'] == '$id'){include("./edit.admin.php");} }
you need to complete one 'if' before the 'elseif'.
My code code have been done differently using elseif's:

if ( do == admin) { // first if block starts hereif ( add ) {... add an id here ...}elseif ( edit ) {... find the id number and edit it here...}elseif (delete ) {... delete the id here ...}} // first if block ends here

Share this post


Link to post
Share on other sites

elseif($_POST['do'] == "admin") { elseif ($_POST['&id'] == '$id'){include("./edit.admin.php");} }
you need to complete one 'if' before the 'elseif'. My code code have been done differently using elseif's:

if ( do == admin) { // first if block starts hereif ( add ) {... add an id here ...}elseif ( edit ) {... find the id number and edit it here...}elseif (delete ) {... delete the id here ...}} // first if block ends here


ARG!!! still dont get it....

can u post result.. on that one.. maby that clears it.. maby fill in the id.. -.- sorry im at a total stop -.-

Share this post


Link to post
Share on other sites

the usage of TABLE for page layout is now not a standard. avaoid using tables and use only divs and add the style sheets in a seperate CSS file.

yeah i guessed so.... -.-

but its the function not the layout...

i have another look now that im awake =D

Share this post


Link to post
Share on other sites

A Table-less version of this script is available at the Xisto Annex.
See the link in the pink bar above the Shoutbox. Select Annex > Scripts > Targetframes for the Demo.
or http://forums.xisto.com/no_longer_exists/

Source code for the div-based layout is found at : http://forums.xisto.com/no_longer_exists/

When there are multiple parts in the Query string, such as "?type=admin&act=edit&id=1234", the value of id is frequently used inside the php script as a value for data retrieved from a database, so you would not need to 'handle' the id = in the logic flow of the script.
Using the script logic I wrote above, I will demonstrate the use of a data value here:

if ( do == admin) { // first if block starts hereif ( add ) {... add an id here ...... present a form for inputting a new member here... complete with the mysql code to insert the member into the Database}elseif ( edit ) {... find the id number and edit it here...... present a form here for editting a member's information... and then update the Database with the information}elseif (delete ) {... delete the id here ...... using a mysql query, find the member with id = 1234  and delete the member's information}} // first if block ends here
As you can see, not everything in the query string affects the Logical flow of the script. in this example, id is a value for retrieving information from the Database.
Is that like what you plan on doing? This is a good example of 'dynamic' web site scripting. Instead of checking each and every value so you match an id, use the database features to write one set of scrpting code to perform a task based on the value passed in the query string. You do not need to write a code snippet for each id = value. Use the value to change the database.
Hope this helps.

Incidently, the above code will not run properly. It is called 'pseudo-code' and is used to represent the logic flow of a script/program only. the full scripting would need to be inserted in the correct places, etcetera. All the php and mysql is missing, but the pseudo-code explains what needs to be done at various spots. It is used to define a solution before the coding starts in order that you have an understanding of the solution and the methods to solve them.

Share this post


Link to post
Share on other sites

A Table-less version of this script is available at the Xisto Annex.See the link in the pink bar above the Shoutbox. Select Annex > Scripts > Targetframes for the Demo.
or http://forums.xisto.com/no_longer_exists/

Source code for the div-based layout is found at : http://forums.xisto.com/no_longer_exists/

i think u all misunderstand me...
i dont care about layout......

i care about code...

jlhaslip.. i dont understand yours...

basicly this template comes from cutenews...
and when i press a link.. it uses template.. and get all links inside.. the ..

like when i press news... it goes template.com/index.php?do=news?id=12&mod=edit.. for example :=) <- this will show in adress bar and when it does it access page news with id2 and in edit mode =) <- example...

and all that happens in index template..

[hr=noshade] [/hr]
lets go over this again....

what i want to do when do=admin is show feks the admin.php

and when it shows do=admin&mode=edit&id=1 it shows the edit.admin.php where the user is id 1

think i formuled it better=?

and i dont know if this is written in the template.. or in the edit.admin.php =?

Share this post


Link to post
Share on other sites

what i want to do when do=admin is show feks the admin.php

 

and when it shows do=admin&mode=edit&id=1 it shows the edit.admin.php where the user is id 1

The code i will show you is similar to what jlhaslip has been showing you this whole time:

$mode = $_GET['mode'];

$id = $_GET['id'];

 

if ($do == "admin"){ // if do=admin, do...

 

if ($mode == "edit"){ // if mode=edit, do...

 

if ($id == "1"){

include "edit.admin.php";

} else {

// do whatever...

}

 

} else if ($mode == "delete"){ // if mode=delete, do...

 

if ($id == "1"){

include "delete.admin.php";

} else {

// do whatever...

}

 

} else if ($mode == "add"){ // if mode=add, do ...

 

if ($id == "1"){

include "add.admin.php";

} else {

// do whatever...

}

 

} else { // if there is no mode set or if it is set with an "unknown" value, do...

 

include "admin.php";

 

}

 

}

 

?> linenums:0'><?php$do = $_GET['do'];$mode = $_GET['mode'];$id = $_GET['id'];if ($do == "admin"){ // if do=admin, do...if ($mode == "edit"){ // if mode=edit, do... if ($id == "1"){ include "edit.admin.php"; } else { // do whatever... }} else if ($mode == "delete"){ // if mode=delete, do... if ($id == "1"){ include "delete.admin.php"; } else { // do whatever... }} else if ($mode == "add"){ // if mode=add, do ... if ($id == "1"){ include "add.admin.php"; } else { // do whatever... }} else { // if there is no mode set or if it is set with an "unknown" value, do... include "admin.php";}}?>


Do you understand how it works now?

 

Note: the code above has not been tested, but should still work.

Share this post


Link to post
Share on other sites

The code i will show you is similar to what jlhaslip has been showing you this whole time:


$mode = $_GET['mode'];

$id = $_GET['id'];

 

if ($do == "admin"){ // if do=admin, do...

 

if ($mode == "edit"){ // if mode=edit, do...

 

if ($id == "1"){

include "edit.admin.php";

} else {

// do whatever...

}

 

} else if ($mode == "delete"){ // if mode=delete, do...

 

if ($id == "1"){

include "delete.admin.php";

} else {

// do whatever...

}

 

} else if ($mode == "add"){ // if mode=add, do ...

 

if ($id == "1"){

include "add.admin.php";

} else {

// do whatever...

}

 

} else { // if there is no mode set or if it is set with an "unknown" value, do...

 

include "admin.php";

 

}

 

}

 

?> linenums:0'><?php$do = $_GET['do'];$mode = $_GET['mode'];$id = $_GET['id'];if ($do == "admin"){ // if do=admin, do...if ($mode == "edit"){ // if mode=edit, do... if ($id == "1"){ include "edit.admin.php"; } else { // do whatever... }} else if ($mode == "delete"){ // if mode=delete, do... if ($id == "1"){ include "delete.admin.php"; } else { // do whatever... }} else if ($mode == "add"){ // if mode=add, do ... if ($id == "1"){ include "add.admin.php"; } else { // do whatever... }} else { // if there is no mode set or if it is set with an "unknown" value, do... include "admin.php";}}?>


Do you understand how it works now?

 

Note: the code above has not been tested, but should still work.


im sorry for all the questioning.. this makes it easyer =)

 

gona test now =D

 

[edit]

thanks this works..

 

but just wondering where to place this?????

 

like in my edit.. or just in my "template"?

Edited by coldasice (see edit history)

Share this post


Link to post
Share on other sites

but just wondering where to place this?????

 

like in my edit.. or just in my "template"?

Going with the file names you have provided in this topic, it would go in admin.php, since edit.admin.php will be included.

Share this post


Link to post
Share on other sites

Going with the file names you have provided in this topic, it would go in admin.php, since edit.admin.php will be included.

hmmmm...

 

 

strange.. when i put this in my admin.php... it dosnt work..

 

but when i put it in a include file it works.. O.o

 

like

 


$mode = $_GET['mode'];

$id3 = $_GET['id'];

 

if ($do == "admin"){ // if do=admin, do...

 

if ($mode == "edit"){ // if mode=edit, do...

 

if ($id3 == "3"){

include "edit.admin.php";

} else {

include ('admin.php');

 

}

}

}

linenums:0'>$do = $_GET['do'];$mode = $_GET['mode'];$id3 = $_GET['id'];if ($do == "admin"){ // if do=admin, do...if ($mode == "edit"){ // if mode=edit, do...if ($id3 == "3"){include "edit.admin.php";} else {include ('admin.php');}}}


and put it in.. include.edit.php

 

and do like

 

in admin.php i do

 

include ('include.edit.php')

 

then i just refreseh admin.php and add the include in top.. ;=) it basicly works... but not the way its suppost when i use it as an include -.-

..

but when i add the pure code.. in to admin.php it dont work at all :)(( <--- scratch that.. it works..

 

seems like it works =D..

 

btw if i put a hidden field or two in the form.... in admin..

 

can i then use that instead of those ifs?

 

question 2.

 

if($subaction == "new"){            echoheader("options", "New Template");        echo"<form method=post action=\"$PHP_SELF\"><table border=0 cellpading=0 cellspacing=0 width=100% height=100%><tr><td >Create new template based on: <select name=base_template>";        foreach($templates_list as $single_template){                echo "<option value=\"$single_template\">$single_template</option>";        }        echo '</select> with name <input type=text name=template_name>  <input type=submit value="Create Template">        <input type=hidden name=mod value=options>        <input type=hidden name=action value=templates>        <input type=hidden name=subaction value=donew>        </td></tr></table></form>';        echofooter();            exit;    }    /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~      Do Create the new template     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */        if($subaction == "donew"){        if(!eregi("^[a-z0-9_-]+$", $template_name)){ msg("error", "Error", "The name of the template must be only with letters and numbers", "$PHP_SELF?mod=options&subaction=new&action=templates"); }        if(file_exists("./data/${template_name}.tpl")){ msg("error", "Error", "Template with this name already exists", "$PHP_SELF?mod=options&subaction=new&action=templates"); }        if($base_template != ""){ $base_file = "./data/${base_template}.tpl"; }        else{ $base_file = "./data/Default.tpl"; }        if (!copy($base_file, "./data/${template_name}.tpl")) {                msg("error", "Error", "Can not copy file $base_file to ./data/ folder with name ${template_name}.tpl");                }        @chmod("./data/${template_name}.tpl", 0777);        msg("info", "Template Created", "A new template was created with name <b>${template_name}</b><br>", "$PHP_SELF?mod=options&action=templates");    }
here i noticed.. these

<input type=hidden name=subaction value=donew>

 

if($subaction == "donew")

 

so do these 2 have any thing in common?

but why is name $subaction?.. and why cant i find any $subaction =.. only $subaction ==..

 

:(:(

Edited by coldasice (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.