whiteboikyle Posted July 2, 2008 Share Posted July 2, 2008 $result = $config->query("SELECT * FROM pages"); for ($i = 0; $i < mysql_num_rows($result); $i = $i + 1) { $page = mysql_result($result, $i, "pages"); elseif($function == "$page") { include("functions/".$page.".php"); } } i need it to add an elseif to the actual if equation.. so pretty much when they add a function it does it all for them.. Link to comment https://forums.phpfreaks.com/topic/112878-i-need-help-with-syntax/ Share on other sites More sharing options...
trq Posted July 2, 2008 Share Posted July 2, 2008 What? Your code and question make little sense. Link to comment https://forums.phpfreaks.com/topic/112878-i-need-help-with-syntax/#findComment-579781 Share on other sites More sharing options...
whiteboikyle Posted July 2, 2008 Author Share Posted July 2, 2008 okay i am making something where people can add a function.. Well each function is viewed by a $_GET['view'] well... For the function to work it has to be allowed through the view.php page.. So i want it to add an elseif{ the include function } and loop it through.. here is the full page.. <?php include("header.php"); session_start(); $myusername = $_SESSION['myusername']; $function = $_GET['function']; if(isset($myusername)){ if(isset($function)){ if($function == ""){ header("location: main.php"); } $result = $config->query("SELECT * FROM pages"); for ($i = 0; $i < mysql_num_rows($result); $i = $i + 1) { $page = mysql_result($result, $i, "pages"); elseif($function == "$page") { include("functions/".$page.".php"); } } else{ echo("<center> You entered an invalid function line! </center>"); } }else{ header_sent("main.php"); } } else{ header_sent("main.php"); } include("footer.php"); ?> Link to comment https://forums.phpfreaks.com/topic/112878-i-need-help-with-syntax/#findComment-579785 Share on other sites More sharing options...
whiteboikyle Posted July 2, 2008 Author Share Posted July 2, 2008 What i am trying to say.. its kinda hard to explain.. but like here is an example.. lets say i have a table that had a column called name.. well what the name is, its a name of a php file.. and lets say you wanted to loop out the php files.. using php laungage.. so instead of doing something with a loop and echoing something.. i wan it to loop and print some php code.. but not just display it.. i want it to run that php code.. so what i want this code to do is loop the actual php code so $page = banip would echo this.. (but not really echo.. just show the code) elseif($function == "banip") { include("functions/banip.php"); } Link to comment https://forums.phpfreaks.com/topic/112878-i-need-help-with-syntax/#findComment-579811 Share on other sites More sharing options...
bluejay002 Posted July 2, 2008 Share Posted July 2, 2008 instead of: ... for ($i = 0; $i < mysql_num_rows($result); $i = $i + 1) { $page = mysql_result($result, $i, "pages"); elseif($function == "$page") { include("functions/".$page.".php"); } } ... try: ... for ($i = 0; $i < mysql_num_rows($result); $i = $i + 1) { $page = mysql_result($result, $i, "pages"); if($function == "$page") { include("functions/".$page.".php"); break; } } ... if that is what you are aiming. Link to comment https://forums.phpfreaks.com/topic/112878-i-need-help-with-syntax/#findComment-579824 Share on other sites More sharing options...
whiteboikyle Posted July 2, 2008 Author Share Posted July 2, 2008 Look at my last 1.. i am trying to do alot of elseif's.. but i need it to ECHO the php so to speak.. but not really echo.. It needs to print the actual PHP code through a loop into the PHP! not into the website! EDIT: okay well here is another way to explain it.. i dono how else to.. if you do an if statement with some elseifs and else at the end liek so if(){ } elseif(){ } elseif(){ } elseif(){ } else{ } well.. the 3 elseif i want to make them generated.. but i just dono how to make it print php code to the php document.. Link to comment https://forums.phpfreaks.com/topic/112878-i-need-help-with-syntax/#findComment-579860 Share on other sites More sharing options...
whiteboikyle Posted July 2, 2008 Author Share Posted July 2, 2008 if($function == ""){ header("location: main.php"); } $result = $config->query("SELECT * FROM pages"); for ($i = 0; $i < mysql_num_rows($result); $i = $i + 1) { $page = mysql_result($result, $i, "pages"); elseif($function == "$page") { include("functions/".$page.".php"); } } else{ echo("<center> You entered an invalid function line! </center>"); } see the if statement and the else at the end.. i want the elseif statements in the middle to be generated! like so it looks like if(){ } elseif(){ } elseif(){ } elseif(){ } else(){ } of course there will be way more elseif statments then that but i am trying to explain this to you guys Now i am pretty sure there is a way to do this! I know the way i wrote it wont work... lol thats why i am asking for help.. now if someone could help me i would be of so much appreciation ! Link to comment https://forums.phpfreaks.com/topic/112878-i-need-help-with-syntax/#findComment-579883 Share on other sites More sharing options...
trq Posted July 2, 2008 Share Posted July 2, 2008 If you indent your code logically we might be able to read it. Look at your last post, your fist if is closed on the third line, hence there is no room for an elseif. I think you need to get back to basics. Link to comment https://forums.phpfreaks.com/topic/112878-i-need-help-with-syntax/#findComment-579993 Share on other sites More sharing options...
whiteboikyle Posted July 2, 2008 Author Share Posted July 2, 2008 The way i logically wrote it, is wrong.. but they way i want it to work is correct.. Dont look at my code.. i know what i want it to do.. i was just using to show what i want it to do.. but i want to PRINT PHP CODE TO THE PHP DOCUMENT! that is all Link to comment https://forums.phpfreaks.com/topic/112878-i-need-help-with-syntax/#findComment-580447 Share on other sites More sharing options...
trq Posted July 2, 2008 Share Posted July 2, 2008 I think you need to get back to basics. Theres a good link in my signiture. Link to comment https://forums.phpfreaks.com/topic/112878-i-need-help-with-syntax/#findComment-580451 Share on other sites More sharing options...
whiteboikyle Posted July 2, 2008 Author Share Posted July 2, 2008 naw i know alot about php.. btw found the function.. eval(); lol i am surprised to see no 1 found that.. lol Link to comment https://forums.phpfreaks.com/topic/112878-i-need-help-with-syntax/#findComment-580473 Share on other sites More sharing options...
DarkWater Posted July 2, 2008 Share Posted July 2, 2008 Eval() is generally considered insecure. What exactly are you trying to do? Let people run their own functions on your site? Link to comment https://forums.phpfreaks.com/topic/112878-i-need-help-with-syntax/#findComment-580474 Share on other sites More sharing options...
whiteboikyle Posted July 3, 2008 Author Share Posted July 3, 2008 no lol i figured it out.. Dark Water message me later i will explain it Link to comment https://forums.phpfreaks.com/topic/112878-i-need-help-with-syntax/#findComment-580538 Share on other sites More sharing options...
trq Posted July 3, 2008 Share Posted July 3, 2008 ol i am surprised to see no 1 found that.. lol Maybe the reason nobody found it is because of the distinct lack of detail in your request. If you can't piece together a question, how are we meant to provide an answer? Link to comment https://forums.phpfreaks.com/topic/112878-i-need-help-with-syntax/#findComment-580564 Share on other sites More sharing options...
bluejay002 Posted July 3, 2008 Share Posted July 3, 2008 lol i am surprised to see no 1 found that.. lol @whiteboikyle You cannot blame the people trying to help you then just disclosed with that because of a poorly structured question in the first place. No offense here, though am also new here, I don't find your recent posts quite polite unless a certain ego was touched. I just understood your question at your third to the last post in this thread. that's a nice find though . peace! Link to comment https://forums.phpfreaks.com/topic/112878-i-need-help-with-syntax/#findComment-580655 Share on other sites More sharing options...
whiteboikyle Posted July 4, 2008 Author Share Posted July 4, 2008 No, dont take it rude at all.. I know i cant put my questions together.. I am a bad write. I usually explain stuff by pictures.. But, its a lack of creativity haha.. but, what i ment was i posted that on another forum with like less people then here, (300 members) and they found it first post. Thats what i ment by that.. Link to comment https://forums.phpfreaks.com/topic/112878-i-need-help-with-syntax/#findComment-581785 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.