
shane85
Members-
Posts
128 -
Joined
-
Last visited
Never
Everything posted by shane85
-
hey guys im trying to do some form validation but running into a problem....I have 2 pages, edit_prospect.php and edit_prospect2.php my form is on edit prospect.php but im viewing records with it so its always like edit_prospect.php?prospect_id=30 or something like that...when the form is submitted, it submits to edit_prospect2.php on edit_prospect2.php I have the following code <?php //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; // the if statements and error messages if($firstname == '') { $errmsg_arr[] = 'First name missing'; $errflag = true; } if($lastname == '') { $errmsg_arr[] = 'Last name missing'; $errflag = true; } if($contact_next == '') { $errmsg_arr[] = 'You must enter a date to contact this prospect next'; $errflag = true; } //If there are input validations, redirect back to the registration form if($errflag) { header("location: edit_prospect.php?prospect_id=38"); // for testing purposes im just testing the 38 record but eventually it will jus tbe to // edit_prospect.php?prospect_id=(variable for prospect_id here) } then on edit_prospect.php I just have the following <?php echo $errmsg_arr; ?> now obviously the form submits to it when there is an error, but it dosnt display what the error is. If u fill in the fields, it goes to the proper page. What is wrong?
-
now it displays -14704 <?php $today=$arrEntry['tstamp']; $time_next=$arrEntry['contact_next']; $timediff=(($time_next)-($today)); $minutes=$timediff/60; $hours=$minutes/60; $days=ceil($hours/24); echo $days; ?>
-
hmm I tried your code and tried to echo days and it displayed 23, which is correct and what I want. However when I entered my variables it displayed a wierd number...my code is as follows <?php $today=$arrEntry['tstamp']; $time_next=$arrEntry['contact_next']; $timediff=(strtotime($time_next)-strtotime($today)); $minutes=$timediff/60; $hours=$minutes/60; $days=ceil($hours/24); echo $days; ?> it displayed 14888 as the number of days...in my db, tstamp is 2010-04-05 15:37:54 and contact_next is 2010-10-05 does it matter that in my db for tstamp time is recorded as well? or its only looking at the date?
-
sorry for all the posts on this today...I cant think straight for some reason when my form submits, it gives a timestamp of when it was submitted theres also a drop down which is where "contact_next" is chosen from...im using strtotime +1day 2day 3day etc. to enter in the information into my db. now if I want to display my querys by contact_next, how would I do the subtraction to show, for example timestamp: 2010-04-05 contact_next: 2010-04-08 obviously the difference there is 3 days....if thers entries for 1 day, 2 days, 3 days etc. I want it so that when viewing by "contact next" the 1 day will show first...then 2, etc etc etc. Also once the "contact_next" expires, ie. todays timestamp would be ahead of that field, to not show those expired results.
-
duh...figured it out...cause im not echoing anything in it...lol
-
I have a drop down so that the options of when to contact next can be chosen. I am using strtotime to do it but its just entering a blank field into my db. The code is as follows for the drop down <select name="contact_next" id="contact_next" class="textfield"> <option value="#" >Please Choose</option> <option value="<?php date('Y-m-d', strtotime('+1 day')); ?>">1 Day</option> <option value="<?php date('Y-m-d', strtotime('+2 day')); ?>">2 Days</option> <option value="<?php date('Y-m-d', strtotime('+3 day')); ?>">3 Days</option> <option value="<?php date('Y-m-d', strtotime('+1 week')); ?>">1 Week</option> <option value="<?php date('Y-m-d', strtotime('+2 week')); ?>">2 Weeks</option> <option value="<?php date('Y-m-d', strtotime('+3 week')); ?>">3 Weeks</option> <option value="<?php date('Y-m-d', strtotime('+1 month')); ?>">1 Month</option> <option value="<?php date('Y-m-d', strtotime('+2 month')); ?>">2 Months</option> <option value="<?php date('Y-m-d', strtotime('+3 month')); ?>">3 Months</option> <option value="<?php date('Y-m-d', strtotime('+6 month')); ?>">6 Months</option> </select> If I just echo <?php echo date('Y-m-d', strtotime('+6 month')); it works perfectly. How come it isnt working and storing into my db???
-
hey guys...I made a post on this few days ago but still am unsure on how I should do this, or for that matter what would be the best way. open to suggestions. what im doing is basically I have a form that submits to a database. One of the fields in my form is "contact_next", which is a drop down menu to chose from. The options are 1 day, 2 day, 3 day, 1 wk, 2 wk, 3 wk, 1 month, 2 month, 3 month, 6 month I also have it storing a timestamp of when this entry is added. So I have a time stamp of when added, and when to contact next. So id imagine I would do a time - contact_next? Or something like that - because I have an option when viewing my entrys "View by when to Contact Next" say I have 4 records that are suppost to be viewed in 1 day, so for 1 day those records will be displayed first before the records from 2 days, 3 days etc. Im not sure how to store the "contact_next" in the database to do it properly to fetch the information. thanks
-
hmm...question on mysql db id number auto_increment..
shane85 replied to shane85's topic in PHP Coding Help
perfect, ty! -
hmm...question on mysql db id number auto_increment..
shane85 replied to shane85's topic in PHP Coding Help
where would I put this statement? I dont use it in any of my querys accept when the db is first created. -
hey guys so ive made a db and made it so each row as a product_id number...which auto increases for each time something is added. However, ive done like 50 test entries so my numbers go from 1,2,3,56,57,58 etc I went in and edited them all so they are all in order and I have about 23 entries. However when I add the next one it goes to 59...so something is still telling it theres that many entries. How do I make it so the next entry will be after the last product_id number?
-
Mike: your correct, I changed my code to the following if ($orderby==prospect_id) { $prospectEntries = mysql_query("SELECT * from prospects ORDER BY ".mysql_real_escape_string($orderby)." DESC ".$queryLimit) or trigger_error(mysql_error()); } else { $prospectEntries = mysql_query("SELECT * from prospects ORDER BY ".mysql_real_escape_string($orderby)." ASC ".$queryLimit) or trigger_error(mysql_error()); } while ($prospectEntry = mysql_fetch_array($prospectEntries)) { print_prospectEntry($prospectEntry); } however nothing changes...is it all correct?
-
currently im using a query to display all my results in ASC order... however, I want it so that if prospect_id is chosen, it will display in DESC order, however all the other ones I want to be displayed in ASC order when chosen. I tried the following statement but it didnt work...is there a better way to do this? or is this the proper way, just I have something wrong?? if ($orderby=prospect_id) { // display this query if prospect_id is chosen $prospectEntries = mysql_query("SELECT * from prospects ORDER BY ".mysql_real_escape_string($orderby)." DESC ".$queryLimit) or trigger_error(mysql_error()); } // if not prospect_id display other results in ASC order $prospectEntries = mysql_query("SELECT * from prospects ORDER BY ".mysql_real_escape_string($orderby)." ASC ".$queryLimit) or trigger_error(mysql_error());
-
hey guys...need some help with a math problem. When entering information into my database, I have it so when it submits, it records a timestamp. One of the fields in my form is "Contact Next" and there is a drop down choice of 1 day 2 day 3 day 1 wk 2 wk 3 wk 1month 2month 3month 6month These values are then stored as 01 02 03 07 14 21 1month 2month 3month 6month in a column called contact_next in my db How would I do it so each field kinda counts down to the day they are suppost to be contacted next? I have a button "View by Contact Next" and basically what I want this to do is view by time remaining from the timestamp, to the ammount of time they entered to contact next. Would it also be hard to take it 1 step further, and when the time is up, for instance if they put 3 days, on the 3rd day, send an email reminder??? This isnt spamming its not going to bug anyone other then myself as a reminder to contact the client! Just to put your worries to rest lol. Anyway, please advise - and thanks in advance
-
perfect! thanks alot guys!
-
I commented out that line and adjusted the code to this but doesnt work...what is wrong??? switch($_GET['orderby']) { case "contact": $orderby="$arrEntry[contact_next]"; break; case "date": $orderby="$arrEntry[tstamp]"; break; case "company": $orderby="$arrEntry[company_name]"; break; case "city"; $orderby="$arrEntry[city]"; break; //case default: //$orderby="prospect_id"; //break; } // Prints all records from Prospect ID //$prospectEntries = mysql_query('SELECT * FROM prospects ORDER BY prospect_id DESC ' . $queryLimit) or trigger_error(mysql_error()); $prospectEntries = mysql_query('SELECT * from prospects ORDER BY ".mysql_real_escape_string($orderby)." DESC '.$queryLimit) or trigger_error(mysql_error());
-
I get this error Parse error: syntax error, unexpected T_DEFAULT for this line case default:
-
hey guys question - right now on my page I have it set up to pull info from my db and display the info from my prospect_id column in DESC order. the code I am using is $prospectEntries = mysql_query('SELECT * FROM prospects ORDER BY prospect_id DESC ' . $queryLimit) or trigger_error(mysql_error()); while ($prospectEntry = mysql_fetch_array($prospectEntries)) { print_prospectEntry($prospectEntry); } At the top of my page, I have links: View By: Contact Next Date Added Company Name City now, I know I could achieve this by adjusting my query to view by date_added, company_name etc instead of prospect_id, However, how do I make it so I can have multiple querys in my code so that initially the page displays the way it currently is, by prospect_id, however if someone where to click the link "contact next" it would display by contact_next istead of prospect_id....same for the other links. sorry for the newb quetson - thnx in advance
-
ignace: I think were on the right track but still not all the way there. im still a little confused. I modified the code and tried using the following $checkboxes = array('$check[0]', '$check[1]', '$check[2]', '$check[3]'); // values for your checkboxes $check = explode('-', $arrEntry['a_locations']); foreach ($checkboxes as $key => $checkbox) { echo '<input type="checkbox" id="', $checkbox . $key, '" name="a_locations[]" value="', $checkbox, '"', (in_array($checkbox, $check) ? ' checked="checked"' : ''), '>', '<label for="', $checkbox . $key, '">', $checkbox, '</label>'; } now, my first problem as you will see is its not displaying the variable in the array, it just echos $check[0] $check[1] etc if I just echo not in the array $check[0] the explode works, and it just displays whatever is in the database field before the first - Now, initially you had it as value1, value2, value3, value4 etc. I only want to have as many values as I do entries in my database seperated by -. Sorry im still confused but I think were on the right track. Any more help is appreciated. Thanks
-
hmm maybe I should go about it a different way then??? basically in my database I have a column in my table called a_locations what I want to do is store locations in there, whether it be a single location or multiple ones. I dont ant to do a text field because I want them to choose from the locations I have on the page. A drop down wont work either cause then its just going to be the 1 location they can select. What I was thinking is checkboxes so that they could check off the ones they want. However the problem with that is now when they go to edit the record, how do I display what ones are checked off?
-
hey guys so I have a form that im submitting to my db and in that form there is a spot for "host locations" im doing this with check boxes so that the user can select 1 or multiple boxes, depending on what is required. This information is then submitted into a field called a_locations Now I also have it so that this record can be edited. So all the other info in the table (first name, last, email, etc) are put into txt fields and in the value im just echoing the $variable to show it, and then it is editable. However im not sure how I would do this for check boxes? If the information is stored into my db and seperated by - lets say, should I explode that, but into an array, and then and if/then statement so that if the variable exists, check the box? or am I getting too complex with this or going in the complete opposite direction? not sure how to accomplish this. Thanks in advance
-
Date help...pulling info from db and seperating into 3 fields
shane85 replied to shane85's topic in PHP Coding Help
thanks alot. Solved! This board is extremely helpful. -
works, thank you
-
I think I figured out why it wasnt working...my variable $prospect_id wasnt being told to GET it in my query...now I have it as follows $qry = "UPDATE prospects SET representative='$representative', prospect_feeling='$prospect', firstname= '$f_name', lastname= '$l_name' WHERE prospect_id='.$_GET['prospect_id'].'"; but its giving me an error Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING before when I had it for prospect_id='37'"; it would work perfectly and update that row, but I want it to update from the variable $prospect_id that I need to use GET for I think?
-
hmm ok. Makes sence I have to include WHERE so that it knows to update the row. So for WHERE im putting prospect_id='$prospect_id' but its still having the same error. $qry = "UPDATE prospects SET(representative, prospect_feeling, firstname, lastname) VALUES('$representative','$prospect', '$f_name', '$l_name') WHERE prospect_id='$prospect_id'"; I even tried using a number instead of $prospect_id that co-insidees with my db for testing purposes, but still returns the query failed.