Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Everything posted by wildteen88

  1. Have look at the manual on output buffering.
  2. Then replace the spaces with an underscore (_) instead?
  3. On line 67 in form_proceessed2011-NEW.php there is some form of output therefore header() will not work. The solution would be to modify your script so there is no output before the use of the header() function. Or for a simple fix revert to using output buffering.
  4. Look for PHP validation tutorials. There isn't a built in function which will do it all for you.
  5. Does the folder Changes exist within the Projects folder? fwrite will not create the directory structure if it doesn't exist. You'll first need to create the directory structure and then create/write to the file. Also make sure the folder Changes if it exists is not set to Read Only in Windows.
  6. The only way I got it to work is to use type casting. Change the foreach loop to foreach($XML->xml->establishments->land as $value) { $key = (int) $value->id; $cost = (int) $value->cost; $income = (int) str_replace(array('$', ','), '', (string) $value->income); $properties[ $key ]['cost'] = $cost; $properties[ $key ]['income'] = $income; $ratios[ $key ] = $income / $cost; }
  7. I didn't test my code using XML data. I used some hard coded values. However this shouldn't make a difference. Could I see how your XML file is constructed?
  8. You should be replacing the spaces in PHP when outputting your links. Not mod_rewrite.
  9. The only places you use explode on are lines 58 and 69 58. $temp = explode(' ', $this->numbers[$j]); 59. for ($a =0; $a <$temp.length; $j++); ... 69. $temp1 = explode(' ', $this->numbers[$j]); 70. for ($a =0; $a <$temp1.length; $j++); On lines 58 and 69 you use explode to get the individual numbers from $this->numbers[$j]. But you are not doing anything with them afterwards (lines 59 and 70). The for loop is not constructed incorrectly. Variables do not have properties such as .length.
  10. Why when that is what append mode does. Quote from the manual
  11. Yea sorry, I posted in the wrong code earlier. I tried to edit it before you read my reply.
  12. Templates as in what?
  13. That fine. I just through you may have forgotten about your previous post as you didn't reply to it last time. If you want to add a string of numbers, eg $numbers = '1, 3, 18, 27'; And you want to add them into an array you can simply do $array[] = $numbers; That will add the string of numbers to the array.
  14. You can use a script called PHPMailer for sending emails with attachments. Basic usage example: http://phpmailer.worxware.com/index.php?pg=examplebmail
  15. Just replace the HTML with header('Location: thankyou.php'); However you will want to remove this gap ?> <?php Before using that function. header() will not work if there is any kind of output beforehand.
  16. There is nothing wrong with building a CMS in PHP. There a probably thousands of content management scripts that where made with PHP, the most popular being Joomla and WordPress and few others.
  17. Rather than assign each properties values to seperate variables ($id10_code $id10_value $id10_id etc). You'll want to assign them to an array instead within your foreach loop $key = $value->id; $properties[ $key ]['name'] = $value->name; $properties[ $key ]['cost'] = $value->cost; $properties[ $key ]['income'] = $value->income; After calculate the ratio and add it to a separate array for storing the ratios. When adding the ratio to the array assign its key as the property id eg $ratios[ $key ] = $value->income / $value->cost; Now after the foreach loop you then use max to get the highest ratio from the $ratios array. $highestRatio = max($ratios); // get the highest ratio Next use array_search to get property details for the highest ratio. $propertyKey = array_search($highestRatio, $ratios); // get the property key $property = $properties[ $propertyKey ]; // get the property with the highest ratio $property will be associative array of the properties details (name, cost, income). Complete code $XML = simplexml_load_string("property_list.xml"); $ratios = array(); $properties = array(); foreach($XML->xml as $value) { $key = $value->id; $properties[ $key ]['name'] = $value->name; $properties[ $key ]['cost'] = $value->cost; $properties[ $key ]['income'] = $value->income; $ratios[ $key ] = $value->income / $value->cost; } $highestRatio = max($ratios); // get the highest ratio $propertyKey = array_search($highestRatio, $ratios); // get the properties ID $property = $properties[ $propertyKey ]; // get the property with the highest ratio echo $property['name'] . ' has the best ratio of ' . $highestRatio;
  18. So you only want to calculate the ratios with the properties that have the id of 10, 12 and 16? Or do you want to do it for all properties within property_list.xml?
  19. Without seeing your code how you are getting the cost/income and calculating the ratio I cannot provide you a better answer other than what I posted above. This is what you will need to do
  20. fopen returns a handler which you need to capture using a variable when calling fopen. You then pass this handler as the first parameter to fwrite. You don't pass the filename. Corrected code $handle = fopen($file,'a') or die("can't open file"); fwrite($handle, $Username);
  21. This topic has been moved to PHP Coding Help. http://www.phpfreaks.com/forums/index.php?topic=333804.0
  22. Basically add all the ratios your script calculates into an array then use max which will pick the highest ratio from the array
  23. No point I don't read PM's. If you need help post it in the forums.
  24. Use an if which compares the two variables if($FirstRatio > $SecoundRatio) echo $FirstRatio; else echo $SecoundRatio;
×
×
  • 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.