Jump to content

156418

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

156418's Achievements

Member

Member (2/5)

0

Reputation

  1. Never mind, solved it by GROUP BY now. Many thanks for all the help, this was a system I've taken over the administration of, at least after this event i'll have the time to scrap this Database and start with a new one taking out all the multiple tables which have made it confusing!
  2. Thanks for the help, I've got it working as I want, just have one problem. I had to change the query slightly as the date is in the database as text rather than in Date Format. However the problem is that each record which is returned is displayed 3 times [code]<?php require('db_connect.php'); ?> <?php $query = "select Callbacks.* from Callbacks,TicketsSold where Callbacks.cartId = TicketsSold.OrderID and MC_EventDate in ('Saturday 9th December')"; $results = mysql_query($query) or die(mysql_error()); ?> </head> <body> <p>Attendance List: Saturday 9th December 2006</p> <p> <?php while ($row = mysql_fetch_array($results)) {   extract($row);   echo "Callback Number: $CallbackNo <br>";   echo "Customer Name: $customername <br>";   echo "Customer Address: $customeraddress <br>";   echo "Ticket Details: $M_disc <br>"; } ?>[/code] Any ideas as to what I've done wrong?
  3. Hi, I think there's probably an easy way to do this, but its got me a little confused. I would like to Run a query, which selects two tables, Callbacks and TicketsSold. Then I'd like to display the contents of Callbacks, where the cartID = cartID in TicketsSold, and where MC_EventDate equals either: Saturday 9th December Sunday 10th December Saturday 16th December Sunday 17th December Saturday 23rd December. I will have 5 seperate pages, so I can hard code the date into the query, but am struggling on how to put the query togther to get the necessary results. Do I need to run seperate queries on the tables then merge them somehow? I have PHP version  4.4.2 and MySQL version 4.1.21-standard if that makes a difference Many thanks for any pointers.
  4. Hmmm thanks, thats annoying, as thats something that Worldpay spit out as one of their defined colums. Sorted it now by sending them an additional field which is put into DB. Everything working ok. Thanks for all the help
  5. Thanks, I've removed that but still got the same error  ???
  6. I'm trying to run the following query: [code]<?php // sort out the input $cartId = $_POST['cartId']; $description = $_POST['desc']; $totalamount = $_POST['amount']; $transactioncurrency = $_POST['currency']; $customername = $_POST['name']; $customeraddress = $_POST['address']; $postcode = $_POST['postcode']; $country = $_POST['country']; $tel = $_POST['tel']; $email = $_POST['email']; $transId = $_POST['transId']; $transStatus = $_POST['transStatus']; $transTime = $_POST['transTime']; $authAmount = $_POST['authAmount']; $authCurrency = $_POST['authCurrency']; $rawAuthMessage = $_POST['rawAuthMessage']; $rawAuthCode = $_POST['rawAuthCode']; $cardType = $_POST['cardType']; $AVS = $_POST['AVS']; //1) Now dump the lot into the DB   $query = "INSERT INTO Callbacks (             cartId, desc, amount, currency, name, address, postcode, country, tel, email, transId, transStatus, transTime, authAmount, authCurrency, rawAuthMessage, rawAuthCode, cardType, AVS)             VALUES (             '$cartId',             '$description',             '$totalamount',             '$transactioncurrency',             '$customername',             '$customeraddress',             '$postcode',             '$country',             '$countryString',             '$tel',             '$email',             '$transId', '$transStatus', '$transTime', '$authAmount', '$authCurrency', '$rawAuthMessage', '$rawAuthCode', '$cardType',             '$AVS')"; echo $query. "<br/>"; $insert = mysql_query($query) or die("Error ". mysql_error(). " with query ". $query); ?> [/code] When the query runs, the echo is showing that all the data is there to be put in, but I'm getting the error. [quote]Error 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 'desc, amount, currency, name, address, postcode, country, countryString, tel, em' at line 2 with query INSERT INTO Callbacks etc[/quote] Knowing my typing, its probably a typo somewhere, but I can't spot it! Any help greatly received
  7. Thanks Barand your a genius! that works excellently, also thanks to craygo for your input
  8. Thanks Barand, that looks nice and simple, but I'm getting an error "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 'WHERE EventID = '21'' at line 2" This is my query: All of the fields are correct: [code]<?php $event = mysql_real_escape_string(trim(stripslashes($_POST['event']))); $query = "SELECT EventID, TicketType, SUM(Qty) as total FROM TicketsSold GROUP BY EventID, TicketType  WHERE EventID = '$event'"; $results = mysql_query($query) or die(mysql_error()); ?>[/code]
  9. I have a table in my database called TicketsSold. in that I have thefFields: Refrence, OrderID, EventID, TicketType and Qty I can put together a query no problem which can list the tickets sold for a certain event. i.e [code]<?php $event = mysql_real_escape_string(trim(stripslashes($_POST['event']))); $query = "SELECT * FROM TicketsSold WHERE EventID = '$event'"; $results = mysql_query($query) or die(mysql_error()); ?>[/code] But, is there a way that I can instead of listing eveything, total up everything into groups. For example have it list by EventID then total the amount sold in each ticket type, Adult, Child, Senior, Family and Present. Many thanks for any help. (if this would be better in the MySQL Forum then sorry, as I was unaware what it would come under)
  10. Thanks, I can see the logic that it would implement, but (forgive the ignorance!) where do I place that code, as whereever it goes on my page, or next page it ignores it - I have changed the name to match that of the input with no sucess. I should also have said that if they enter anything other than a number in the box it should redirect them to an error page.
  11. I have a basic table/form which is passing the various inputs onto the next stage, what I want to do is where the Quantity box is only allow the use to enter a number, and reject on blank or anything else. Could someone show an easy way to do that, all the validation scripts I've found seem rather complicated or prevent the input being sent in the headers. Many thanks [code]<table width="70%" border="0">   <tr>     <td width="13%" bgcolor="#E6D0DD">Quantity</td>     <td width="74%" bgcolor="#E6D0DD">Ticket Type </td>     <td width="13%" bgcolor="#E6D0DD">Price</td>   </tr>   <tr>     <td bgcolor="#E6D0D2"><div align="center">       <input name="AdultQuantity" type="text" value="0" size="5">     </div></td>     <td bgcolor="#E6D0D2">Adult     <input type="hidden" name="ATicketType" value="Adult" size="13" maxlength="20"></td>     <td bgcolor="#E6D0D2">&pound;9       <input type="hidden" name="APrice" value="9" size="10" maxlength="1"> </td>   </tr>   <tr>     <td bgcolor="#E6D0D2"><div align="center">       <input name="ChildQuantity" type="text" value="0" size="5">     </div></td>     <td bgcolor="#E6D0D2">Child       <input type="hidden" name="CTicketType" value="Child" size="13" maxlength="20"> </td>     <td bgcolor="#E6D0D2">&pound;6       <input type="hidden" name="CPrice" value="6" size="10" maxlength="1"> </td>   </tr>   <tr>     <td bgcolor="#E6D0D2"><div align="center">       <input name="PresentQuantity" type="text" value="0" size="5">     </div></td>     <td bgcolor="#E6D0D2">Present       <input type="hidden" name="PTicketType" value="Present" size="13" maxlength="20"> </td>     <td bgcolor="#E6D0D2">&pound;3       <input type="hidden" name="PPrice" value="3" size="10" maxlength="1"></p> </td>   </tr> </table> [/code]
  12. Hi, its similar to a shopping cart but not quite! It takes a Quantity and simply posts it to the next page, also there's some hidden text boxes which post the amount for each item (I know thats cheating, but I cant find any other way easily! This is the page prior to that one, which posts the Quantity and price through [code]<form method="POST" action="Stage6-Final.php"> <table width="70%" border="0">   <tr>     <td width="13%" bgcolor="#E6D0DD">Quantity</td>     <td width="74%" bgcolor="#E6D0DD">Ticket Type </td>     <td width="13%" bgcolor="#E6D0DD">Price</td>   </tr>   <tr>     <td bgcolor="#E6D0D2"><div align="center">       <input name="AdultQuantity" type="text" value="0" size="5">     </div></td>     <td bgcolor="#E6D0D2">Adult     <input type="hidden" name="ATicketType" value="Adult" size="13" maxlength="20"></td>     <td bgcolor="#E6D0D2">&pound;9       <input type="hidden" name="APrice" value="9" size="10" maxlength="1"> </td>   </tr>   <tr>     <td bgcolor="#E6D0D2"><div align="center">       <input name="ChildQuantity" type="text" value="0" size="5">     </div></td>     <td bgcolor="#E6D0D2">Child       <input type="hidden" name="CTicketType" value="Child" size="13" maxlength="20"> </td>     <td bgcolor="#E6D0D2">&pound;6       <input type="hidden" name="CPrice" value="6" size="10" maxlength="1"> </td>   </tr>   <tr>     <td bgcolor="#E6D0D2"><div align="center">       <input name="PresentQuantity" type="text" value="0" size="5">     </div></td>     <td bgcolor="#E6D0D2">Present       <input type="hidden" name="PTicketType" value="Present" size="13" maxlength="20"> </td>     <td bgcolor="#E6D0D2">&pound;3       <input type="hidden" name="PPrice" value="3" size="10" maxlength="1"></p> </td>   </tr> </table> </form>[/code] It also posts some other stuff, user details etc which is being pulled from the Database. On the page that recieves it, I have the following: [code]Tickets: </div>            </td>             <td width="79%"><span class="style11"><?php echo $_POST['AdultQuantity']; ?> X <?php echo $_POST['ATicketType']; ?> @ £<?php echo $_POST['APrice']; ?> Each  <input type="input" name="AT" value="<?php echo $_POST['AdultQuantity'] * $_POST['APrice']; ?>" size="13" maxlength="20"><br>   <?php echo $_POST['ChildQuantity']; ?> X <?php echo $_POST['CTicketType']; ?> @ £<?php echo $_POST['CPrice']; ?> Each<input type="input" name="CT" value="<?php echo $_POST['ChildQuantity'] * $_POST['CPrice']; ?>" size="13" maxlength="20"><br>   <?php echo $_POST['PresentQuantity']; ?> X <?php echo $_POST['PTicketType']; ?> @ £<?php echo $_POST['PPrice']; ?> Each<input type="input" name="PT" value="<?php echo $_POST['PresentQuantity'] * $_POST['PPrice']; ?>" size="13" maxlength="20"><br></span></td>           </tr>           <tr>             <td width="21%">               <div align="right" class="style11 style12 style14">Total to Pay:  </div>            </td>             <td width="79%"><span class="style11 style12 style14"><?php echo $_POST['AT'] * $_POST['PT']; ?></span></td>           </tr>[/code] Thats a cut down of it, the rest is just posting the rest of what was sent from the page before. There's a lot of multiple posting of the same variables here as well. No doubt there's a quicker way to do it all, adding and pulling back out from a DB, but I dunno where to begin on making that!
  13. Ah, I see. Would I be right in assuming that I wont be able to add the three totals together without first posting the results?
  14. Thanks, It looks simple enough, but how do i get it to display the output rather than the command [code]<?php echo $_POST['$AdultQuantity * $APrice']; ?>[/code]
  15. I have the following code, which is posted through from a form on a previous page: [code]<?php echo $_POST['AdultQuantity']; ?> X <?php echo $_POST['ATicketType']; ?> @ £<?php echo $_POST['APrice']; ?> Each<br> <?php echo $_POST['ChildQuantity']; ?> X <?php echo $_POST['CTicketType']; ?> @ £<?php echo $_POST['CPrice']; ?> Each<br> <?php echo $_POST['PresentQuantity']; ?> X <?php echo $_POST['PTicketType']; ?> @ £<?php echo $_POST['PPrice']; ?>[/code] what I'd like to do is multiple the Quantity by the Price for each of the three, and then total all three together in another part on the page Is that possible, or will I need to add it into the Database and pull the figures back out?
×
×
  • 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.