Jump to content

tezza42

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Everything posted by tezza42

  1. I am using the following piece of code to open a new window when a checkbox is checked... <INPUT type="checkbox" name="name" value="YES" onClick="window.open('/somepage.php?do=something&id=<?php echo $SOMEID["id"] ?>','','width=600,height=350,left=100,top=100,screenX=100,screenY=100')"> The page opens ok when the checkbox is ticked (checked). PROBLEM: The page opens again if the checkbox is un-ticked (un-checked). I just want to open the page if the checkbox is ticked only but not sure how to do this? OTHER INFO: Seperate checkboxes are dynamically created on the page for each id=<?php echo $SOMEID["id"] ?>
  2. I have a form on a page which is accessed when a user logs into their account. The form dynamically pulls bits of the users info from 2 tables in a mysql database, Tables (ITEMS) and Table (USERS). Table (USERS) holds the users info (NAME, EMAIL ETC) while Table (ITEMS) hold information about the users items for which they may have several of. When the form page is accessed all the users items from Table (ITEMS) are dynamically shown on the form with several radio buttons at the side of each item. The user can tick certain radio buttonss at the side of each item and click the send button. TRYING TO ACHIEVE... After the form is sent a thank you message is returned on the same page with details of the items and what radios were ticked. An Email of the same is sent to user with info of the items and what radios were ticked. An Email is also sent to me with same info of the items and what radios were ticked. WHAT I AM ACHIEVING SO FAR WITH CODE BELOW: The form page is ok showing all users items, radios, send button etc. The returned thank you page is fine showing items, what radios were checked etc. Even the email part is working sending an email to the user and myself. THE PROBLEM IS THAT A SEPERATE EMAIL IS SENT TO BOTH OF US FOR EACH ITEM THE USER HAS IN THE DATABASE. I JUST WANT ONE EMAIL SENDING TO BOTH OF US DETAILING ALL ITEMS. I realise this is because of the while statement in the call to the database which is looping the below code for each item thus sending an email for each item. What I can not suss out is how to send just the one email with all items on. Tried moving the closing loop bracket all over the place and parts of the code but to not avail. THE CODE: (some unecessary code removed from echo/thank you to simplify) <table width="100%"> <tr> <td class="bodytext"><strong>Name</strong></td> <td class="bodytext"><strong>Ref</strong></td> <td><strong>Status</strong></td> <td><strong>Type</strong></td> <td><strong>Date</strong></td> <td><strong>Extend</strong></td> <td><strong>Feature</strong></td> <td><strong>Offer</strong></td> </tr> <form action="example-this-page" method="post"> <input type="hidden" name="action" value="0"> <input type="hidden" name="id" value="<?php echo $_REQUEST["id"]; ?>"> <?php $sql = "SELECT * FROM ".$TABLES["items"]." WHERE user_id='".$_SESSION["UserAccount"]."'"; $sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql); while ($ITEMS = mysql_fetch_assoc($sql_result)) { $sql = "SELECT * FROM ".$TABLES["users"]." WHERE id='".$ITEMS["user_id"]."'"; $sql_resultT = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql); $USER=mysql_fetch_assoc($sql_resultT); ?> <? if (isset($action)) { $to = $USER["email"]; $mailheader = "From: $email\r\n"; $mailheader .= "Reply-To: $email\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $msg = "Dear ".stripslashes($USER["name"])."<br><br> <table><tr> <td><strong>Name</strong></td> <td><strong>Ref No</strong></td> <td><strong>Status</strong></td> <td><strong>Type</strong></td> <td><strong>Date</strong></td> <td><strong>Extend</strong></td> <td><strong>Feature</strong></td> <td><strong>Offer</strong></td> </tr> <tr> <td>".stripslashes($ITEMS["name"])."</td> <td>".stripslashes($ITEMS["ref"])."</td> <td>".stripslashes($ITEMS["status"])."</td> <td>".stripslashes($ITEMS["type"])."</td> <td>".stripslashes($ITEMS["date"])."</td> <td>".$_POST['extend']."</td> <td>".$_POST['feature']."</td> <td>".$_POST['offer']."</td> </tr> </table> "; mail($to, "subject", $msg, $mailheader) or die ("Failure"); mail("me@me.co.uk", "subject", $msg, $mailheader) or die ("Failure"); echo "<br /><br /><font size=2> <strong><center>Thank you!</center><br /> Your details of your request has been sent:</center><br /> "; }; ?> <tr> <td><?php echo stripslashes($ITEMS["name"]); ?></td> <td><?php echo stripslashes($ITEMS["ref"]); ?></td> <td><?php echo stripslashes($ITEMS["status"]); ?></td> <td><?php echo stripslashes($ITEMS["type"]); ?></td> <td><?php echo stripslashes($ITEMS["date"]); ?></td> <td><input type="radio" name="extend<?php echo stripslashes($ITEMS["id"]); ?>" value="No"> No <input type="radio" name="extend<?php echo stripslashes($ITEMS["id"]); ?>" value="Yes" /> Yes</td> <td><input type="radio" name="featured<?php echo stripslashes($ITEMS["id"]); ?>" value="No"> No <input type="radio" name="featured<?php echo stripslashes($ITEMS["id"]); ?>" value="Yes" /> Yes</td> <td><input type="radio" name="latedeal<?php echo stripslashes($ITEMS["id"]); ?>" value="No"> No <input type="radio" name="latedeal<?php echo stripslashes($ITEMS["id"]); ?>" value="Yes" /> Yes</td> </tr> <?php } ?> <tr> <td> <input type="submit" name="Submit" value="Send"></td> </tr></table> </form> </table>
  3. All I want is to be able to add a number, preferable in brackets, to the end of the filename but can't for the life of me, find out how to do it. Have searched for days on google and sifted through hundreds of websites but I can't seem to get a straight answer! Users are allowed to upload up to 30 image on our site (one at a time) for each property they have listed. Each property has its own id number when they initially register it. When a user uploads an image the image filename is currently changed to: (The property id)(hyphen)(date/time)(dot)(jpg) Example: 81-150520101530.jpg The above example is for an image file uploaded for property with id 81 on 15th May 2010 at 15:30 The major drawback with this is if a user manages to upload 2 photos within the same minute using (dmYHi) the first image is overwritten. If I add seconds to the filenme for example; (dmYHis) sometimes there will be an error and some images won't show because in the MySQL database the file may say: 81-15052010153022.jpg but in the image upload folder the image can sometimes be 1 second out example: 81-15052010153023.jpg There has been a difference of 1 second between the image being uploaded to the image folder and the name being inserted in the MySql datebas. Hence the not showing because it does not match the database filename. To solve this, short term, I have been using the rand() function like this rand(0,30) but I really really do not want to use this. Want I want is to add incremental numbers to each photo uploaded but haven't a clue how to do it. Please help anyone! I would like it like this: 1st photo name = 81-[1].jpg 2nd photo name = 81-[2].jpg 3rd photo name = 81-[3]jpg 4th photo name = 81-[4].jpg 5th photo name = 81-[5].jpg etc etc etc up to and including 81-[30].jpg It doesn't matter about the date but what I also need to keep in mind that the user may come back at a later time and upload more images for this property. Also user may delete certain images of the property at any time to change for new ones. Lets say they delete... 3rd photo name = 81-[3]jpg 4th photo name = 81-[4].jpg and upload 2 different images... Because [1],[2] and [4]to[30] already exist these two new image should be named: 81-[3]jpg 81-[4].jpg AGAIN. Current code looks like this: } elseif ($_REQUEST["do"]=='add_photo') { $ref=rand(0,30); $temp = upload_image($HTTP_POST_FILES['photo']['tmp_name'], $_REQUEST["id"].'-'.date('dmYHi').'['.$ref.'].jpg', $OPTIONS["path_accommodations"], $OPTIONS["pic_width"],$OPTIONS["pic_height"], ''); if ($temp==1) { $sql = "INSERT INTO ".$TABLES["accommodations_photos"]." SET accommodation_id='".$_REQUEST["id"]."', filename='".$_REQUEST["id"].'-'.date('dmYHi').'['.$ref.'].jpg'."', description='".mysql_escape_string($_REQUEST["description"])."'"; $sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql); };
  4. I would really appreciate any help anyone can offer updating fields in the same table on a monthly basis with Cron and/or PHP, my level is novice. I am on a hostgator shared server running: cpanel version 11.24.5-RELEASE Apache version 2.2.11 (Unix) PHP version 5.2.9 MySQL version 5.1.30 I have a table called stats with the following fields: id visit each time a certain id (page) is visited it inserts a count in the visit field. What I would like to do is at the end of each month at midnight copy the count in the visit field to a month field in the same table and reset the visit field to zero. Also at the end of each year at midnight copy the total for all month fields in a year field and reset the months to zero. So far I have added the following fields after visit field so the table now looks like this... id visit Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 2009 2010 2011 I have looked around the internet and found out how to do this manually by running the following SQL query in phpmyadmin: UPDATE stats SET `Jan`=`visit` This inserts the data in the visit field into the month of Jan field. This is ok if I can remember to do this at exactly midnight of each month but I am pretty sure I will forget one or not do it on time. I would like to automate this with a cron job or php which I am usure how to do. I am also unsure of how to set the original field (visit) back to zero. Basically this is what I would like but am sort of stuck. Midnight - Last day in January update Jan field with current visits and reset visit field to zero Midnight - Last day in February update Feb field with current visits and reset visit field to zero Midnight - Last day in March update Mar field with current visits and reset visit field to zero Midnight - Last day in April update Apr field with current visits and reset visit field to zero Midnight - Last day in May update May field with current visits and reset visit field to zero Midnight - Last day in June update Jun field with current visits and reset visit field to zero Midnight - Last day in July update Jul field with current visits and reset visit field to zero Midnight - Last day in August update Aug field with current visits and reset visit field to zero Midnight - Last day in September update Sep field with current visits and reset visit field to zero Midnight - Last day in October update Oct field with current visits and reset visit field to zero Midnight - Last day in November update Nov field with current visits and reset visit field to zero Midnight - Last day in December update Dec field with current visits and reset visit field to zero Midnight - Last day in December 2009 update 2009 field with the total from all months fields Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec BUT NOT RESET month fields to zero instead just overwriting each month as and when... For example: the data in month Jan (which would be the count for January 2009) would be overwritten on the midnight 31st January 2010 with data from the visit field. I hope this makes sense and someone can help me out to run on autopilot! Please remember I'm a novice! Thanks in advance.
×
×
  • 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.