Jump to content

Swole

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Swole's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am wondering what I am doing wrong. I'm trying to add to one table and at the same time update another table. It'll add to a table with no problems but it won't update the other table. Here's the code and thanks in advance. <!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 method="post"> <input name="YES" type="submit" value="YES" id="YES" /><input id="MAYBE" name="MAYBE" type="submit" value="MAYBE" /><input id="NO" name="NO" type="submit" value="NO" /></form> <?php $yes = YES; $maybe = MAYBE; $no = NO; if (isset($_POST['YES'])) { $sql = "INSERT INTO answered(Qanswered, answer)VALUES('$question', '$yes')"; $query = "UPDATE user SET Votes='1' WHERE USER ID='87654' "; $result=mysql_query($sql);} if (isset($_POST['MAYBE'])) { $sql = "INSERT INTO answered(Qanswered, answer)VALUES('$question', '$maybe')"; $result=mysql_query($sql);} if (isset($_POST['NO'])) { $sql = "INSERT INTO answered(Qanswered, answer)VALUES('$question', '$no')"; $result=mysql_query($sql);} ?> </body> </html>
  2. That worked!!! Thanks a bunch...
  3. 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>
×
×
  • 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.