Jump to content

Psycho

Moderators
  • Posts

    12,157
  • Joined

  • Last visited

  • Days Won

    129

Everything posted by Psycho

  1. OK, THAT'S IT! If I could I would delete every post I have made in this thread for I regret EVER having helped you. You are cheating on us with another forum! I caught you red handed: http://www.dynamicdrive.com/forums/showthread.php?p=235020
  2. Try setting your FROM address to something like this $EmailFrom = "From: Win One <someaddress@yourcompany.com>"; Use a valid email address within the brackets for buncebacks and/or replies to be sent to. Aw, shucks. Pls don't tell my wife.
  3. The problem is your use of $next_record. You call it in the while loop AND inside the loop itself. So each iteration of the loop will use up two records. I think this is a more efficient method: function map_showCA() { global $db, $tpl; // ShowLocalResources $sSQL = "SELECT id, state, statename, statename_html FROM states_canada ORDER BY state;"; $db->query($sSQL); $recordIdx = 0; $column_names = array('first', 'second', 'threeth', 'fourth', 'fifth'); while ($db->next_record()) { $state = $db->f("state"); $statename = $db->f("statename"); $statename_html = (!USE_SEO_LINKS) ? $statename_html = $db->f("id") : $db->f("statename_html"); //Determine the column and column name $colIdx = $recordIdx%count($column_names); $col_name = $column_names[$colIdx]; $parameters = "http://{$statename_html}ilocalize.com"; // $column_link = generate_vendor_seo_url($parameters); $tpl->set_var("{$col_name}_column_link", $parameters); $tpl->set_var("{$col_name}_column", tohtml($statename)); $recordIdx++; } $tpl->parse("ShowLocalResourcesCA", true); }
  4. Doh! I made the same error as you. Move the two lines that close the row and table to after the while loop closing bracket. As I alluded to before: Check your output! If you looked at the actual rendred HTML you would see somethign like this: <table> <tr> <td><img src="somfiel.jpg"> Title</td> </tr> </table> <td><img src="somfiel.jpg"> Title</td> </tr> </table> <td><img src="somfiel.jpg"> Title</td> </tr> </table>
  5. You added the new code for the sucess condition instead of replaceing it. Try this: <?php $EmailFrom = "Win One"; $EmailTo = "sales@capsonewire.com"; $Subject = "Registration"; $Name = Trim(stripslashes($_POST['Name'])); $Tel = Trim(stripslashes($_POST['Tel'])); $Email = Trim(stripslashes($_POST['Email'])); $Phone = Trim(stripslashes($_POST['Phone'])); $Message = Trim(stripslashes($_POST['Message'])); // validation $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: {$Name}\n"; //$Body .= "City: {$City}\n"; $Body .= "Email: {$Email}\n"; $Body .= "Phone: {$Phone}\n"; $Body .= "Message: {$Message}\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success) { //Modify content for confirmation and send to user $message = "This is to confirm that the following message was sent to our sales department:\n\n" . $message; mail($Email, $Subject, $Body, "From: <$EmailFrom>"); //Redirect to thank you page print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">"; } else { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?> Edit: Also added the line to actually send the email that Nightslyr found.
  6. What do the transactions have to do with updating the account table? Also, if the interest rate is differnent between accounts then it shoudl be included in the account table. However, if there is a fixed number of account types, then the account types should be it's own table and referenced back to the accounts table. I have no idea exactly how your db should be structured, but here is an example of how I would do it. TABLE: account_types atype_id | atype_name | rate ------------------------------------ 1 | Standard Savings | 1.2 2 | Money Market | 3.5 3 | Checking | 0 TABLE: customers cust_id | fist_name | last_name -------------------------------- 4 | Bob | Smith 8 | Jane | Davis TABLE: accounts acct_id | cust_id | type_id | date_opened | date_closed ------------------------------------------------------- 21 | 4 | 1 | 4/23/2010 | 22 | 4 | 3 | 4/23/2010 | 23 | 8 | 2 | 5/13/2010 | TABLE: transaction_types ttype_id | ttype_name ---------------------- 15 | Deposit 16 | Interest Payment 17 | ATM Withdrawal TABLE: transactions acct_id | ttype_id | date | memo | amount 21 | 15 | 4/23/2010 | | 250 21 | 15 | 5/6/2010 | | -80 From the above you can see that Bob has two accounts: standard savings and checking. Also, he opened the savings account on 4/32 with a deposit of $250 and he has an ATM withdrawal on 5-6-2010 of $80 So, you could easlity find the current balance of any account by joining the applicable tables and doing a sum of the amounts column.
  7. As Sasa pointed out I erroneously used a plus (+) instead of a period (.) when creating the modified message. use this: // redirect to success page if ($success) { //Modify content for confirmation and send to user $message = "This is to confirm that the following message was sent to our sales department:\n\n" . $message; mail($Email, $Subject, $Body, "From: <$EmailFrom>"); //Redirect to thank you page print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">"; } Also, if you get an error, by all means POST the error. Lastly, do not use your production environment for testing!
  8. My point is that "Go read the manual" never helped anyone do anything of value. Really? Have you ever read the PHP manual? I learn a ton from it. Even when I think I know everything about a function, if I read the PHP manual for that function (especially the notes) I sometimes learn a lot of useful information. But, that is besides the point because no one said to "Go read the manual". I suggested you go read a Tutorial. There is a big difference between a manual and a tutorial. A good tutorial will include a realistic problem needing to be solved and then explain how the process in question can be used to solve the problem. I read the tutorials for OOP on this site quite a while back but recall them giving good examples and context of the functionality. Anyway, mnoving this post to the "Application Design" forum as it seems the most appropriate for this subject. Good luck with getting the hand-holding you need.
  9. So, why would you include a "</table>" at the end of every image! That was the exact issue I mentioned in the first reply. You are also creating a ROW for every image which is screwing it up. This is an HTML issue that is caused by faulty logic in your PH code. If you were to view the source of the rendered HTML page the errors should be obvious. You area slo grabbing way more fields than you are using and there is no need to create variables for each from the db results just to use it once. Try this //validate item $query = "SELECT p.thumb, p.title, p.name FROM product AS p LEFT JOIN picks AS s on s.item_id = p.id WHERE s.date = CURDATE()"; $get_item_sql = mysql_query($query) or die(mysql_error()); if (mysql_num_rows($get_item_sql) < 1) { //invalid item $display_block .= "<p><em>Invalid item selection.</em></p>"; } else { //Start the table and row $display_block = "<table>\n"; $display_block .= "<tr>\n"; //valid item, get info while ($item = mysql_fetch_array($get_item_sql)) { $item_id = $item_info['item_id']; $item_artist = $item_info['artist']; $item_photo = $item_info['thumb']; $item_username = $item_info['username']; $item_title = $item_info['title']; $item_name = $item_info['name']; $display_block .= "<td >"; $display_block .= "<img src=\"image_files/{$item['thumb']}\" alt=\"{$item['name']}\" />"; $display_block .= "<br />{$item['title']} " $display_block .= "</td>\n"; //Close the row and table $display_block .= "</tr>\n"; $display_block .= "</table>"; } }
  10. Off topic @ sinista: You never need to create an IF/ELSE statement were the IF condition returns true and the ELSE condition returns false. Instead of this function error_check($var) { if($var ==10) { return true; } else return false; } You should have just done this function error_check($var) { return ($var==10); }
  11. Hmm...for some strange reason that code is using HTML META Refresh to redirect the page instead of PHP header() functions. I wouldn't do that, but it will work. Anyway, it appears the script is already sending an email to the sales department. So, you need to send a copy to the submitter. You already have thier email address in the variable $Email. So, just add another line with the mail() function, but use their email instead of the $EmailTo (which goes to sales). You might also add some text to the top of the message stating something like "The following email was sent to...". Modify this // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">"; } To this // redirect to success page if ($success) { //Modify content for confirmation and send to user $message = "This is to confirm that the following message was sent to our sales department:\n\n" + $message; mail($Email, $Subject, $Body, "From: <$EmailFrom>"); //Redirect to thank you page print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">"; } To add instructions in the response you would need to modify the thank you page: contactthanks.php
  12. This is technically an HTML problem not a PHP problem. But, since you say you are displaying "a row of images" I assume that line above is within a loop. Well, you have TR tags and an ending TABLE tag. The TR and TABLE tags would need to be outside the loop.
  13. Then perhaps you should have stated that in your initial post. Otherwise it looked like you were asking for someone to personally teach you OOP. OK, I'm not sure what you have been reading, but it must not have been very good. I read a couple of tutorials to get started and was able to implement OO code into my site fairly easily - although I still use a lot of procedural. As for how do you "link" the class that should have been the very first thing your "books" covered. You simply include the file with the Class code as you would any other php file using one of the include()/require() variants. Then you instantiate the class by creating a new object like so: $someVariable = new SomeClassDefiningAnObject;
  14. I'm really not following you. It seems you are making this more difficult than it needs to be. You should not have separate tables for deposits and withdrawals and then another to store the totals. You only need ONE table to store the transactions indicating the type of transaction and the amount (deposits would be positive while withdrawals would be negative). Using that you could easily get the current total for the account and report on deposits and withdrawals independantly as needed. Of course you would want to have a separate table to store the user/owner of the account which all of the transactions would relate back to.
  15. What is the exact content of the original string? You would most likely want to use a regular expression to remove the unwanted characters.
  16. This forum is for getting help with code that you have written. In any event, it's not efficient to try and teach someone through a forum. There are plenty of tutorials out there for PHP OOP Programming. I would suggest you take a look at some. Here are a couple: Beginning Object Oriented Programming in PHP Object Oriented PHP for Beginners Or there are the Tutorials on this site: OO PHP Part 1: OOP in Full Effect OO PHP Part 2: Boring OO Principles OO PHP Part 3: UML, Classes and Relations
  17. I couldn't get your code to run - getting an error about defining the function as a parameter for some reason. But, I was able to get the logic needed. Basically you need to test the min()'s of the two arrays. If the mins are not equal then sort the lowest min first. If they are equal you need to remove those min values and test the new mins. This process continues until you get unequal mins or until one or both arrays run out of values. If you get two different mins the array with the lowest min gets sorted first. If one array runs out of values it is sorted first. If both arrays run out of values (they had the exact same values) return 0; Here is the function I used. I'll leave it to you to determine how to implement the logic into your existing code: function sort_by_array ($a, $b) { $a = $a['list']; $b = $b['list']; //Continue to remove the min value from each array until //they are not equal or until one runs out of values while(count($a)>0 && count($b)>0 && min($a)==min($b)) { unset($a[array_search(min($a), $a)]); unset($b[array_search(min($b), $b)]); } //$a and $b have different min values if(count($a)>0 && count($b)>0) { return (min($a)>min($b))?1:-1; } //One or both arrays ran out of values return (count($a)!=count($b)) ? (count($a)==0)?-1:1 : 0; }
  18. The solution you want is "mod_rewrite". Whether you can use it or not will depend upon the web server you use and your permissions. Here is a tutorial on it: http://www.workingwith.me.uk/articles/scripting/mod_rewrite
  19. Ideally you would want to "build" the checkboxes from wherever you store the list (in a DB?). Without knowing your entire application here is a solution using an array. I also modified it slightly so you can give the checkboxes more descriptive labels other than "MS" while still preserving the values. I'm not sure why you have a closing FORM tag before the form fields, but oh well. Lastly, don't use the FONT tag, it has been deprecated for years. Since you are using a class it isn't doing anything anyway - just use a span tag. <form /> <?php $levelList = array( 'PreK' => 'Pre Kindergarten', 'Elem' => 'Elementary', 'MS' => 'Middle School', 'HS' => 'High School', 'College' => 'College' ); //Display selected levels echo "<b>Levels <br /> />"; echo implode(" <br />\n", $_GET['lev']); //Create list of levels for selection foreach($levelList as $level => $label) { echo "<input type=\"checkbox\" name=\"lev[]\" value=\"{$level}\" />"; echo "<span class=\"sm\">PreK</span>\n"; } ?> <input type="submit" value=" ..:: Submit ::.. " />
  20. You will need to modify the function openenfobox() in some way. Without understanding the entire process I can't state what the best solution would be, but here is one: Add a third parameter to the openinfobox() function. In all the onclick calls add the third parameter using 'this' onclick="openinfobox('Enquiry Sent', 1, this)" You can then implement the solution in JS by having the function check the href value of the link object and if it doesn't contain "#e" then do not make the call to PHP. Or you could append the "#e" as another paramter tot he AJAX call and have PHP react accordingly.
  21. After a little more tinkering I've greatly reduced the primary function that determines the last time any contents of a folder have been modified. function lastModifiedDate($folder, $recursive=true) { $filesAry = glob("{$folder}/*"); foreach($filesAry as $file) { $lastMod = max(filemtime($file), (is_dir($file)&&$recursive)?lastModifiedDate($file):0); } return $lastMod; }
  22. I wrote it yesterday. If I already had it I would have posted it in my first response. It seemed like an interesting problem to solve and I thought that I could get some "template" code that I could use in the future. The only thing is that it is not going to be efficient since you have to check every object inside the folder. I also made the code recursive so when it checks to find when the content of a folder was last modified it not only check the first level of files and folder it also check all the sub folders and the subfolders in those, and so on. If you don't need to check the subfolders then remove the entire IF condition block that starts if(is_dir($file))
  23. Here you go. There are two functions: getFoldersByModified(): This function takes a root folder as the input and will check each folder using lastModifiedDate() (explained below) and will return an array of the folders in order of the date that their content was last modified. lastModifiedDate(): This will return the last modified date of anything inside the folder (files and other subfolders). You can then take the first five elements from the returned array using something like array_splice($array, 5); function lastModifiedDate($folder, $lastDate=false) { $filesAry = glob("{$folder}/*"); foreach($filesAry as $file) { if(!$lastDate || filemtime($file)>$lastDate) { $lastDate = filemtime($file); } if(is_dir($file)) { $lastDate = lastModifiedDate($file, $lastDate); } } return $lastDate; } function getFoldersByModified($root_directory) { //Get list of folders in root $foldersAry = glob("{$root_directory}/*", GLOB_ONLYDIR); //Iterrate through each folder getting last modified date $foldersByDate = array(); foreach($foldersAry as $folder) { $foldersByDate[lastModifiedDate($folder)] = basename($folder); } krsort($foldersByDate); return $foldersByDate; } //Specify the root directory $root_directory = "./ts3-v3-small"; //Get all folders in order of the "modified" date $foldersByDate = getFoldersByModified($root_directory); //Remove all but the first five array_splice($foldersByDate, 5); print_r($foldersByDate);
  24. I'm not sure I totally understand your application or what the structure should be, but you explanation "seems" logical. However: There is no need to "loop over" the array and run separate queries. You should never run queries within loops if not absolutely necessary. And in this case it definitely is not. Just use the array to create the single query statement. Here is an example (assuming the records just need foreign keys for the dicount and eligibility records.: $discountID = $_POST['discount_id']; $eligibilityAry = $_POST['eligibility_options']; //Create an array of the records to be added $valuesAry = array(); foreach($eligibilityAry as $eligOption) { $valuesAry[] = "('{$discountID}', '{$eligOption}')"; } $valuesStr = implode(', ', $valuesAry); $query = "INSERT INTO `Discounts_To_Eligibility` VALUES " . $valuesStr; $result = mysql_query($query); The query would look something like this (added line breaks for clarity): INSERT INTO `Discounts_To_Eligibility` VALUES ('9', '5'), ('9', '16'), ('9', '23'), ('9', '33')
  25. I have some advice - DON'T STORE ARRAYS. Once you store an array of values you lose a ton of functionality. You stated above you may need to search the array. However, by storing the array into a single field you lose the ability to easily search the records effectively. Youwould either need to use regular expressions in the query or you would have to query all the records and then iterrate through each one to search using PHP. The better method is to store the multiple values in a separate table using a foreign key back tothe parent record. This is the whole point of a relatinal database. For example, if you have a user with multiple coupons you would have a single entry in the USER table. Then in the COUPONS table you would have multiple records - one for each coupon - and each record would have a field to identify the user record they are associated with.
×
×
  • 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.