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,