Jump to content

BarneyJoe

Members
  • Posts

    103
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

BarneyJoe's Achievements

Member

Member (2/5)

0

Reputation

  1. I have a page here, that uses a bit of PHP to loop a series of checkboxes. I've posted a screenshot here: http://www.handprintwebdesign.co.uk/gsg_checkboxes/ I have the stripes working, but not the rules for the checkboxes so that they don't appear with a border in IE. So I have a couple of rules in my CSS: .tickbox_odd { border: 0; background-color:#006; } .tickbox_even { border: 0; background-color: #990000; } And at the moment, the code I have looks like: (the line in bold is the key line) while ($keyword=mysql_fetch_assoc($query)) { //If new category close previous row & display new category if ($keyword['Category']!=$current_category) { if ($current_category && $column !=1 ) { echo "</tr>\n"; } $current_category = $keyword['Category']; echo "<tr class=\"categorycell\"><td colspan=\"10\">$current_category</td></tr>\n"; $column = 1; $row_type=""; } //Create new row if 1st keyword if ($column == 1) { $row_type = ($row_type=="odd")?"even":"odd"; echo "<tr class=\"".$row_type."\">"; } //Display the checkbox echo "<td width=\"2%\">"; echo "<input type=\"checkbox\" class=\"tickbox_".$row_type."\""; if (in_array($keyword['ActivityID'],$photokeywords)) { echo " checked"; } echo " name=\"ckbox[".$keyword['ActivityID']."]\" id=\"ckbox[".$keyword['ActivityID']."]\">"; echo "</td>\n"; //Display the Keyword echo "<td width=\"18%\" align=\"left\">".$keyword['Activity']."</td>\n"; //Close the row if 5th keyword OR increase column count if ($column == 4) { echo "</tr>"; $column = 1; } else { $column++; } } if ($column != 1) { echo "</tr>"; } But that isn't working - any help with this would be appreciated, just to get this detail tidied up. Thank you.
  2. Thanks guys - that all looks like its working OK now.
  3. This is only really of any help if you have access top Dreamweaver, as its an extension - but looks like the sort of thing you're after... http://www.tom-muck.com/extensions/help/HorizontalVerticalLooperHelp/index.cfm
  4. Thank you - that's all pretty much working now, the session variable is echoing on each page so I know is all OK. The only thing that isn't working, is getting the package ID inserted into my packagefeatures interlinking table. At the moment I have this code that works as it should to display the features along with checkboxes as an array : <code> <p>Package ID : <?php echo $_SESSION['package_ID'];?></p> <table width="100%" border="0" cellpadding="0" cellspacing="0" align="center"> <form name="form1" id="form1" method="GET" action="package_added3.php"> <input type='hidden' name='package_ID' value='<?php echo $package_ID; ?>'> <?php require_once('../Connections/connPackages.php'); error_reporting(E_ALL & E_STRICT); $package_ID = 1; if (isset($_GET['package_ID'])) { $package_ID = intval($_GET['package_ID']); } //Get destinations & put into array mysql_select_db($database_connPackages, $connPackages); $query_Keyword_Match = sprintf("SELECT * FROM packagefeatures WHERE packageID = %s", $package_ID); $Keyword_Match = mysql_query($query_Keyword_Match, $connPackages) or die(mysql_error()); $packagefeatures = array(); while ($row_Keyword_Match = mysql_fetch_assoc($Keyword_Match)) { $packagefeatures[] = $row_Keyword_Match['feature_ID']; } //Get all the keywords $sql = "SELECT * FROM features ORDER BY feature"; $query = mysql_query($sql); $current_category = ""; $row_type = ""; $column = 1; while ($keyword=mysql_fetch_assoc($query)) { //If new category close previous row & display new category if ($keyword['Category']!=$current_category) { if ($current_category && $column !=1 ) { echo "</tr>\n"; } $current_category = $keyword['Category']; echo "<tr class=\"categorycell\"><td colspan=\"10\">$current_category</td></tr>\n"; $column = 1; $row_type=""; } //Create new row if 1st keyword if ($column == 1) { $row_type = ($row_type=="odd")?"even":"odd"; echo "<tr class=\"".$row_type."\">"; } //Display the checkbox echo "<td width=\"2%\">"; echo "<input type=\"checkbox\" class=\"tickbox_".$row_type."\""; if (in_array($keyword['feature_ID'],$photokeywords)) { echo " checked"; } echo " name=\"ckbox[".$keyword['feature_ID']."]\" id=\"ckbox[".$keyword['feature_ID']."]\">"; echo "</td>\n"; //Display the Keyword echo "<td width=\"18%\" align=\"left\">".$keyword['feature']."</td>\n"; //Close the row if 5th keyword OR increase column count if ($column == 4) { echo "</tr>"; $column = 1; } else { $column++; } } if ($column != 1) { echo "</tr>"; } ?> <tr> <td> </td> </tr> <tr> <td colspan="2"> <tr> <td colspan="2"> <input type="submit" name="Submit" value="FINISH"> <INPUT type=button value="Cancel"> </form></td> </tr> </table> </code> And on the next page, using this to insert the two IDs : <code> /******************** * *insert Package Features into PackageFeatures table table * ********************/ //sql insert string $sql = "INSERT INTO packagefeatures (packageID, featureID) VALUES "; $ck = $_GET['ckbox']; //loops though the profiles adding the the insert string each profile row foreach ($ck As $GetIndex => $GetValue){ if ($GetValue=='on'){ $sql .= "('{$_GET['package_ID']}', '$GetIndex'), "; } } //trims the end , $sql = rtrim($sql," ,") ; //inserts data mysql_select_db($database_connPackages, $connPackages); mysql_query($sql); echo mysql_error(); </code> But its only inserting the featureID, and 0's for each packageID....
  5. OK, so I've added that to the addDestinations page, so its : <code> /******************** * *Retrieve package_ID * ********************/ $package_ID = mysql_insert_id (); /******************** * *Store package_ID in session * ********************/ $_SESSION['package_ID'] = $package_ID; </code> What's the syntax to pick it up in the next page? Something like : $_GET['package_ID']; or $_GET[session=package_ID]; ?
  6. Not sure why, but this is something I always have a mental block with - what form would the syntax take for that? For example, as a session?
  7. Hope someone can help with this.... I have a database structure along the lines of : 1. A main table of holiday packages. 2. A table of destinations that form a many to many link with the Packages table. 3. A table of feature types (eg museums, theme parks) that form another many to many link with the Packages table. First I have a page addPackage.php. This goes onto addPackageDestinations.php, which inserts the data entered in the addPackage page, and grabs the package_ID of that new record : <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } /******************** * *insert Package details into db * ********************/ //sql string $insertSQL = sprintf("INSERT INTO packages (package, costperpax, duration, baselocation, category, agerange, hotel, educational_tours, field_trips, corporate_outings, plant_visits, budget_package, themepark, museum, rollingtours, seminars, historicsite, teambuilding, zoo, park, church, naturalbeauty, relaxation, beach, city, wildlife, international, mallshopping, description) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['package'], "text"), GetSQLValueString($_POST['costperpax'], "text"), GetSQLValueString($_POST['duration'], "date"), GetSQLValueString($_POST['baselocation'], "text"), GetSQLValueString($_POST['category'], "text"), GetSQLValueString($_POST['agerange'], "text"), GetSQLValueString($_POST['hotel'], "text"), GetSQLValueString($_POST['educational_tours'], "text"), GetSQLValueString($_POST['field_trips'], "text"), GetSQLValueString($_POST['corporate_outings'], "text"), GetSQLValueString($_POST['plant_visits'], "text"), GetSQLValueString($_POST['budget_package'], "text"), GetSQLValueString($_POST['themepark'], "text"), GetSQLValueString($_POST['museum'], "date"), GetSQLValueString($_POST['rollingtours'], "text"), GetSQLValueString($_POST['seminars'], "text"), GetSQLValueString($_POST['historicsite'], "text"), GetSQLValueString($_POST['teambuilding'], "text"), GetSQLValueString($_POST['zoo'], "text"), GetSQLValueString($_POST['park'], "text"), GetSQLValueString($_POST['church'], "text"), GetSQLValueString($_POST['naturalbeauty'], "text"), GetSQLValueString($_POST['relaxation'], "text"), GetSQLValueString($_POST['beach'], "text"), GetSQLValueString($_POST['city'], "text"), GetSQLValueString($_POST['wildlife'], "text"), GetSQLValueString($_POST['international'], "text"), GetSQLValueString($_POST['mallshopping'], "text"), GetSQLValueString($_POST['description'], "text")); //insert $Result1 = mysql_select_db($database_connPackages, $connPackages); mysql_query($insertSQL); echo mysql_error(); /******************** * *Retrieve package_ID * ********************/ $package_ID = mysql_insert_id (); ?> So far, so good. I then go onto an addPackageFeatures.php page, which inserts the package destinations like so : <?php /******************** * *insert Package Destinations into PackageDestinations table table * ********************/ //sql insert string $sql = "INSERT INTO packagedestinations (packageID, destinationID) VALUES "; $ck = $_GET['ckbox']; //loops though the profiles adding the the insert string each profile row foreach ($ck As $GetIndex => $GetValue){ if ($GetValue=='on'){ $sql .= "('{$_GET['package_ID']}', '$GetIndex'), "; } } //trims the end , $sql = rtrim($sql," ,") ; //inserts data mysql_select_db($database_connPackages, $connPackages); mysql_query($sql); echo mysql_error(); ?> So all I need on this page is the same package_ID for the new package being created, to be passed from the addPackageDestinations page onto the addPackageFeatures page. Not sure how well I've explained it but hopefully it makes sense...? Thanks.
  8. Hope someone can help with this, as I'm still a bit new to this. Basically have one table Orders, and another OrderDetails. Have a page that lists Orders (simply based on the Orders table), and the user can click through to view the OrderDetails using the code : <a href="orderdetails.php?ID=<?php echo $row_rsOrders['OrderID']; ?>"><?php echo $row_rsOrders['VendorTxCode']; ?></a> Which works fine. However, I want to show on the Details page a couple of fields from the Orders Table - ie OrderTotal and VendorTxCode. My query at the moment looks like : SELECT * FROM Orders, OrderDetails WHERE Orders.OrderID = OrderDetails.DetailOrderID But think I need to use a JOIN (INNER) so that it knows which record to use based on the current OrderID, as the above is showing the values from the first record in the Orders table. If anyone can help out with the syntax, that would be much appreciated.
  9. Got this working finally - think it might have been because the code updating the database was before the code that unpacked the encrypted fields back from the payment processor.
  10. Have been having a rummage, and think it was to do with a session needing to be unset - otherwise it was overwriting. Have at least confirmed it doesn't do this if the browser is closed and re-opened - so it looks like I just need to unset the session and it'll be fine.
  11. Have noticed that in fact it's overwriting the first record each time. Also posted on web assist's forum, who mentioned that it's only supposed to hold one order at a time. Not sure what's going on, as it was before.... I'll see if I can find out more from the web assist (DW externsions) guys.
  12. Although I did have a typo in the second part - should have been : mysql_select_db($database_connOriental, $connOriental); $Result1 = mysql_query($updateSQL, $connOriental) or die(mysql_error()); } if ("" == "") { $updateSQL = sprintf("UPDATE Orders SET OrderStatus=%s, VendorTxCode=%s WHERE OrderID=%s" GetSQLValueString("Accepted", "text"), GetSQLValueString($_POST['VendorTxCode'], "text"), GetSQLValueString($_SESSION['OrderNumber'], "int")); //die($updateSQL); mysql_select_db($database_connOriental, $connOriental); $Result1 = mysql_query($updateSQL, $connOriental) or die(mysql_error()); }
  13. I thought that was the code. What's the real code? ???
×
×
  • 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.