I have a simple PHP question.
I need to add inside a DB the result of this JavaScript code
function test() {
$('#percentage').html(Math.floor((Math.random() * 100 + 1)) + '%');
};
that generate inside a div a random number. I have a couple of textbox with some other infos and hey work properly, i just need to add this one but i can't.
the code to add the other results and then to display them is this:
ADDING ELEMENTS TO DB:
include('dbconnection.php');
$Name = $_POST['name'];
$Surname = $_POST['surname'];
$Random = $_POST['random'];
$Sentence =$_POST['sentence'];
$sql = "INSERT INTO `results`(`Name`, `Surname`, `Random`, `Sentences`) VALUES('$Name', '$Surname','$Random', '$Sentence')";
$retval = mysql_query( $sql );
if(! $retval )
{
die('Could not enter data: ' . mysql_error());
}
header('Location: index.php');
DISPLAY DB RESULTS:
include('dbconnection.php');
$result = mysql_query("SELECT `Name`, `Surname`, `Random`, `Sentences` FROM `results`");
while ($row = mysql_fetch_array($result))
{
$name = $row['Name'];
$surname = $row['Surname'];
$random = $row['Random'];
echo"Name: $name -- Surname: $surname -- Random: $random</br>";}
thanks!