
Ruud Hermans
Members-
Posts
23 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
Ruud Hermans's Achievements

Newbie (1/5)
0
Reputation
-
I want to write a script that everytime when it gets called displays a diffrent message and when the last message is called jump back to the first one. I want it to display quotes of people in a little box on a website but have no idea how I should build it. Anyone any suggestions ore techniques or even maby any example scripts?
-
Going goo goo here. Full code now: <link href="../style/main.css" rel="stylesheet" type="text/css" /> </head> <body> <table class="pad" width="80%" height="*" border="0" bgcolor ="#FFFFFF" align="center"> <tr> <td> <?php include('../includes/secondheader.php') ?> <h2>Temperature Conversion</h2> <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="get"> Degrees: <input type = "text" name = "degree" size=4> <select name="scale"> <option value="celcius">Celsius</option> <option value="fahrenheit">Fahrenheit</option> <option value="kelvin">Kelvin</option> <option value="rankine">Rankine</option> </select> <br/> <input type = "submit" name = "submit"/> </form> <?php if((isset($_GET['submit']))) { if ($scale == "celcius") {print "<table border><tr><th colspan=2> Conversion Results</th></tr><tr><td>$degree</td><td>celsius</td></tr>"; $c_2_f = $degree*9/5+32; print "<tr><td>$c_2_f</td><td>fahrenheit</td></tr>"; $c_2_k = $degree+273.15; print "<tr><td>$c_2_k </td><td>kelvin</td></tr>"; $c_2_r = $c_2_f+459.6; print "<tr><td>$c_2_r</td><td>rankine</td></tr></table>";} if ($scale == "fahrenheit") {print "<table border><tr><th colspan=2> Conversion Results</th></tr><tr><td>$degree</td><td>farhenheit</td></tr>"; $f_2_c = ($degree -32)*5/9; print "<tr><td>$f_2_c</td><td>celsius</td></tr>"; $f_2_k = $f_2_c+273.15; print "<tr><td>$f_2_k </td><td>kelvin</td></tr>"; $f_2_r = $degree+459.6; print "<tr><td>$f_2_r</td><td>rankine</td></tr></table>";} if ($scale == "kelvin") {print "<table border><tr><th colspan=2> Conversion Results</th></tr><tr><td> $degree</td><td>kelvin</td></tr>"; $k_2_f = ($degree - 273.15) * 9 / 5 + 32; print "<tr><td>$k_2_f</td><td>fahrenheit</td></tr>"; $k_2_c = $degree-273.15; print "<tr><td>$k_2_c </td><td>celsius</td></tr>"; $k_2_r = $k_2_f+459.6; print "<tr><td>$k_2_r</td><td>rankine</td></tr></table>";} if ($scale == "rankine") {print "<table border><tr><th colspan=2> Conversion Results</th></tr><tr><td>$degree</td><td>rankine</td></tr>"; $r_2_f = $degree-459.6; print "<tr><td>$r_2_f</td><td>fahrenheit</td></tr>"; $r_2_c = ($r_2_f - 32)*5/9; print "<tr><td>$r_2_c </td><td>celsius</td></tr>"; $r_2_k = $r_2_c + 273.15; print "<tr><td>$r_2_k</td><td>kelvin</td></tr></table>";} } ?> <?php include('../includes/footer.php') ?> </td> </tr> </table> </body> </html> And now I am recieving this again.
-
<form action = "<?php echo $_SERVER[’PHP_SELF’]; ?>"
-
Thanks waterssars and all of you. I understand what you mean. Need to make it a if statement before executing the code. Problem now is when submitting the form it results in a 404 error for some reason.
-
What do you mean by check submit?
-
I do not get the point. I do not have the queted line of code in the script. Did you mean I need to change. if ($scale == "celcius") to this? if (isset($_GET['celcius'])) I doubt that I understood you the right way.
-
I have a script here that I am trying to run but for some reason I am recieving errors.it tells e a variable is undefined. While to me it looks like everything is ok. Any suggestions? <html> <head> <title></title> <link href="../style/main.css" rel="stylesheet" type="text/css" /> </head> <body> <table class="pad" width="80%" height="*" border="0" bgcolor ="#FFFFFF" align="center"> <tr> <td> <?php include('../includes/secondheader.php') ?> <h2>Temperature Conversion</h2> <form action = "<?php echo $_SERVER[’PHP_SELF’]; ?>" method = "GET"> Degrees: <input type = "text" name = "degree" size=4> <select name="scale"> <option value="celcius">Celsius</option> <option value="fahrenheit">Fahrenheit</option> <option value="kelvin">Kelvin</option> <option value="rankine">Rankine</option> </select> <br/> <input type = "submit" name = "tets"/> </form> <?php if ($scale == "celcius") {print "<table border><tr><th colspan=2> Conversion Results</th></tr><tr><td>$degree</td><td>celsius</td></tr>"; $c_2_f = $degree*9/5+32; print "<tr><td>$c_2_f</td><td>fahrenheit</td></tr>"; $c_2_k = $degree+273.15; print "<tr><td>$c_2_k </td><td>kelvin</td></tr>"; $c_2_r = $c_2_f+459.6; print "<tr><td>$c_2_r</td><td>rankine</td></tr></table>";} if ($scale == "fahrenheit") {print "<table border><tr><th colspan=2> Conversion Results</th></tr><tr><td>$degree</td><td>farhenheit</td></tr>"; $f_2_c = ($degree -32)*5/9; print "<tr><td>$f_2_c</td><td>celsius</td></tr>"; $f_2_k = $f_2_c+273.15; print "<tr><td>$f_2_k </td><td>kelvin</td></tr>"; $f_2_r = $degree+459.6; print "<tr><td>$f_2_r</td><td>rankine</td></tr></table>";} if ($scale == "kelvin") {print "<table border><tr><th colspan=2> Conversion Results</th></tr><tr><td> $degree</td><td>kelvin</td></tr>"; $k_2_f = ($degree - 273.15) * 9 / 5 + 32; print "<tr><td>$k_2_f</td><td>fahrenheit</td></tr>"; $k_2_c = $degree-273.15; print "<tr><td>$k_2_c </td><td>celsius</td></tr>"; $k_2_r = $k_2_f+459.6; print "<tr><td>$k_2_r</td><td>rankine</td></tr></table>";} if ($scale == "rankine") {print "<table border><tr><th colspan=2> Conversion Results</th></tr><tr><td>$degree</td><td>rankine</td></tr>"; $r_2_f = $degree-459.6; print "<tr><td>$r_2_f</td><td>fahrenheit</td></tr>"; $r_2_c = ($r_2_f - 32)*5/9; print "<tr><td>$r_2_c </td><td>celsius</td></tr>"; $r_2_k = $r_2_c + 273.15; print "<tr><td>$r_2_k</td><td>kelvin</td></tr></table>";} ?> <?php include('../includes/footer.php') ?> </td> </tr> </table> </body> </html>
-
Do you mean you just want to enter that query and it should be executed? It is indeed a query that will create a new table Yes.
-
Hahaha, I would like to write this entire query plus the creating of the table into a textfield and then run it.
-
But then I am inserting something into a table. The meaning is to insert into a database so I can create a table in the form.
-
I am pretty sure it is but I am just trying a few things to see if they would work so I understand the language better.
-
Running into a error: That would be the line with the closing tag for html. Full code now: <html> <head> <title></title> </head> <body> <form method="post"> <table width="80%" border="0" align="center"> <tr> <td width="100">Query</td> <td><textarea name="run" cols="50" rows="10"></textarea></td> </tr> <tr> <td width="100"> </td> <td> </td> </tr> <tr> <td colspan="2" align="center"><input name="save" type="submit" value="Run query"></td> </tr> </table> </form> <?php if(isset($_POST['save'])) { include 'config.php'; include 'opendb.php'; $query = 'CREATE DATABASE survivalist'; $result = mysql_query($query); mysql_select_db('survivalist') or die('Cannot select database'); $run = $_POST['run']; if(!get_magic_quotes_gpc()) { $_POST['run'] = addslashes($_POST['run']); } mysql_query($_POST['run']); if(mysql_errno()) { die('An error occured: '.mysql_error()); } ?> </body> </html> Any solutions?
-
I have been looking into those and know partly how to work with them. But this script is ment as a try out for inserting MySQL queries from a form.
-
I am quite new to this. Sorry for asking but what would the full PHP code look like then sins it also needs to create the database first?
-
I am trying to write a script that allows me to run a mysql query by inserting it into a form. The database is created but when I try to add anything in it there is a error. <html> <head> <title></title> </head> <body> <form method="post"> <table width="80%" border="0" align="center"> <tr> <td width="100">Query</td> <td><textarea name="run" cols="50" rows="10"></textarea></td> </tr> <tr> <td width="100"> </td> <td> </td> </tr> <tr> <td colspan="2" align="center"><input name="save" type="submit" value="Run query"></td> </tr> </table> </form> <?php if(isset($_POST['save'])) { include 'config.php'; include 'opendb.php'; $query = 'CREATE DATABASE survivalist'; $result = mysql_query($query); mysql_select_db('survivalist') or die('Cannot select database'); $run = $_POST['run']; if(!get_magic_quotes_gpc()) { $run = addslashes($run); } $query="$run"; mysql_query($query) or die('Error ,query failed'); include 'library/closedb.php'; echo "Query has been inserted without errors"; } ?> </body> </html> What I presume is that the error is somewhere here sins the message gets displayed. $query="$run"; mysql_query($query) or die('Error ,query failed'); Any help would be more then welcome.