Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
Change page based on MySQL result
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Sean" data-source="post: 171371" data-attributes="member: 10142"><p>[PHP]<?php</p><p> </p><p>$mysqli = new mysqli();</p><p>$mysqli->connect('localhost', 'root', 'PASSWORD', 'DATABASENAME');</p><p> </p><p>if ($result = $mysqli->query("SELECT * FROM `cms_settings`")) {</p><p> while ($row = $result->fetch_object()) {</p><p> if($row->maintenance === "0") {</p><p> echo "NOT IN MAINTENANCE";</p><p> // header('Location: LINK TO PLACE IF MAINTENANCE IS NOT ENABLED');</p><p> }</p><p> else {</p><p> echo "IN MAINTENANCE";</p><p> // header('Location: LINK TO PLACE IF MAINTENANCE IS ENABLED');</p><p> }</p><p> }</p><p>}</p><p> </p><p>?>[/PHP]</p><p> </p><p>1 = Maintenance Enabled</p><p>0 = Maintenance Disabled</p><p> </p><p>This will work but you will need to change your database structure as your database is not set up correctly to do this properly.</p><p> </p><p>Here is what the database should look like : <a href="http://i.imgur.com/oH35U.png" target="_blank">http://i.imgur.com/oH35U.png</a></p></blockquote><p></p>
[QUOTE="Sean, post: 171371, member: 10142"] [PHP]<?php $mysqli = new mysqli(); $mysqli->connect('localhost', 'root', 'PASSWORD', 'DATABASENAME'); if ($result = $mysqli->query("SELECT * FROM `cms_settings`")) { while ($row = $result->fetch_object()) { if($row->maintenance === "0") { echo "NOT IN MAINTENANCE"; // header('Location: LINK TO PLACE IF MAINTENANCE IS NOT ENABLED'); } else { echo "IN MAINTENANCE"; // header('Location: LINK TO PLACE IF MAINTENANCE IS ENABLED'); } } } ?>[/PHP] 1 = Maintenance Enabled 0 = Maintenance Disabled This will work but you will need to change your database structure as your database is not set up correctly to do this properly. Here is what the database should look like : [URL]http://i.imgur.com/oH35U.png[/URL] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
Change page based on MySQL result
Top