![]() |
Multiple If satements
I have a php file that has an if statement... If this link is clicked, it will show a web form and not show anything else. If the link is not clicked the data will be shown.
Now, I want to have another link that will load only a certain type of data, basically sorting the MySQL information a certain way. I'm not sure how to implement this. Here's the current code that I have now: PHP Code:
|
ok here's the whole idea, if you won't get it then ask again to explain in full.
NOTE: i would prefer not to use if(): endif; but, i would prefer if() {} the second approach is more clear PHP Code:
|
I think I understand what you're saying, but I can't get it to implement right.
Basically, what I'm trying to do is take the code I have now, add another IF statement, so when the search link is clicked, it will reload index.php but only show the search HTML portion, just like it does with the game submission form. |
sure just add the following lines BEFORE THE ELSE STATEMENT
PHP Code:
AND replace the echo statement with your search form |
I'm still confused, I tried a few different layouts and wasn't able to get this to work. Here's what I currently have for code that works, at the top you can see that the
<?php if (isset($_GET['addgame'])): // User wants to add a Xbox Title ?> statement is where it only shows the add form, then after the add form HTML, there's an if statement that loads the actual PHP code for the rest of the site. PHP Code:
|
ok, first to make sure
1) if addgame is in the url means show the form 2) when the form is submitted then enter the info in database and show the info Now you wanna add 3) if, say, search is in the url then search the database. if i am right then heres the code which will work PHP Code:
|
Great, I got it working. Thank you! Now I understand after seeing the code implemented.
I think later on, submit a game and search will have a separate files / pages. |
Seperating pages in to different pages is a good thing. its easy to handle them.
OR you have tohe option to do it right now, WITHOUT CHANGING any thing. here's the idea add.php PHP Code:
PHP Code:
PHP Code:
PHP Code:
hope this helps EDIT: again i prefer to use {} in if statements rather than : {} are just easy to read and notice, coz you always know where it'll end |
| All times are GMT. The time now is 05:30 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0