www.webdeveloper.com
Results 1 to 2 of 2

Thread: Inserting into multiple tables

  1. #1
    Join Date
    May 2012
    Posts
    1

    Exclamation Inserting into multiple tables

    I can't seem to insert data into multiple tables

    User(User_ID, Email, First_Name, Second_Name, Gender, Age, Password, Title)
    Workout(Workout_ID, User_ID, Date)
    Exercise(Exercise_ID, Name, Description, Image)
    Workout_Exercises(Workout_Exercises_ID, Workout_ID, Exercise_ID, Reps, Sets)

    Now when I go to do this:

    Code:
    $insert1 = mysql_query("INSERT INTO exercise(Name) values('$exercise1');");
    
    $insert2 = mysql_query("INSERT INTO workout_exercises(Reps, Sets) values($reps1, $sets1);");
    The exercise gets inserted but the reps and sets do not get inserted into the workout_exercises table. I think this has something to do with the Exercise_ID and the Workout_ID but I am really not sure.

    Please someone help!

  2. #2
    Join Date
    May 2012
    Posts
    6
    remember the basic of coding:

    always check the syntax if you omit single qoute, semi colon, etc.

    in your case

    $insert1 = mysql_query("INSERT INTO exercise(Name) values('$exercise1');");
    >remove the semi colon

    $insert2 = mysql_query("INSERT INTO workout_exercises(Reps, Sets) values('$reps1',' $sets1');");

    >enclose your values in single quote
    >remove semi colon


    regards

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles