Jump to content

Recommended Posts

Ok my problem is I'm trying to get this page to pull a random quote from my database and then give the user a option if they like the quote or not. So after the user decides if they like it or not they click a button with whatever choice they made. I want to get it so once they click the button it will send the answer and the quote to another table. My problem is i can get it to work untill I add $sql into the code and then the page stops displaying anything.  (Sorry for any grammer or spelling problem. English was never my strongest subject,lol.)

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Crushed</title>
<style type="text/css">
input#YES {
margin-left: 545px;
background-color: #FF0000;
}
input#MAYBE {
margin-left: 5px;
background-color: #FF0000;
}
input#NO {
margin-left: 5px;
background-color: #FF0000;
}


</style>
</head>

<body>
<?php
$user="";
$password="";
$database="";
$connection=mysql_connect('localhost',$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT `question`, `question` FROM `questions` ORDER by rand() LIMIT 1";
$result=mysql_query($query) or die(mysql_error());
$QID = htmlentities(mysql_result($result,$i,"QID"));
$question = htmlentities(mysql_result($result,$i,"question"));
echo("<blockquote>" . $QID . "  <center>" . $question . "</center></blockquote>");

?>



<form action="index.php" method="post">
<input id="YES" name="YES" type="submit" value="YES" /><input id="MAYBE" name="MAYBE" type="submit" value="MAYBE" /><input id="NO" name="NO" type="submit" value="NO" /></form>

<?php
if(isset($_POST['YES'])){
 $sql =
  
          }
?>


</body>

</html>

 

Link to comment
https://forums.phpfreaks.com/topic/176005-solved-sql-help/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.