Jump to content

stualk

Members
  • Posts

    109
  • Joined

  • Last visited

    Never

Everything posted by stualk

  1. Hello mate, Long time, no speak. Hope you're well. Thanks for the URL. I'm taking a look now. I'm 75% there with this and, while I've always been ok reading files from folders in php, reading folders and sub folder that are randomly added to the hosting space isn't something I've ever done before. Will let you know how I get on.
  2. Hi folks, Working on something and I'm not sure how best to do it. It's a system whereby customers can login and see pdf files. Each customer has a unique reference number which is mirrored with a folder on the server, the folder name being the customer reference number. That's the first bit of checking. Then, within that customer folder there will be between 1 and X sub folders which are labelled by unique product reference numbers. Beyond that, each of the product reference folders will have a year folder with a folder for each month of the year going forward. Here's an example of the folder structure: - Customer Number (e.g. 12345678) - Product Number (e.g. 456789) (could be more than one) - Year (e.g. 2011) (could be more than one) -Month (e.g. 01/02/03/04/05/06 etc) Essentially, I'm just unsure how to check if folders exist and display their contents if they do. Here's my code so far, which does the first part of checking to see if the product numbers exist, but not the folder checking (I've not activated the hyperlinks in this code yet). This doesn't go as far as years and months yet, just the product number: $query = mysql_query("SELECT * FROM customers where id = '$id'"); while($rst = mysql_fetch_array($query)) { echo "$rst[company_name]"; } $query = mysql_query("SELECT * FROM sites where company_name = '$company'"); while($rst = mysql_fetch_array($query)) { echo "$rst[site]<br>"; if ($rst[product1] !== ""){ echo "- <a href='#'>$rst[product1]</a><br>"; } if ($rst[product1] == ""){ echo ""; } if ($rst[product2] !== ""){ echo "- <a href='#'>$rst[product2]</a><br>"; } if ($rst[product2] == ""){ echo ""; } if ($rst[product3] !== ""){ echo "- <a href='#'>$rst[product3]</a><br>"; } if ($rst[product3] == ""){ echo ""; } if ($rst[product4] !== ""){ echo "- <a href='#'>$rst[product4]</a><br>"; } if ($rst[product4] == ""){ echo ""; } if ($rst[product5] !== ""){ echo "- <a href='#'>$rst[product5]</a><br>"; } if ($rst[product5] == ""){ echo ""; }
  3. Just wanted to say thanks for all the great tips on this. Grouping the 'OR' items within brackets solved the issue with the incorrect search results. Now I get results which are 100% accurate. Later I'll be looking at mysql_real_escape_string to make it better still but ultimately the search is now working perfectly, so thanks to all for your help.
  4. Thanks for this. Some useful info and advice there. Always good to get a second opinion on the method etc, especially considering you spotted that bedrooms was in there twice and I didn't! (Although removing it hasn't altered the search results) I'll try to post back to let you know how I got on using your method. Thanks again for the assistance.
  5. Hello folks, I've got a problem with a search script. It's searching a db containing various properties (as in buildings) and it's not quite returning the correct results. The search form asks that you select a house type (4 options, all of which are tick boxes) and then the last part of the form is select how many bedrooms you'd like (which is a drop-down list featuring numbers 2-5) What should happen is someone selects one or more of the tick boxes and then the number of bedrooms and it returns all the house types that were ticked but only those with the number of bedrooms that were specified in the original search. Currently the results are correct in that they're showing the correct house types, but the number of bedrooms isn't right. e.g. if you chose 2 bedrooms in the search it shows those, as well as 3, 4 and 5 bedrooms in the results. Can't figure it out but it will be something to do with && and OR in my search script. Can anyone suggest a tweak to this that might work? (I'm using the $_GET function because the search form is in a Flash movie) $Result = mysql_query("select * from property_names where TownHouse = '$_GET[TownHouse]' OR Apartment = '$_GET[Apartment]' OR Detached = '$_GET[Detached]' OR SemiDetached = '$_GET[semiDetached]' && visible= 'Yes' && bedrooms = '$_GET[bedrooms]' && bedrooms = '$_GET[bedrooms]'")
  6. Great advice Lee. Much appreciated. I had to adjust it slightly to work how I wanted it to but the theory behind it was spot on so many thanks. Here's the final code that I arrived at: <ul id='MenuBar2' class='MenuBarHorizontal'> <?php $NumRows=mysql_query("select DISTINCT section,sub_section from products where visible = 'Yes'"); $NumRows=mysql_num_rows($NumRows); $Result = mysql_query("select DISTINCT section,sub_section from products where visible = 'Yes'") or die("Error 1"); $i=1; while($row = mysql_fetch_array($Result)) { $sections[$row[section]][] = $row[sub_section]; } echo ""; foreach ($sections as $section => $subsections) { echo "<li><a class='MenuBarItemSubmenu' href='#'>$section</a><ul>"; foreach ($subsections as $sub_section) { echo "<li><a class='MenuBarItemSubmenu' href='products_second.php?section=$sub_section'>$sub_section</a></li>"; } echo "</ul>"; } ?></li></ul>
  7. Hi folks, I've got a spry/drop-down menu on my website but it's not quite working how I want it to. In the db table are a range of products that fall into certain categories and then sub-categories. Here's a small selection of items in the table as an example: SECTIONSUB SECTION BedsSingle Beds BedsDouble Beds BedsKing Size Beds The way the spry/drop-down menu is meant to work is that it selects a unique/distinct value from the 'section' column and this becomes a drop-down link. Then, it displays all the sub sections specific to that section beneath in the drop-down, like this: Beds - Single Beds - Double Beds - King Size Beds At the minute it's doing this, one beside another: Beds - Single Beds Beds - Double Beds etc I'm almost there but how can I group them all into one 'beds' drop-down? A foreach loop perhaps? Here's my code: <ul id='MenuBar2' class='MenuBarHorizontal'> <?php $NumRows=mysql_query("select DISTINCT section,sub_section from products where visible = 'Yes'"); $NumRows=mysql_num_rows($NumRows); $Result = mysql_query("select DISTINCT section,sub_section from products where visible = 'Yes'") or die("Error 1"); $i=1; while($row = mysql_fetch_array($Result)){ echo "<li><b><a class='MenuBarItemSubmenu' href='products.php'>$row[section]</a></b><ul> <li><a href='products_second.php?section=$row[sub_section]'><b><i>$row[sub_section]</i></b></a>"; echo "</li></ul>"; } ?> </li> </ul>
  8. That's fine, cheers. This is almost working how I want it to. However, using the code above it displays the products like this: Ideally I want it to display like this: How can I best achieve this? Please don't say it's an array as I can never get my head around them!!
  9. Thanks - I'm not certain. Take a look at the code I've been using. I've already created the table, it's just displaying the results i'm having difficulty with: require ('database.php'); $query2 = mysql_query("select DISTINCT fabric from TABLE where product = '$product'"); while($rst = mysql_fetch_array($query2)) { echo(" <tr> <td class='body'> <b>$rst[fabric]</b><br>Available in: $rst[colour] </td> </tr> "); }
  10. I'm trying to work out how best to display products from a db but i'm having difficulty with my select statement. Here's an example of part of the db: id product fabric colour 1 square leather cream 2 square leather black 3 square leather white 4 square suede cream 5 round leather black 6 round leather white 7 round suede cream 8 round suede white What I want to do is for someone to be able to view the page containing the square products, the select statement then calls out the first fabric option (leather) and then displays the colour options beneath, like this Square products: Leather Available in: cream | black | white Suede Available in: cream Am I going to need an array here or is there an easier way to do this?
  11. Cheers - that's not a million miles from what i'm doing now, it's just that my current method involves sending other variables with the URL other than just '?id=x' at the end. What's the best way to update the values of id=x without adding them to the URL? Is there some sort of update function available for this?
  12. Hi guys, My first post on here in ages! I'm looking for some advice on form submission. The method i've been using for some time now is starting to cause me problems on one form in particular. I'll try my best to explain: Someone submits an enquiry on an item listed on a website. Their enquiry includes their contact info such as name, address, telephone, email etc. That goes into a db. The administrator is notified of this and adds costings to the enquiry, which then sends the customer an email asking them to confirm their acceptance. The email contains a simple 'CLICK HERE' which takes them to a form showing all the details they originally submitted along with the info the administrator has added. They can change any of the details they originally submitted as well as adding a purchase order number. When they click the submit button this is where the problems are occuring. I'm using the URL to send the info from EVERY editable field on the confirmation form and it seems as though it's too much for the URL to handle because I'm getting reports of the form 'freezing' and 'doing nothing' and 'going to just a blank white page' Is there some other way I can submit the edited info to the db to avoid this? I'm no expert, as you can probably tell (!), so any advice I would very much welcome.
  13. Hi there, I want to create a system where I can upload Excel files in xls format to my web server so that I can access them wherever I am and view/edit them? I've done this bit so far and everything is fine. I'm having a problem with the second part of my system - I need other people to be able to VIEW these Excel files (only view, not edit) ideally as part of a web page rather than having to open the excel file in Excel. Some of my spreadsheets contain links to other spreadsheets/worksheets within some of the cells so ideally it needs to display this formatting as well if at all possible. Does anyone know of a way to do this using php? Basically, it's the displaying of the excel documents i'm having difficulty with. I've done/know how to do the rest.
  14. Ok, using the following code returns nothing: $TOTALS = array($TOTAL_REDUCED_1, $TOTAL_REDUCED_2, $TOTAL_REDUCED_3, $TOTAL_REDUCED_4, $TOTAL_REDUCED_5, $TOTAL_REDUCED_6); for($i=0; $i<count($TOTALS[0]); $i++) { echo($TOTALS[0][$i]); } What effect would the positioning of these } have on it? I can only think that i've got them in the wrong place as it's not actually displaying anything. What do you think?
  15. Here's my full code for StepOne. I've commented some of it to help you understand what does what as there's an awful lot of code here! This code works perfectly for what I want it to do. There's probably a quicker way of doing it but I did it this way because I knew how to, that's all. // ========================================================================== if ($Step == "StepOne") { // ========= list of sections =============================================== require ('database.php'); // work out todays date $today = getdate(); $mon = $today['month']; $day = $today['weekday']; $dayn = $today['mday']; $year = $today['year']; if ($dayn == 1) { $dayn = "0$dayn"; } elseif ($dayn == 2) { $dayn = "0$dayn"; } elseif ($dayn == 3) { $dayn = "0$dayn"; } elseif ($dayn == 4) { $dayn = "0$dayn"; } elseif ($dayn == 5) { $dayn = "0$dayn"; } elseif ($dayn == 6) { $dayn = "0$dayn"; } elseif ($dayn == 7) { $dayn = "0$dayn"; } elseif ($dayn == { $dayn = "0$dayn"; } elseif ($dayn == 9) { $dayn = "0$dayn"; } // convert month into a code number for storage in database for sorting purposes switch ($mon) { case "January": $monthcode = '01'; break; case "February": $monthcode = '02'; break; case "March": $monthcode = '03'; break; case "April": $monthcode = '04'; break; case "May": $monthcode = '05'; break; case "June": $monthcode = '06'; break; case "July": $monthcode = '07'; break; case "August": $monthcode = '08'; break; case "September": $monthcode = '09'; break; case "October": $monthcode = '10'; break; case "November": $monthcode = '11'; break; default: $monthcode = '12'; break; } // select details of customers existing supply $NumRows=mysql_query("SELECT * FROM customers_existing where company_name = '$company_name'"); $NumRows=mysql_num_rows($NumRows); $Result = mysql_query("SELECT * FROM customers_existing where company_name = '$company_name'"); if (!$Result) die (mysql_error()); for ($i=1; $i<=$NumRows; $i++) { if ($row = mysql_fetch_array($Result)) { $id = $row["id"]; $existing_supplier = $row["existing_supplier"]; $isdn2_line_details = $row["isdn2_line_details"]; $isdn2_unit_rate = $row["isdn2_unit_rate"]; $isdn2_current_costs = $row["isdn2_current_costs"]; $isdn30_channels_line_details = $row["isdn30_channels_line_details"]; $isdn30_channels_unit_rate = $row["isdn30_channels_unit_rate"]; $isdn30_channels_current_costs = $row["isdn30_channels_current_costs"]; $analogue_lines_line_details = $row["analogue_lines_line_details"]; $analogue_lines_unit_rate = $row["analogue_lines_unit_rate"]; $analogue_lines_current_costs = $row["analogue_lines_current_costs"]; $local_line_details = $row["local_line_details"]; $local_unit_rate = $row["local_unit_rate"]; $local_current_costs = $row["local_current_costs"]; $national_line_details = $row["national_line_details"]; $national_unit_rate = $row["national_unit_rate"]; $national_current_costs = $row["national_current_costs"]; $vodafone_line_details = $row["vodafone_line_details"]; $vodafone_unit_rate = $row["vodafone_unit_rate"]; $vodafone_current_costs = $row["vodafone_current_costs"]; $orange_line_details = $row["orange_line_details"]; $orange_unit_rate = $row["orange_unit_rate"]; $orange_current_costs = $row["orange_current_costs"]; $tmobile_line_details = $row["tmobile_line_details"]; $tmobile_unit_rate = $row["tmobile_unit_rate"]; $tmobile_current_costs = $row["tmobile_current_costs"]; $o2_line_details = $row["o2_line_details"]; $o2_unit_rate = $row["o2_unit_rate"]; $o2_current_costs = $row["o2_current_costs"]; $international_line_details = $row["international_line_details"]; $international_unit_rate = $row["international_unit_rate"]; $international_current_costs = $row["international_current_costs"]; $other_line_details = $row["other_line_details"]; $other_unit_rate = $row["other_unit_rate"]; $other_current_costs = $row["other_current_costs"]; $total_current_costs = $row["total_current_costs"]; $total_current_costs = number_format($total_current_costs, 2); // display results from the above print(" <table width='95%' border='1' cellpadding='0' cellspacing='0' bordercolor='#FFFFFF'> <tr height='25'> <td bgcolor='#FF9900' width='25%'><strong><font size='2' face='Trebuchet MS'> Telecoms Tender</font></strong></td> <td bgcolor='#FF9900' width='25%'><font size='2' face='Trebuchet MS'><b>12 month offers</b></font></td> <td colspan='2' bgcolor='#FF9900' width='50%'><font size='2' face='Trebuchet MS'><strong>Offers Values</strong></font></td> </tr> </table> <br> <table width='95%' border='1' cellpadding='0' cellspacing='0' bordercolor='#FFFFFF'> <tr height='25'> <td bgcolor='#FF9900' width='50%'><strong><font size='2' face='Trebuchet MS'> Supplier</font></strong></td> <td align='right' bgcolor='#FF9900' width='25%'><font size='2' face='Trebuchet MS'><strong>Annual Cost - Lines & Calls</strong></font></td> <td align='right' bgcolor='#FF9900' width='25%'><font size='2' face='Trebuchet MS'><strong>Offer Date</strong></font></td> </tr> <tr height='25'> <td bgcolor='#FFCC99'><font size='2' face='Trebuchet MS'>Existing Suppliers: <b>$existing_supplier</b></font></td> <td bgcolor='#FFCC99'><div align='right'><font size='2' face='Trebuchet MS'><b>£$total_current_costs</b></font></div></td> <td align='right' bgcolor='#FFCC99'><font size='2' face='Trebuchet MS'><b>$dayn $mon $year</b></font></td> </tr> </table> <br> <table width='95%' border='1' cellpadding='0' cellspacing='0' bordercolor='#FFFFFF'> "); }} require ('database.php'); // select the six suppliers details from tq db $NumRows=mysql_query("select id from telequote_new") or die("Sorry Couldn't Complete Query_1a"); $NumRows=mysql_num_rows($NumRows); if ($NumRows == "0") { echo("<br><br><br><b>Sorry, there are no details currently listed.</b>"); } else { $NumRows=mysql_query("select * from telequote_new"); $NumRows=mysql_num_rows($NumRows); $Result = mysql_query("select * from telequote_new") or die("No connection"); for ($i=1; $i<=$NumRows; $i++) { if ($row = mysql_fetch_array($Result)) { $id = $row["id"]; $supplier_name = $row["supplier_name"]; $logo = $row["logo"]; // select new offer details from customers db $NumRows2=mysql_query("select id from customers") or die("Sorry Couldn't Complete Query_1a"); $NumRows2=mysql_num_rows($NumRows2); if ($NumRows2 == "0") { echo("<br><br><br><b>Sorry, there are no details currently listed.</b>"); } else { $NumRows2=mysql_query("select * from customers where company_name = '$company_name'"); $NumRows2=mysql_num_rows($NumRows2); $Result2 = mysql_query("select * from customers where company_name = '$company_name'") or die("No connection"); for ($i=1; $i<=$NumRows2; $i++) { if ($row = mysql_fetch_array($Result2)) { $id = $row["id"]; $company_name = $row["company_name"]; $isdn2a = $row["isdn2a"]; $isdn2b = $row["isdn2b"]; $isdn2c = $row["isdn2c"]; $isdn2d = $row["isdn2d"]; $isdn2e = $row["isdn2e"]; $isdn2f = $row["isdn2f"]; $isdn30a = $row["isdn30a"]; $isdn30b = $row["isdn30b"]; $isdn30c = $row["isdn30c"]; $isdn30d = $row["isdn30d"]; $isdn30e = $row["isdn30e"]; $isdn30f = $row["isdn30f"]; $analogue_linesa = $row["analogue_linesa"]; $analogue_linesb = $row["analogue_linesb"]; $analogue_linesc = $row["analogue_linesc"]; $analogue_linesd = $row["analogue_linesd"]; $analogue_linese = $row["analogue_linese"]; $analogue_linesf = $row["analogue_linesf"]; $locala = $row["locala"]; $localb = $row["localb"]; $localc = $row["localc"]; $locald = $row["locald"]; $locale = $row["locale"]; $localf = $row["localf"]; $nationala = $row["nationala"]; $nationalb = $row["nationalb"]; $nationalc = $row["nationalc"]; $nationald = $row["nationald"]; $nationale = $row["nationale"]; $nationalf = $row["nationalf"]; $vodafonea = $row["vodafonea"]; $vodafoneb = $row["vodafoneb"]; $vodafonec = $row["vodafonec"]; $vodafoned = $row["vodafoned"]; $vodafonee = $row["vodafonee"]; $vodafonef = $row["vodafonef"]; $orangea = $row["orangea"]; $orangeb = $row["orangeb"]; $orangec = $row["orangec"]; $oranged = $row["oranged"]; $orangee = $row["orangee"]; $orangef = $row["orangef"]; $tmobilea = $row["tmobilea"]; $tmobileb = $row["tmobileb"]; $tmobilec = $row["tmobilec"]; $tmobiled = $row["tmobiled"]; $tmobilee = $row["tmobilee"]; $tmobilef = $row["tmobilef"]; $o2a = $row["o2a"]; $o2b = $row["o2b"]; $o2c = $row["o2c"]; $o2d = $row["o2d"]; $o2e = $row["o2e"]; $o2f = $row["o2f"]; $other_mobilea = $row["other_mobilea"]; $other_mobileb = $row["other_mobileb"]; $other_mobilec = $row["other_mobilec"]; $other_mobiled = $row["other_mobiled"]; $other_mobilee = $row["other_mobilee"]; $other_mobilef = $row["other_mobilef"]; $internationala = $row["internationala"]; $internationalb = $row["internationalb"]; $internationalc = $row["internationalc"]; $internationald = $row["internationald"]; $internationale = $row["internationale"]; $internationalf = $row["internationalf"]; $offer_number = $row["offer_number"]; $offer_month = $row["offer_month"]; $offer_year = $row["offer_year"]; // convert offer_month code into month text switch ($offer_month) { case "01": $monthtext = 'January'; break; case "02": $monthtext = 'February'; break; case "03": $monthtext = 'March'; break; case "04": $monthtext = 'April'; break; case "05": $monthtext = 'May'; break; case "06": $monthtext = 'June'; break; case "07": $monthtext = 'July'; break; case "08": $monthtext = 'August'; break; case "09": $monthtext = 'September'; break; case "10": $monthtext = 'October'; break; case "11": $monthtext = 'November'; break; default: $monthtext = 'December'; break; } // work out total of Gamma's offer if ($supplier_name == "Gamma Telcom") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2a * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30a * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linesa * 12; $LOCAL_REDUCED = $local_line_details * $locala / 100; $NATIONAL_REDUCED = $national_line_details * $nationala / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafonea / 100; $ORANGE_REDUCED = $orange_line_details * $orangea / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobilea / 100; $O2_REDUCED = $o2_line_details * $o2a / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationala / 100; $OTHER_REDUCED = $other_line_details * $other_mobilea / 100; $TOTAL_REDUCED_1 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_1 = number_format($TOTAL_REDUCED_1); } // work out total of Thus's offer if ($supplier_name == "Thus") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2b * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30b * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linesb * 12; $LOCAL_REDUCED = $local_line_details * $localb / 100; $NATIONAL_REDUCED = $national_line_details * $nationalb / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafoneb / 100; $ORANGE_REDUCED = $orange_line_details * $orangeb / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobileb / 100; $O2_REDUCED = $o2_line_details * $o2b / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationalb / 100; $OTHER_REDUCED = $other_line_details * $other_mobileb / 100; $TOTAL_REDUCED_2 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_2 = number_format($TOTAL_REDUCED_2); } // work out total of Kingston's offer if ($supplier_name == "Kingston") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2c * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30c * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linesc * 12; $LOCAL_REDUCED = $local_line_details * $localc / 100; $NATIONAL_REDUCED = $national_line_details * $nationalc / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafonec / 100; $ORANGE_REDUCED = $orange_line_details * $orangec / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobilec / 100; $O2_REDUCED = $o2_line_details * $o2c / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationalc / 100; $OTHER_REDUCED = $other_line_details * $other_mobilec / 100; $TOTAL_REDUCED_3 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_3 = number_format($TOTAL_REDUCED_3); } // work out total of C&W's offer if ($supplier_name == "Cable and Wireless") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2d * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30d * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linesd * 12; $LOCAL_REDUCED = $local_line_details * $locald / 100; $NATIONAL_REDUCED = $national_line_details * $nationald / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafoned / 100; $ORANGE_REDUCED = $orange_line_details * $oranged / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobiled / 100; $O2_REDUCED = $o2_line_details * $o2d / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationald / 100; $OTHER_REDUCED = $other_line_details * $other_mobiled / 100; $TOTAL_REDUCED_4 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_4 = number_format($TOTAL_REDUCED_4); } // work out total of BT's offer if ($supplier_name == "British Telecom") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2e * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30e * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linese * 12; $LOCAL_REDUCED = $local_line_details * $locale / 100; $NATIONAL_REDUCED = $national_line_details * $nationale / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafonee / 100; $ORANGE_REDUCED = $orange_line_details * $orangee / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobilee / 100; $O2_REDUCED = $o2_line_details * $o2e / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationale / 100; $OTHER_REDUCED = $other_line_details * $other_mobilee / 100; $TOTAL_REDUCED_5 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_5 = number_format($TOTAL_REDUCED_5); } // work out total of Opal's offer if ($supplier_name == "Opal") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2f * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30f * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linesf * 12; $LOCAL_REDUCED = $local_line_details * $localf / 100; $NATIONAL_REDUCED = $national_line_details * $nationalf / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafonef / 100; $ORANGE_REDUCED = $orange_line_details * $orangef / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobilef / 100; $O2_REDUCED = $o2_line_details * $o2f / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationalf / 100; $OTHER_REDUCED = $other_line_details * $other_mobilef / 100; $TOTAL_REDUCED_6 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_6 = number_format($TOTAL_REDUCED_6); } // puts the six above into an array $TOTALS = array($TOTAL_REDUCED_1, $TOTAL_REDUCED_2, $TOTAL_REDUCED_3, $TOTAL_REDUCED_4, $TOTAL_REDUCED_5, $TOTAL_REDUCED_6); print_r($TOTALS[0][0]); print_r($TOTALS[0][1]); print_r($TOTALS[0][2]); print_r($TOTALS[0][3]); print_r($TOTALS[0][4]); print_r($TOTALS[0][5]); // this commented out code is how I want to display the data in rows in numerical order when the system works as it should //echo(" // <tr height='50'> // <td bgcolor='#FFCC66' width='25%'><strong><font size='2' face='Trebuchet MS'><a href='telequote.php?Step=StepTwo&&company_name=$company_name&&supplier_name=$supplier_name&&customer_id=$customer_id'>$supplier_name</a></font></strong></td> // <td align='center' bgcolor='#FFCC66' width='25%'><a href='telequote.php?Step=StepTwo&&company_name=$company_name&&supplier_name=$supplier_name&&customer_id=$customer_id'><img border='1' src='images/logos/$logo'></a></td> // <td align='right' bgcolor='#FFCC99' width='25%'><font size='2' face='Trebuchet MS'><strong>£$TOTALS</strong></font></td> // <td align='right' bgcolor='#FFCC99' width='25%'><font size='2' face='Trebuchet MS'><strong>$offer_number $monthtext $offer_year</strong></font></td> // </tr> //"); }}} }}} print(" </table> "); print(" <br><font size='2' face='Trebuchet MS'>Click the supplier name or logo to view the offer breakdown<br>Costs exclude VAT</font> "); }
  16. I don't know to be honest. I wouldn't know where to start because I never work with arrays, hence the reason I've laid my code out like I have. It worked fine until I started trying to display the totals in numerical order. Do you think it's best to use that method?
  17. Yes it's a select from statement like this: $NumRows=mysql_query("select * from table"); $NumRows=mysql_num_rows($NumRows); $Result = mysql_query("select * from table") or die("No connection"); for ($i=1; $i<=$NumRows; $i++) { if ($row = mysql_fetch_array($Result)) { $id = $row["id"]; $supplier_name = $row["supplier_name"]; $logo = $row["logo"];
  18. It's a select from statement which selects 6 rows from a table. There will only ever be six rows in the table but each row has a field called 'supplier_name' and then a series of figures to go with that field, which we then use to formulate the totals, and eeventually we need to display the totals for each supplier name in numerical order, preferably in a row that looks like this: $supplier_name $TOTAL_REDUCED $date etc
  19. Over 1000 lines? This is currently about 1,000 in total because it works in steps. This problem is with Step One so God help me with the rest! 1) supplier name is the name of the telecoms supplier that is offering the figures that we're putting in numerical order. 2) that code actually doesn't display anything at all for some strange reason!
  20. Here it is in its entirity! (told you there was a lot!) :-) if ($supplier_name == "One") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2a * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30a * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linesa * 12; $LOCAL_REDUCED = $local_line_details * $locala / 100; $NATIONAL_REDUCED = $national_line_details * $nationala / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafonea / 100; $ORANGE_REDUCED = $orange_line_details * $orangea / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobilea / 100; $O2_REDUCED = $o2_line_details * $o2a / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationala / 100; $OTHER_REDUCED = $other_line_details * $other_mobilea / 100; $TOTAL_REDUCED_1 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_1 = number_format($TOTAL_REDUCED_1, 2); } if ($supplier_name == "Two") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2b * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30b * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linesb * 12; $LOCAL_REDUCED = $local_line_details * $localb / 100; $NATIONAL_REDUCED = $national_line_details * $nationalb / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafoneb / 100; $ORANGE_REDUCED = $orange_line_details * $orangeb / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobileb / 100; $O2_REDUCED = $o2_line_details * $o2b / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationalb / 100; $OTHER_REDUCED = $other_line_details * $other_mobileb / 100; $TOTAL_REDUCED_2 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_2 = number_format($TOTAL_REDUCED_2, 2); } if ($supplier_name == "Three") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2c * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30c * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linesc * 12; $LOCAL_REDUCED = $local_line_details * $localc / 100; $NATIONAL_REDUCED = $national_line_details * $nationalc / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafonec / 100; $ORANGE_REDUCED = $orange_line_details * $orangec / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobilec / 100; $O2_REDUCED = $o2_line_details * $o2c / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationalc / 100; $OTHER_REDUCED = $other_line_details * $other_mobilec / 100; $TOTAL_REDUCED_3 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_3 = number_format($TOTAL_REDUCED_3, 2); } if ($supplier_name == "Four") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2d * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30d * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linesd * 12; $LOCAL_REDUCED = $local_line_details * $locald / 100; $NATIONAL_REDUCED = $national_line_details * $nationald / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafoned / 100; $ORANGE_REDUCED = $orange_line_details * $oranged / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobiled / 100; $O2_REDUCED = $o2_line_details * $o2d / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationald / 100; $OTHER_REDUCED = $other_line_details * $other_mobiled / 100; $TOTAL_REDUCED_4 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_4 = number_format($TOTAL_REDUCED_4, 2); } if ($supplier_name == "Five") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2e * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30e * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linese * 12; $LOCAL_REDUCED = $local_line_details * $locale / 100; $NATIONAL_REDUCED = $national_line_details * $nationale / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafonee / 100; $ORANGE_REDUCED = $orange_line_details * $orangee / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobilee / 100; $O2_REDUCED = $o2_line_details * $o2e / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationale / 100; $OTHER_REDUCED = $other_line_details * $other_mobilee / 100; $TOTAL_REDUCED_5 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_5 = number_format($TOTAL_REDUCED_5, 2); } if ($supplier_name == "Sixl") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2f * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30f * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linesf * 12; $LOCAL_REDUCED = $local_line_details * $localf / 100; $NATIONAL_REDUCED = $national_line_details * $nationalf / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafonef / 100; $ORANGE_REDUCED = $orange_line_details * $orangef / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobilef / 100; $O2_REDUCED = $o2_line_details * $o2f / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationalf / 100; $OTHER_REDUCED = $other_line_details * $other_mobilef / 100; $TOTAL_REDUCED_6 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_6 = number_format($TOTAL_REDUCED_6, 2); } $TOTALS = array($TOTAL_REDUCED_1, $TOTAL_REDUCED_2, $TOTAL_REDUCED_3, $TOTAL_REDUCED_4, $TOTAL_REDUCED_5, $TOTAL_REDUCED_6); print_r($TOTALS[0][0]); print_r($TOTALS[0][1]); print_r($TOTALS[0][2]); print_r($TOTALS[0][3]); print_r($TOTALS[0][4]); print_r($TOTALS[0][5]);
  21. That's returning the same number on separate rows, like this: 2,984. 2,984. 2,984. 2,984. 2,984. 2,984. More than before, which was just a series of 2's
  22. No that's just outputting a series of 2's again. These are the kind of problems i've been getting when I tried to code it myself....frustrating!!
  23. That's returned a series of 2's, like this: 2 2 2 2 2 2 Is that because i've got a comma in the numerical result and i'm displaying them to 2 decimal places, possibly?
  24. That returns an error on the second line of the code! Looks like it's for the less than part of it. Parse error: syntax error, unexpected '<', expecting T_VARIABLE or '$'
  25. That simply outputs the following, which is much tidier for starters: 2,984.15 2,984.15 2,984.15 2,984.15 2,984.15 2,984.15
×
×
  • 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.