Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 09-28-2008, 05:22 PM Page Information
Average Talker

Posts: 16
Trades: 0
Hey everyone I have a question. I know how to make basic news scripts and such, but I don't know how to control a page from an admin panel. How would I make something where I can have 2 radio buttons ("Disabled" "Enabled") and if I click Disabled it will make the page go offline. Also, what would I have to do to make the page have a comment of why it is offline. All help is useful, Thanks!
Ghost Sniper X is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-28-2008, 07:52 PM Re: Page Information
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
if ($pagedisabled) {
echo("some message");
} else {
// show page;
}
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-28-2008, 09:06 PM Re: Page Information
Average Talker

Posts: 16
Trades: 0
Quote:
Originally Posted by chrishirst View Post
if ($pagedisabled) {
echo("some message");
} else {
// show page;
}
I know how to display everything. I just don't know how I would create the admin panel to select whether the page is enabled or disabled and setting up the MySQL table. Also, I would like all my pages to have this feature, so how would I set all of this up where every page pulls different information from the database.

Last edited by Ghost Sniper X; 09-28-2008 at 09:08 PM..
Ghost Sniper X is offline
Reply With Quote
View Public Profile
 
Old 09-28-2008, 11:23 PM Re: Page Information
Mattmaul1992's Avatar
Ultra Talker

Posts: 486
Name: Matt
Trades: -1
Every page should have an ID. You will take that ID and compare it against the database. Your database will have a column which will tell your script if that page is online or not. I've done plenty of things like this in the past few years.. Here's a small example -
Code:
MySQL TABLE - Pages

page_id  page_name show_page reason_offline
1           news         1              
2           forums       0              Because our forums suck
PHP Code:
PAGE BEING DISPLAYED news.php

$page_id 
$_GET['page_id']; // What page is this?
$query "SELECT * FROM pages WHERE page_id=`$page_id`"// Grab page DB info
$result mysql_query($query) or die ('Error in query: ' mysql_error()); // Grab MySQL result
$row mysql_fetch_object($result); // Put result into an object
if ($row->show_page == 0)
{
// Page is offline. Let em know..
print "This page is currently offline. Please check back later. Reason: $row->reason_offline";
die; 
// Kill the page.. Make sure to display the rest of your HTML though.

To explain.. You have 4 columns in the table "pages". The columns identify page_id, name, if it's offline or not, and why it's offline.
Your code on all of your pages grabs that specific pages row in the database based on the page id provided using the get method. You sound new so in case you don't know you pass information via the url (www.something.com/index.php?page_id=1) to your script by using $_get['page_id'].
This is all EXTREMELY basic. If you don't understand what I've said here you really need to hit the books much harder. PHP is easy once you get the hang of it.
Good luck. Let me know if you need more help.
__________________
PHP Code:
$talkupation++; 

Please login or register to view this content. Registration is FREE
- Free IPB forum hosting (releasing today!!!), no ads, free modifications
Mattmaul1992 is offline
Reply With Quote
View Public Profile
 
Old 09-28-2008, 11:51 PM Re: Page Information
Average Talker

Posts: 16
Trades: 0
I get what you are saying, I understand the functions. Isn't it possible for users to avoid this though? I have a few questions though. I wanted to avoid having my urls "index.php?=1." Plus, wouldn't it be easy for people to just edit the url to a different page id that is online, therefore allowing them to see the disabled page? Is there a way I can simply just make the php $page_id = 1;.

I am sure that above code would send me errors, but I will find out. Thank you very much for the help though . I am fairly new to php, but I am having a lot of fun learning it, and I am starting to understand a lot more.
Ghost Sniper X is offline
Reply With Quote
View Public Profile
 
Old 09-29-2008, 12:34 AM Re: Page Information
Mattmaul1992's Avatar
Ultra Talker

Posts: 486
Name: Matt
Trades: -1
sure you could do that. I was thinking you had a more CMS driven website but if you want to keep things as static as possible that's definitely the best way to do it.
__________________
PHP Code:
$talkupation++; 

Please login or register to view this content. Registration is FREE
- Free IPB forum hosting (releasing today!!!), no ads, free modifications
Mattmaul1992 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Page Information
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.29527 seconds with 12 queries