Good morning everyone,
I could be crazy but I am starting to work more on both my php skills and my mySQL skills, forgive me if I am asking the wrong question in the right forum or vice versa.
I am building a script so when I log into my backend of my website I can "turn on and off" my website, I was going to accomplish this by building a php script that compared a mySQL table value with either 1 or 0.
If table value = 0 the website is offline
else if table value is anything else - include the site
<html> <body> <?php // Make a MySQL Connection mysql_connect('localhost', 'myusername', "mypassword") or die(mysql_error()); mysql_select_db('pixelat4_mydatabase') or die(mysql_error()); // Retrieve all the data from the "example" table $result = mysql_query("SELECT * FROM onandoff") or die(mysql_error()); // store the record of the "example" table into $row $row = mysql_fetch_array( $result ); // Print out the contents of the entry //**this will be where the value is returned from the mysql database**// if ($row=='0') echo 'this will be offline'; else include("ms.pk/index.php"); ?> </body> </html>
I am currently using phpmyadmin (have never really used it before), does anybody have some good tutorials that explain indepth how to build a table(yes I have been googling and reading lots but find some of the tutorials to be contradicting and the others don't really explain why I'm doing it).
I did however manage to build a table but its not setup quite the way I think I need it setup for this to work, it has the following columns:
Field Type Collation Attributes Null Default Extra Action
I am asking in the simplest way my brain can think to put it is:
1)I am comparing a row - should I not be comparing to a single field? And if so how do I do so?
2)Is this setup right? Am I on the right track?
I know these are not the most advanced of questions but atleast I am trying!