Jump to content

shambala

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

shambala's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I tried your script out wsantos but it still gave the same error, then I tried teng84s script and it worked perfectly, thank you to everyone who helped me.
  2. UPDATE student_data SET student_data.number=all_students.number,student_data.first_name=all_students.first_name,student_data.last_name=all_students.last_name,student_data.teacher=all_students.teacher,student_data.room=all_students.room WHERE all_students.number = 1234567 AND student_data.number=all_students.number It gave me a error saying: #1109 - Unknown table 'all_students' in where clause
  3. Thank you so much wsantos it worked perfectly but it input the data into a new row instead of merging it into the row thats already there
  4. I dont know how to do that =S But that is what I want to do: Export data from all_students and import into student_data, but it need to import the data into the row that has the same "number"
  5. student_data Field Type Null Key Default Extra number int(7) first_name varchar(50) last_name varchar(50) date date 0000-00-00 teacher varchar(50) title varchar(50) author varchar(50) pages int(5) recommend varchar(3) why text room varchar(5) all_students Field Type Null Key Default Extra number int(7) first_name varchar(50) last_name varchar(50) teacher varchar(50) room varchar(5)
  6. I see what your saying now, its my fault for not explaining better. I want the data from all_students to copy over to student_data based on the number value
  7. [b]MySQL returned an empty result set (i.e. zero rows). (Query took 0.0001 sec)[/b] SQL query: SELECT S.number, A_ll.first_name FROM all_students AS A_ll LEFT JOIN student_data AS S ON S.number = A_ll.number WHERE S.number =1234 LIMIT 0 , 30 But if I change 1234 to 1234567 I get [b]Showing rows 0 - 0 (1 total, Query took 0.0001 sec)[/b] SQL query: SELECT S.number, A_ll.first_name FROM all_students AS A_ll LEFT JOIN student_data AS S ON S.number = A_ll.number WHERE S.number =1234567 LIMIT 0 , 30 It displays number and first_name beloew that but when I go to browse student_data nothing has changed
  8. Error SQL query: Documentation SELECT S.number, All.first_name FROM all_students AS ALL LEFT JOIN student_data AS S ON S.number = All.number WHERE S.number =1234 LIMIT 0 , 30 MySQL said: Documentation #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'All LEFT JOIN student_data as S ON S.number = All.number WHERE S.number = 1234' at line 1 This does sound like what I need though, for data from one table to be entered into another table by a number thats in both tables.
  9. Here is a graphical layout of what im trying to say along with table structures and test data =D (I recreated the database/tables since im not at my server, things might not be exactly the same as my script) http://www.fa-studios.downthe.net/phpprob.bmp
  10. It is a bit confusing =) but basically what I want is this: When the user types their number on the form and hits submit i want the php file to grab the teacher and name data that correspond to the number from the all_students table and input that data into the student_data table.
  11. I tried this bit of coding but this doesnt work, so any help to fix it would be great <?php $con = mysql_connect("localhost","root","*****"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("student_data", $con); $result=mysql_query("SELECT $_POST[number] FROM all_students"); $first_name = mysql_result($result,0,"first_name") $last_name = mysql_result($result,0,"last_name") $teacher = mysql_result($result,0,"teacher") $room = mysql_result($result,0,"room") $sql="INSERT INTO student_data (number, first_name, last_name, date, teacher, title, author, pages, recommend, why, room) VALUES ('$_POST[number]',$first_name,$last_name,CURDATE(),$teacher,'$_POST[title]','$_POST[author]','$_POST[pages]','$_POST[recommend]','$_POST[why]',$room)"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Thank you for participating in Durant's Cougar's Excellence in Reading Program<br><br>Click here to <a href=http://****>Submit another reading</a>"; mysql_close($con) ?>
  12. The form <html> <body> <form action="submit.php" method="post"> Student Number: <input type="text" name="number" maxlength="7" size="7" /> <br> Book's Title: <input type="text" name="title" /> <br> Author of the book: <input type="text" name="author" /> <br> Number of pages in the book: <input type="text" name="pages" maxlength="5" size="5" /> <br> Would you recommend this book to a friend?: <input type="radio" name="recommend" value="yes" /> Yes <input type="radio" name="recommend" value="no" /> No <br> Why? <br> <textarea rows="10" cols="30" wrap="virtual" name="why" /></textarea> <br> <input type="submit" /> </form> </body> </html> PHP file <?php $con = mysql_connect("localhost","root","******"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("student_data", $con); $sql="INSERT INTO student_data (number, name, date, teacher, title, author, pages, recommend, why) VALUES ('$_POST[number]','$_POST[name]',CURDATE(),'$_POST[teacher]','$_POST[title]','$_POST[author]','$_POST[pages]','$_POST[recommend]','$_POST[why]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Thank you for participating in Durant's Cougar's Excellence in Reading Program<br><br>Click here to <a href=http://*****>Submit another reading</a>"; mysql_close($con) ?> I would like for it to grab the teacher and name data from the other database according to the numer then input that all in the student_data table. Right now everything works except the teacher and name part.
  13. I have a form that asks for a number, when the user types in the number it enters that number into a database. I have a different database that has every number that a user will enter inside it along with names that correspond to that number. I would like for the php file that enters the number in the database to look for the name that goes with it and enter it in.
  14. I have a index page that asks for the Lawson Number and a submit button: <html> <body> <form action="vote.php" method="post"> Lawson Number: <input type="text" name="lnumber" /> <input type="submit" /> </form> </body> </html> It goes to vote.php for the scripts, I have a table already made with all the numbers that will be used in it, and a used column set to 0. When the user types in their lawson number I want this script to check to see if they have voted or not, if the used value is 0 then I want it to redirect to a certai page and make the value a 1, and if the value is already a 1 because they voted once already then it redirects to a different page. This is what I have so far: <?php $con = mysql_connect("localhost","root","****"); ?> If someone could help me make this happen it would help me a lot.
×
×
  • 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.