Jump to content

webmaster1

Members
  • Posts

    607
  • Joined

  • Last visited

    Never

Everything posted by webmaster1

  1. <html> <body> <table><tr><th>Date</th></tr> <?php include("dbinfo.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); //$query="SELECT date FROM zevasce"; $query=" SELECT DATE_FORMAT(date, '%a') AS 'Day of Week', count(1) AS 'Count' FROM zevasce WHERE date >= DATE_SUB(NOW(), INTERVAL 1 MONTH) GROUP BY 1 ORDER BY DAYOFWEEK(date) "; $result=mysql_query($query); $num=mysql_num_rows($result); mysql_close(); $i=0; while ($i < $num) { $date=mysql_result($result,$i,"date"); ?> <tr><td><? echo $date; ?></td></tr> <? $i++; } ?> Hmm, thanks but I get this: Date Warning: mysql_result() [function.mysql-result]: date not found in MySQL result index 4 in /xxx Warning: mysql_result() [function.mysql-result]: date not found in MySQL result index 4 in /xxx
  2. Hi All, I have the following query to output data into a web page via PHP: I want to group the results by date i.e. 14th, 15th or 16th The column 'date' is of a datetime format. Does anyone know how to do this?
  3. After much trial and tribulation I've finally found a script that works perfectly with all email providers: http://www.4wordsystems.com/php_mail_attachment.php Problem solved!
  4. Well, the first script I posted (see original post) won't work with GMAIL and YAHOO MAIL. Premiso's suggestion of using PEAR won't work because I can't figure out what my user name is (see prev. post). I'm now trying this script though the email message won't send: <?php $fileatt = "some.pdf"; // Path to the file $fileatt_type = "application/pdf "; // File Type $fileatt_name = "Some PDF"; // Filename that will be used for the file as the attachment $email_from = "[email protected]"; // Who the email is from $email_subject = "2nd Script Test"; // The Subject of the email $email_txt = "Hopefully this second script works."; // Message that the email has in it $email_to = "[email protected]"; // Who the email is too $headers = "From: ".$email_from; $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $email_message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_message . "\n\n"; $data = chunk_split(base64_encode($data)); $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; $ok = @mail($email_to, $email_subject, $email_message, $headers); if($ok) { echo "<font face=verdana size=2>The file was successfully sent!</font>"; } else { die("Sorry but the email could not be sent. Please go back and try again!"); } ?> Can anyone help me with this?
  5. Apparently I just upload it and activate it with: I'm not too sure what it means by my_user_name though ???
  6. I've just downloaded the PEAR module for MIME mail but I'm not sure what to do with the file. Its a *.tar file: I work with CPANEL rather than having my computer set up as its own server.
  7. Will do. I'm beginning to think that the providers are identifying my mail as spam. The link below explains how PEAR can resolve the issue. http://www.webkami.com/programming/php/php-pear-mail-intro/sending-pear-mail-using-php-function-error.html I just don't like the idea of using huge copy and paste PHP scripts that I don't understand mostly because I don't kow how to begin editing them when I need to be specific.
  8. Hi All, Just ressurecting this thread to see if anyone knows why the script doesn't work with certain email providers. I just realised that the two it did work with (outlook and hotmail) are both microsoft.
  9. Quick addition: Just found out it doesn't work with eircom.net email users and a few others. What a bummer. I've taken it down for now :'(.
  10. After a little research the only problem I've come across online is whether or not the mail provider is configured to recieve html email. This shouldn't be an issue because the script I'm using has a plain text alternative message set up. Also it doesn't account for the lost attachment.
  11. That works great, thanks amclean. I've researched the mysqli extension since.
  12. Argh! I put an automated email application live in work but now I've found out that messes up when it sends to GMAIL. HOTMAIL and OUTLOOK work fine. Problem: The email message ends up being sent as the attachment and the original attachment is nowhere to be found. Is there a quick solution to this? <?php //define the receiver of the email $recipientemail = mysql_real_escape_string($_POST['recipientemail']); $to = ''.$recipientemail.''; //define the subject of the email $subject = 'Hello'; //create a boundary string. It must be unique //so we use the MD5 algorithm to generate a random hash $random_hash = md5(date('r', time())); //define the headers we want passed. Note that they are separated with \r\n $headers = "From: [email protected]\r\nReply-To: [email protected]"; //add boundary string and mime type specification $headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\""; //read the atachment file contents into a string, //encode it with MIME base64, //and split it into smaller chunks $attachment = chunk_split(base64_encode(file_get_contents('somepdf.pdf'))); //define the body of the message. ob_start(); //Turn on output buffering ?> --PHP-mixed-<?php echo $random_hash; ?> Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>" --PHP-alt-<?php echo $random_hash; ?> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit A message goes here --PHP-alt-<?php echo $random_hash; ?> Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit A message goes here --PHP-alt-<?php echo $random_hash; ?>-- --PHP-mixed-<?php echo $random_hash; ?> Content-Type: application/pdf; name="NTL_Pricing_Information.pdf" Content-Transfer-Encoding: base64 Content-Disposition: attachment <?php echo $attachment; ?> --PHP-mixed-<?php echo $random_hash; ?>-- <?php //copy current buffer contents into $message variable and delete current output buffer $message = ob_get_clean(); //send the email $mail_sent = @mail( $to, $subject, $message, $headers ); //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" echo $mail_sent ? "<p><font face='arial' size='2'><center>Thank you <b>$salesagentname</b>. The desired mail and document has been sent to <b>$recipientemail</b> for <b>$recipientname</b>.</font></center></p>" : "<p><font face='arial' size='2'><center>This mail <b>did not</b> send. Please try again!</p></font></center></p>"; ?>
  13. Goddamn you amcleam and your misleading post! Just kidding . Back to google it is then. I'll crack this, don't worry. Those ninja-like dropdowns can't elude me forever.
  14. Adjusted accordingly. Still stuck with an empty drop down though <?php include("dbinfo.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); echo '<select>'; $query="SELECT urn, date FROM zevasce"; //$result=$mysqli->query($query); $result=mysql_query($query); while ($row=$result->fetch_object()) { echo '<option value="'.$row->urn.'">'.$row->date."</option>\n"; } echo '</select>'; ?>
  15. That makes sense. I was more confused at what it was doing but from both of your explanations its more of a convention than an action. Any ideas where I went wrong editing your code? The dropdown is empty. <?php include("dbinfo.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); echo '<select>'; $query="SELECT urn, date FROM zevasce"; $result=$mysqli->query($query); while ($row=$result->fetch_object()) { echo '<option value="'.$row->urn.'">'.$row->date."</option>\n"; } echo '</select>'; ?>
  16. Could you clarify this? The end user only see's one column populated in the dropdown. I can't seem to work out why we're calling on two as per the query. I know this is the correct way but I just don't understand it. @Mchl: Ah, I see. Very neat indeed. Still at the dropdown junction though
  17. @amclean Thanks for that. Its a neater starting point than I've come across so far. I don't understand the query. Is that a typo? How can I select a column from a column? Might this work just as well SELECT column1, column2 FROM table? I also can't grasp why I need to pull in two columns when I'm only displaying one. <?php include("dbinfo.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); echo '<select>'; $query="SELECT urn, recipientname FROM zevasce"; $result=$mysqli->query($query); while ($row=$result->fetch_object()) { echo '<option value="'.$row->urn.'">'.$row->recipientname."</option>\n"; } echo '</select>'; ?> I end up with an empty dropdown @Mchl Thanks for the resource. It looks nasty . I was hoping I could group by date based on the date of the month. E.g. Display all records submitted on the 17th Jan without discriminating the results by time. One step at a time though. I need to master the ancient ways of the dropdown first.
  18. Hi All, I've built a modest mailing CRM and so far I'm outputting the my entire mySQL table into a web page as a crude report of sorts. I want to filter the results by date but I'm not sure how to go about it since I'm using datetime which means there all unique. I'd prefer a range (lets say a day) rather than populating every single date and time in the dropdown. Can anyone help me in A) creating a php dynamic dropdown and B) how to limit the results to a range? I can only get as far as populating the results in the dropdown and thats it. I can't find one tutorial that properly explains the mechanics of the code. Is there a conspiracy against newbs unlocking the secrets of the mighty php dropdown?
  19. I've tried working with this script I found through google but it seems incomplete. <?php ... mysql cnx code ... $sql="SELECT id, thing FROM table"; $result=mysql_query($sql); $options=""; while ($row=mysql_fetch_array($result)) { $id=$row["id"]; $thing=$row["thing"]; $options.="<OPTION VALUE=\"$id\">".$thing; } ?> ... html code ... <SELECT NAME=thing> <OPTION VALUE=0>Choose <?=$options?> </SELECT> ... I know this seems like a basic example though I can't actually work out whats going on. Why is there a need for it to call on the id when its only populating one variable?
  20. Does anyone know of a solid tutorial to populate results into a dropdown menu?
  21. All the examples I find only show how to populate one dropdown. I'm usually okay following the step by steps but I get stuck when it comes to combining different snippets of code.
  22. Phew. I thought I had explained it all arse ways. I would definatley apreciate any help you can offer with the dropdown lists and IF, ELSE IF statements. I haven't worked with either before.
  23. I still can't find anything decent online. Its wrecking my head.
  24. The provided code displays the contents of the table in its entirety using SELECT * The columns of the table are as follows: I want all the distinct values of Date to list in the first dropdown and and the distinct values of Sales Agent Name in the second dropdown. Finally depending on which options the user selects from each drop down the results will be listed accordingly on the same page.
  25. Hi All, I'm outputting the contents of a mySQL table into a web page using a simple SELECT * statement. I want to be able to filter results by date and/or name so I presume I need a dropdown for each and one submit button. From what I understand I need to do the following: [*]Populate the distinct dates and names in their respective dropdowns [*]Filter whats to be displayed depending on whats selected in the two dropdown menus Can anyone point me in the right direction? When I search online I find help forums with partial snippets of code rather than any decent tutorials. Heres the code I'm using that SELECTS * <?php session_start(); if (!$_SESSION['logged']) { header("location: loginfl.php"); } else { ?> <html> <body> <a href='admin.php'>Return to Administration Home</a> <table border="1" cellspacing="2" cellpadding="2"> <tr> <th><font face="Arial, Helvetica, sans-serif">Date</font></th> <th><font face="Arial, Helvetica, sans-serif">URN</font></th> <th><font face="Arial, Helvetica, sans-serif">Recipient Email</font></th> <th><font face="Arial, Helvetica, sans-serif">Recipient Name</font></th> <th><font face="Arial, Helvetica, sans-serif">Sales Agent Name</font></th> </tr> <? include("dbinfo.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM zevasce ORDER BY date"; $result=mysql_query($query); $num=mysql_num_rows($result); mysql_close(); $i=0; while ($i < $num) { $date=mysql_result($result,$i,"date"); $urn=mysql_result($result,$i,"urn"); $recipientemail=mysql_result($result,$i,"recipientemail"); $recipientname=mysql_result($result,$i,"recipientname"); $salesagentname=mysql_result($result,$i,"salesagentname"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><? echo $date; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $urn; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $recipientemail; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $recipientemail; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $salesagentname; ?></font></td> </tr> <? $i++; } echo "</table>"; } ?>
×
×
  • 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.