Jump to content

tta013

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

tta013's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. You get the club ID from the array on the first line....
  2. Dear Dowdy, Many thanks for your reply. I would def like each of the clubs on the seperate rows. Could you please calrify a litte bit for me of your reply. Are you saying I replace the WHILE loop with FOR Loop? Thanks in advance.
  3. Hi all, I had submitted the same question a few weeks back but I don't think I gave the whole picture of the problem. Basically I have a feedback form. So when a client click on a create a review, I want the client to fill out the questionnaire for the clubs that they have joined. (There are about 10 different clubs). So here is the code: <div> <?php if ($_REQUEST['action'] == 'create') { create_review($_REQUEST['id']); } ?> </div> --- On the another page, I have the following bit: function create_review($id) { $club_id = array('A' => 1, 'B' => 2, 'C' => 3, 'D' => 4, 'E' => 5, 'F' => 6, 'G' => 7, 'H' => 9, 'I' => 10, 'J' => 11, 'K' => 12); $sql = "INSERT INTO Review (booking_id, contact_id, start_date, pause_date, finish_date, stage, client_info) VALUES "; $sql .= " (" . $id . ", " . $_SESSION['contact_id'] . ", CURDATE(), NULL, NULL, 0, '" . mysql_real_escape_string($_SERVER['HTTP_USER_AGENT']) . "')"; $result = mysql_query($sql) or die(mysql_error()); $sql = "SELECT activity FROM Activities WHERE booking_id = " . $id . " AND activity IN ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l')"; $result = mysql_query($sql) or die(mysql_error()); //this is where i think not working if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)) { $sql = "INSERT INTO Club_Review (booking_id, club_id) VALUES (" . $id . ", " . $club_id[strtoupper($row['activity'])] . ")"; $result = mysql_query($sql) or die(mysql_error()); } } $sql = "INSERT INTO Review_Response (booking_id) VALUES (" . $id . ")"; $result = mysql_query($sql) or die(mysql_error()); } ---- The problem i have is when a client has booked more than one clubs, the program will only INSERT a random club into Club_Review instead of all the clubs the client has booked. I was wondering if someone can help me on this please. I must admit I am a PHP newbie. Regards,
  4. Here it is, function create_review($id) { $club_id = array('CLASS1' => 1, 'CLASSB' => 2, 'CLASSTOP' => 3); $sql = "INSERT INTO Review (booking_id, contact_id) VALUES "; $sql .= " (" . $id . ", " . $_SESSION['contact_id'] . " . mysql_real_escape_string($_SERVER['HTTP_USER_AGENT']) . "')"; $result = mysql_query($sql) or die(mysql_error()); $sql = "SELECT activity FROM Booked_Activities WHERE booking_id = " . $id . " AND activity IN ('CLASS1', 'CLASSB', 'CLASSTOP')"; $result = mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($result) > 0) { //this is the bit that's not working while ($row = mysql_fetch_assoc($result)) { $sql = "INSERT INTO Club_Review (booking_id, club_id) VALUES (" . $id . ", " . $club_id[strtoupper($row['activity'])] . ")"; $result = mysql_query($sql) or die(mysql_error()); } } $sql = "INSERT INTO Review_Response (booking_id) VALUES (" . $id . ")"; $result = mysql_query($sql) or die(mysql_error()); }
  5. tta013

    Insert into

    Hello there, I am a new bie here... I was wondering how I could transfer the data from one table to another. I tried with the following but giving me an error message. Was wondering what I did wrong. SELECT * FROM `tbl_temp` WHERE 1 INSERT INTO `tbl_temp` ( `booking_id`, `club_id` ) SELECT 'Booking' ('booking_id`,'club_id`) FROM 'Booking' Thanks,
  6. HI there, Sorry, I tried as you suggested but it is not evening inserting booking Id and club_id into the activity review anymore. Previously it was adding one record.... I was wondering what is not clicking in the process...
  7. This didn't work I am afraid. The data is no longer appending to the activity_respond table..
  8. Dear all, I have the follwoing code: $club_id = array('CLASS1' => 1, 'CLASS2' => 2, 'CLASS3' => 3); $sql = "SELECT activity FROM Activities WHERE booking_id = " . $id . " AND activity IN ('class1', 'class2', 'class3')"; $result = mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)) { $sql = "INSERT INTO Activity_Review (booking_id, club_id) VALUES (" . $id . ", " . $club_id[$row['activity']] . ")"; $result = mysql_query($sql) or die(mysql_error()); } } $sql = "INSERT INTO Activity_Response (booking_id) VALUES (" . $id . ")"; $result = mysql_query($sql) or die(mysql_error()); } } ---- For some reasons, the code will only insert to activity_review only one row even if there is more than one row. Can someone give me an advise as to what might be the problem is? Regards,
×
×
  • 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.