Jump to content

tryingtolearn

Members
  • Posts

    293
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by tryingtolearn

  1. This is what I started with but both variables always come back as 0 // Check for a primary Image URL. if (isset($_GET['img1'])) { // Page is first accessed. $purl = $_GET['img1']; } else { // Big problem! $purl = 0; } // Check for a alternate Image URL. if (isset($_GET['img2'])) { // Page is first accessed. $aurl = $_GET['img2']; } else { // Big problem! $aurl = 0; } if (($purl == 0)||($aurl == 0)) { // Do not proceed! header("content-type: image/jpeg"); $sig_loc = "noimg.jpg"; $sig = imagecreatefromjpeg($sig_loc); imagejpeg($sig); exit(); // Terminate execution of the script. }
  2. Im wondering if it is possible to have an image tag provide two different urls to a php page that will check if url to image 1 exists - if it does, display it but if it doesnt go to url 2 and display it. So the html would be something like <img src="www.alternate_img.php?img1=www.url_to_img_1&img2=www.url_to_img_2"> how do you pick up the ?img1=www.url_to_img_1&img2=www.url_to_img_2 in alternate_img.php to check if they exist to display the image in the html img tag? Can you do something like that?
  3. Thanks, still doesnt seem to match it though. Ill keep looking.
  4. I have to extract info from two different type of paragraph tags on a page The first is <p><a href="link.html">text</a></p> The second is <p class="row"> <span class="hh" id="rag"> </span> <a href="link.html">text -</a></p> using <[p^>]+> gets the first kind but Im having problems matching the tag with an attribute I need to get everything inbetween the paragraph tags from both styles. any help would be appreciated
  5. I am parsing an rss feed and its working well but there is line that looks different and Im trying to figure out how I can get the info from it. The feed would look like this <item> <title><![CDATA[My Page Title]]></title> <link><![CDATA[http://sitename.com]]></link> <description><![CDATA[<table><tr><td>Description HTML Here</td></tr></table>]]></description> <pubDate>Fri, 06 Mar 2009 15:00:28 PST</pubDate> <rx:Category xmlns:rx="urn:site:apis:Components"><![CDATA[My Category Name]]></rx:Category> </item> Notice the line <rx:Category xmlns:rx="urn:site:apis:Components"><![CDATA[My Category Name]]></rx:Category> I need to display the My Category Name part The php code I am using is $doc = new DOMDocument(); $doc->load('xmlsource.xml'); $arrFeeds = array(); foreach ($doc->getElementsByTagName('item') as $node) { $itemRSS = array ( 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue, 'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue, 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue, 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue ); array_push($arrFeeds, $itemRSS); } foreach ($arrFeeds AS $v){ foreach($v as $k){ echo "$k<br />"; } } It gets the title description link and pub date but I dont know what I can add to get the category as well Thanks for any help.
  6. Well this is what I eventually ended up with from a different tutorial. (If anyone is following or in need) Seems to be working but I wouldnt know if there was an error in it as can be seen from my previous code. <script type="text/javascript" language="javascript"> var max_vent = 15; function inDest(dest, text, value) { var opt, o = 0; while (opt = dest[o++]) if (opt.value == value && opt.text == text) return true; return o > max_vent; } function toDest(s, dest) { var opt, o = 0; while (opt = s[o++]) if (opt.selected && !inDest(dest, opt.text, opt.value)) dest.options[dest.length] = new Option(opt.text,opt.value); } function moveSelected (select, down) { if (select.selectedIndex != -1) { if (down) { if (select.selectedIndex != select.options.length - 1) var x = select.selectedIndex + 1; else return; } else { if (select.selectedIndex != 0) var x = select.selectedIndex - 1; else return; } var swapOption = new Object(); swapOption.text = select.options[select.selectedIndex].text; swapOption.value = select.options[select.selectedIndex].value; swapOption.selected = select.options[select.selectedIndex].selected; swapOption.defaultSelected = select.options[select.selectedIndex].defaultSelected; for (var property in swapOption) { select.options[select.selectedIndex][property] = select.options[x][property]; select.options[x][property] = swapOption[property]; } } } function delSelected(dest) { var opt, o = 0; while (opt = dest[o++]) if (opt.selected) dest[o-1] = null; } function setHidden(f) { var destVals = new Array(), opt = 0, separator = '|', d = f.dest; while (d[opt]) destVals[opt] = d[opt++].value; f.destItems.value = separator + destVals.join(separator) + separator; alert('destItems.value = ' + f.destItems.value); return true; } </script>
  7. I appreciate that But is there a way to make it work too??
  8. Thanks But that doesnt transfer the list box options. ??? I did some reading and found anothe rexample so Im going to try and figure that one out.
  9. Hi all, I am trying to piece together two seperate examples to make a form that will Transer items in a list box to another listbox Then in the second list box allow them to sort the order to their preference. Everything is working until I get to the sorting If I try to move an item up, I cant move it into the top position, it will sort of duplicate itself in the listbox. Not exactly sure what the code means and does so I would appreciate any guidance on where I am screwing up. <script language="javascript" type="text/javascript"> function move(fbox, tbox) { var arrFbox = new Array(); var arrTbox = new Array(); var arrLookup = new Array(); var i; for (i = 0; i < tbox.options.length; i++) { arrLookup[tbox.options[i].text] = tbox.options[i].value; arrTbox[i] = tbox.options[i].text; } var fLength = 0; var tLength = arrTbox.length; for(i = 0; i < fbox.options.length; i++) { arrLookup[fbox.options[i].text] = fbox.options[i].value; if (fbox.options[i].selected && fbox.options[i].value != "") { arrTbox[tLength] = fbox.options[i].text; tLength++; } else { arrFbox[fLength] = fbox.options[i].text; fLength++; } } fbox.length = 0; tbox.length = 0; var c; for(c = 0; c < arrFbox.length; c++) { var no = new Option(); no.value = arrLookup[arrFbox[c]]; no.text = arrFbox[c]; fbox[c] = no; } for(c = 0; c < arrTbox.length; c++) { var no = new Option(); no.value = arrLookup[arrTbox[c]]; no.text = arrTbox[c]; tbox[c] = no; } } </script> <script type="text/javascript"> function moveO(listform,w){ var tolist=document.getElementsByName(listform)[0]; var opt=tolist.options[tolist.selectedIndex]; if(w=='up'){ var prev=opt.previousSibling; while(prev&&prev.nodeType!=1){ prev=prev.previousSibling; } prev?tolist.insertBefore(opt,prev):tolist.appendChild(opt) } else{ var next=opt.nextSibling; while(next&&next.nodeType!=1){ next=next.nextSibling; } if(!next){tolist.insertBefore(opt,tolist.options[0])} else{ var nextnext=next.nextSibling; while(next&&next.nodeType!=1){ next=next.nextSibling; } nextnext?tolist.insertBefore(opt,nextnext):tolist.appendChild(opt); } } } </script> <form name="listform"> <table><tr><td> <select multiple size="15" name="fromlist" style="width:100"> <option value="1">Event 1</option> <option value="2">Event 2</option> <option value="3">Event 3</option> <option value="4">Event 4</option> <option value="5">Event 5</option> <option value="6">Event 6</option> <option value="7">Event 7</option> <option value="8">Event 8</option> <option value="9">Event 9</option> <option value="10">Event 10</option> <option value="11">Event 11</option> <option value="12">Event 12</option> <option value="13">Event 13</option> <option value="14">Event 14</option> <option value="15">Event 15</option> </select> </td> <td align="center" valign="middle"> <input type="button" onClick="move(this.form.tolist,this.form.fromlist)" value="<<"> <input type="button" onClick="move(this.form.fromlist,this.form.tolist)" value=">>"> </td> <td> <select multiple size="15" name="tolist" style="width:150"> </select> </td> <td> <input type="button" value="UP" onclick="moveO('tolist','up')" /> <br /> <input type="button" value="DOWN" onclick="moveO('tolist','down')" /> </td> </tr></table> </form>
  10. Well, I'll be damned! Learn something new every day Thanks Mchl
  11. I should add The table updates fine if I update it directly in phpmyadmin Dont know if that helps narrow things down a bit.
  12. Not sure if this needs to be in this forum or the php help forum Sorry if this is the wrong spot. I have an UPDATE Query that is failing when I include two enum fields in the query This updates the record w/ no problem $query = "UPDATE page2 SET title='$t', info='$a', cat_id='$ca' WHERE id=$editid"; $result = mysql_query($query); But when I do it like this(Show and access are enum fields) $query = "UPDATE page2 SET title='$t', info='$a', cat_id='$ca', show='$sho', access='$ac' WHERE id=$editid"; $result = mysql_query($query); I get this error This query worked on a server running an older version of mysql - this just started when I moved to this server running MYSQL Version 5.0.51a Any ideas?
  13. Thanks Crayon Violet That worked also Thorpe - If it returns true it is going to 1 set of additional checks, if false it goes to a different set of checks, it is sorting the array so even if it starts at 13 - its just going to take the five integers and see if they are in consecutive order. Thanks for the help, once again seems like I was making harder than it needed to be haha
  14. Thanks genericnumber1 I will try it out.
  15. Maybe I am missing it but say you have an array that contains 15 numbers array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) when a page loads it is going to use 5 of the numbers at random out of the array, could be 1 - 2 - 6 - 9 - 11 or 8 - 11 - 12 - 13 -14 but what I need to find is if those #s are in any consecutive order ex 1-2-3-4-5 or 7-8-9-10-11 Ive read through the array function page but dont see a anything for this, is there an array function that does this?
  16. Only problem is it doesnt get added to the array. But the more Im thinking about it Id run into the whole problem of unchecking images then. Then Id have to get it out of the array Ill just set it up to handle each page individually I guess - straight php.
  17. The class provides a few different links Jump to page Next Display X numbers per page Then a numbered set 1,2,34,...917 All links or it goes to the page once the option is selected from the dropdown. they are generated from the following codes in the class $this->return = ($this->current_page != 1 And $this->items_total >= 10) ? "<a class=\"paginate\" href=\"$_SERVER[php_SELF]?page=$prev_page&ipp=$this->items_per_page$this->querystring\">« Previous</a> ":"<span class=\"inactive\" href=\"#\">« Previous</span> "; OR $this->return .= ($i == $this->current_page And $_GET['page'] != 'All') ? "<a title=\"Go to page $i of $this->num_pages\" class=\"current\" href=\"#\">$i</a> ":"<a class=\"paginate\" title=\"Go to page $i of $this->num_pages\" href=\"$_SERVER[php_SELF]?page=$i&ipp=$this->items_per_page$this->querystring\">$i</a> "; OR $this->return .= (($this->current_page != $this->num_pages And $this->items_total >= 10) And ($_GET['page'] != 'All')) ? "<a class=\"paginate\" href=\"$_SERVER[php_SELF]?page=$next_page&ipp=$this->items_per_page$this->querystring\">Next »</a>\n":"<span class=\"inactive\" href=\"#\">» Next</span>\n"; $this->return .= ($_GET['page'] == 'All') ? "<a class=\"current\" style=\"margin-left:10px\" href=\"#\">All</a> \n":"<a class=\"paginate\" style=\"margin-left:10px\" href=\"$_SERVER[php_SELF]?page=1&ipp=All$this->querystring\">All</a> \n"; OR $this->return .= ($i == $this->current_page) ? "<a class=\"current\" href=\"#\">$i</a> ":"<a class=\"paginate\" href=\"$_SERVER[php_SELF]?page=$i&ipp=$this->items_per_page$this->querystring\">$i</a> "; OR $this->return .= "<a class=\"paginate\" href=\"$_SERVER[php_SELF]?page=1&ipp=All$this->querystring\">All</a> \n"; OR this for the jump to sections function display_items_per_page() { $items = ''; $ipp_array = array(10,25,50,100,'All'); foreach($ipp_array as $ipp_opt) $items .= ($ipp_opt == $this->items_per_page) ? "<option selected value=\"$ipp_opt\">$ipp_opt</option>\n":"<option value=\"$ipp_opt\">$ipp_opt</option>\n"; return "<span class=\"paginate\">Items per page:</span><select class=\"paginate\" onchange=\"window.location='$_SERVER[php_SELF]?page=1&ipp='+this[this.selectedIndex].value+'$this->querystring';return false\">$items</select>\n"; } function display_jump_menu() { for($i=1;$i<=$this->num_pages;$i++) { $option .= ($i==$this->current_page) ? "<option value=\"$i\" selected>$i</option>\n":"<option value=\"$i\">$i</option>\n"; } return "<span class=\"paginate\">Go To Page:</span><select class=\"paginate\" onchange=\"window.location='$_SERVER[php_SELF]?page='+this[this.selectedIndex].value+'&ipp=$this->items_per_page$this->querystring';return false\">$option</select>\n"; } But I dont want the checkbox value added to the URL The results will contain somewhere in the neighborhood of 9000+ results The checkbox will select those to be deleted If I add them to the URL that could get pretty long.
  18. It is a page reload I was going to keep adding it to the url but this database set has over 9000 items That could get to be a pretty long url! Here is the php class that paginates the mysql results class Paginator{ var $items_per_page; var $items_total; var $current_page; var $num_pages; var $mid_range; var $low; var $high; var $limit; var $return; var $default_ipp = 10; var $querystring; function Paginator() { $this->current_page = 1; $this->mid_range = 7; $this->items_per_page = (!empty($_GET['ipp'])) ? $_GET['ipp']:$this->default_ipp; } function paginate() { if($_GET['ipp'] == 'All') { $this->num_pages = ceil($this->items_total/$this->default_ipp); $this->items_per_page = $this->default_ipp; } else { if(!is_numeric($this->items_per_page) OR $this->items_per_page <= 0) $this->items_per_page = $this->default_ipp; $this->num_pages = ceil($this->items_total/$this->items_per_page); } $this->current_page = (int) $_GET['page']; // must be numeric > 0 if($this->current_page < 1 Or !is_numeric($this->current_page)) $this->current_page = 1; if($this->current_page > $this->num_pages) $this->current_page = $this->num_pages; $prev_page = $this->current_page-1; $next_page = $this->current_page+1; if($_GET) { $args = explode("&",$_SERVER['QUERY_STRING']); foreach($args as $arg) { $keyval = explode("=",$arg); if($keyval[0] != "page" And $keyval[0] != "ipp") $this->querystring .= "&" . $arg; } } if($_POST) { foreach($_POST as $key=>$val) { if($key != "page" And $key != "ipp") $this->querystring .= "&$key=$val"; } } if($this->num_pages > 10) { $this->return = ($this->current_page != 1 And $this->items_total >= 10) ? "<a class=\"paginate\" href=\"$_SERVER[php_SELF]?page=$prev_page&ipp=$this->items_per_page$this->querystring\">« Previous</a> ":"<span class=\"inactive\" href=\"#\">« Previous</span> "; $this->start_range = $this->current_page - floor($this->mid_range/2); $this->end_range = $this->current_page + floor($this->mid_range/2); if($this->start_range <= 0) { $this->end_range += abs($this->start_range)+1; $this->start_range = 1; } if($this->end_range > $this->num_pages) { $this->start_range -= $this->end_range-$this->num_pages; $this->end_range = $this->num_pages; } $this->range = range($this->start_range,$this->end_range); for($i=1;$i<=$this->num_pages;$i++) { if($this->range[0] > 2 And $i == $this->range[0]) $this->return .= " ... "; // loop through all pages. if first, last, or in range, display if($i==1 Or $i==$this->num_pages Or in_array($i,$this->range)) { $this->return .= ($i == $this->current_page And $_GET['page'] != 'All') ? "<a title=\"Go to page $i of $this->num_pages\" class=\"current\" href=\"#\">$i</a> ":"<a class=\"paginate\" title=\"Go to page $i of $this->num_pages\" href=\"$_SERVER[php_SELF]?page=$i&ipp=$this->items_per_page$this->querystring\">$i</a> "; } if($this->range[$this->mid_range-1] < $this->num_pages-1 And $i == $this->range[$this->mid_range-1]) $this->return .= " ... "; } $this->return .= (($this->current_page != $this->num_pages And $this->items_total >= 10) And ($_GET['page'] != 'All')) ? "<a class=\"paginate\" href=\"$_SERVER[php_SELF]?page=$next_page&ipp=$this->items_per_page$this->querystring\">Next »</a>\n":"<span class=\"inactive\" href=\"#\">» Next</span>\n"; $this->return .= ($_GET['page'] == 'All') ? "<a class=\"current\" style=\"margin-left:10px\" href=\"#\">All</a> \n":"<a class=\"paginate\" style=\"margin-left:10px\" href=\"$_SERVER[php_SELF]?page=1&ipp=All$this->querystring\">All</a> \n"; } else { for($i=1;$i<=$this->num_pages;$i++) { $this->return .= ($i == $this->current_page) ? "<a class=\"current\" href=\"#\">$i</a> ":"<a class=\"paginate\" href=\"$_SERVER[php_SELF]?page=$i&ipp=$this->items_per_page$this->querystring\">$i</a> "; } $this->return .= "<a class=\"paginate\" href=\"$_SERVER[php_SELF]?page=1&ipp=All$this->querystring\">All</a> \n"; } $this->low = ($this->current_page-1) * $this->items_per_page; $this->high = ($_GET['ipp'] == 'All') ? $this->items_total:($this->current_page * $this->items_per_page)-1; $this->limit = ($_GET['ipp'] == 'All') ? "":" LIMIT $this->low,$this->items_per_page"; } function display_items_per_page() { $items = ''; $ipp_array = array(10,25,50,100,'All'); foreach($ipp_array as $ipp_opt) $items .= ($ipp_opt == $this->items_per_page) ? "<option selected value=\"$ipp_opt\">$ipp_opt</option>\n":"<option value=\"$ipp_opt\">$ipp_opt</option>\n"; return "<span class=\"paginate\">Items per page:</span><select class=\"paginate\" onchange=\"window.location='$_SERVER[php_SELF]?page=1&ipp='+this[this.selectedIndex].value+'$this->querystring';return false\">$items</select>\n"; } function display_jump_menu() { for($i=1;$i<=$this->num_pages;$i++) { $option .= ($i==$this->current_page) ? "<option value=\"$i\" selected>$i</option>\n":"<option value=\"$i\">$i</option>\n"; } return "<span class=\"paginate\">Go To Page:</span><select class=\"paginate\" onchange=\"window.location='$_SERVER[php_SELF]?page='+this[this.selectedIndex].value+'&ipp=$this->items_per_page$this->querystring';return false\">$option</select>\n"; } function display_pages() { return $this->return; } }
  19. I take it AJAX isnt the way to go for this... Anyone have any ideas on what would be the way to go?
  20. Totally new to this - sorry if this belongs in the php forum. But I know it cant be done in php so I am checking here. I have a paginated result from a mysql table Each item has a checkbox I need to get the values of each item checked but was running into problems once the user goes through the pagination (I lose the values from the previous page(s). So I was thinking that I could add the value of the checkbox to a php array when the user checks the box then when they are all done and click submit I can then get all the values in the array and process them. 1. Is this possible? 2. If so, is that what ajax is used for? 3. if so - How would I go about it? I would have thought this would be a common thing but numerous searches havent turned up much at all. Thanks for any insight or direction.
  21. Got it figured out, Wasnt the script but with the pipe I set up under the forwarder. I had "|/home/USERNAME/domains/DOMAIN_NAME/public_html/PATH/TO/SCRIPT.php" But it needed to be "|/usr/local/bin/php /home/USERNAME/domains/DOMAIN_NAME/public_html/PATH/TO/SCRIPT.php"
  22. Im trying to gather the info from bounced emails I have all the replys being sent to an email address then using a script to get the info from the bounced emails Mainly which address it could not be delivered to But the only variable I get right now is the subject, everything else is blank Any ideas on what I may be doing wrong? This test is just set up to email me the results Sidenote - The imap functions looked like the way to go but it doesnt seem like that is installed on my host. #!/usr/local/php5/bin/php <?php // read from stdin $fd = fopen("php://stdin", "r"); $email = ""; while (!feof($fd)) { $email .= fread($fd, 1024); } fclose($fd); // handle email $lines = explode("\n", $email); // empty vars $from = ""; $subject = ""; $headers = ""; $message = ""; $splittingheaders = true; for ($i=0; $i < count($lines); $i++) { if ($splittingheaders) { // this is a header $headers .= $lines[$i]."\n"; // look out for special headers if (preg_match("/^Subject: (.*)/", $lines[$i], $matches)) { $subject = $matches[1]; } if (preg_match("/^From: (.*)/", $lines[$i], $matches)) { $from = $matches[1]; } } else { // not a header, but message $message .= $lines[$i]."\n"; } if (trim($lines[$i])=="") { // empty line, header section has ended $splittingheaders = false; } } include('Mail.php'); include('Mail/mime.php'); // Constructing the email $sender = "//fromaddress"; $recipient = "//toaddress"; $subject = "Bounce Report"; // Subject for the email //$text = 'Bounce Report.'; // Text version of the email $html = '<html><body><p>'.$from.' - '.$subject.'</p></body></html>'; // HTML version of the email $crlf = "\n"; $headers = array( 'From' => $sender, 'Return-Path' => $sender, 'Subject' => $subject ); // Creating the Mime message $mime = new Mail_mime($crlf); // Setting the body of the email $mime->setTXTBody($text); $mime->setHTMLBody($html); // Set body and headers ready for base mail class $body = $mime->get(); $headers = $mime->headers($headers); // SMTP params $smtp_params["host"] = "host"; // SMTP host $smtp_params["port"] = "port";//587 $smtp_params["auth"] = true; $smtp_params["username"] = "un"; $smtp_params["password"] = "pw"; // Sending the email using smtp $mail =& Mail::factory("smtp", $smtp_params); $result = $mail->send($recipient, $headers, $body); if($result) { echo("Your message has been sent!"); } else { echo("Your message was not sent: " . $result); } ?>
  23. I use a form that takes the # columns # of rows Border Width Cellpadding Cellspacing and Table width The php part then takes those inputs and creates the table using this, print "<table border=\"$border\" cellpadding=\"$cp\" cellspacing=\"$cs\" width=\"$width$ms\">\n"; for ($r=0; $r<$row; $r++) { print "<tr>\n"; if($r != $row) { for ($i=0; $i<$col; $i++) { $cell = $i+1; print "<td>$cell</td>\n"; } if($i == $col) { print "</tr>\n"; } } } print "</table>\n"; Here is the whole shabang that you can taylor to your needs. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Dyna Table</title> <style type="text/css"> html,body{margin:0;padding:0} body{font: 76% arial,sans-serif;text-align:center} p{margin:0 10px 10px} a{display:block;color: #981793;padding:10px} div#header h1{height:80px;line-height:50px;margin:0; padding-left:10px;background: #cccccc;color: #202020} div#container{text-align:left; border: 3px solid #202020;} div#content p{line-height:1.4} div#navigation{background:#404040; color: #cccccc;} div#extra{background:#cccccc; color: #404040; border-bottom: 1px solid #202020;} div#footer{background: #cccccc;color: #404040} div#footer p{margin:0;padding:5px 10px} div#container{width:700px;margin:0 auto} div#content{float:left;width:500px} div#navigation{float:right;width:200px} div#extra{clear:both;width:100%} </style> </head> <body> <div id="container"> <div id="header"><h1>Dynamic Table Creation</h1></div> <div id="wrapper"> <div id="content"> <p> <?php if (isset($_POST['submitted'])) { // Handle the form. // Check for Columns. if (!empty($_POST['columns'])) { $col = $_POST['columns']; } else { $col = FALSE; echo '<p><font color="red" size="+1">Please enter the amount of columns you need!</font></p>'; } // Check for Rows. if (!empty($_POST['rows'])) { $row = $_POST['rows']; } else { $row = FALSE; echo '<p><font color="red" size="+1">Please enter the amount of rows you need!</font></p>'; } // Check for border width. if (!empty($_POST['border'])) { $border = $_POST['border']; } else { $border = 0; } // Check for table width. if (!empty($_POST['width'])) { $width = $_POST['width']; } else { $width = 100; } // Check for cell Padding. if (!empty($_POST['cp'])) { $cp = $_POST['cp']; } else { $cp = 0; } // Check for cell Spacing. if (!empty($_POST['cs'])) { $cs = $_POST['cs']; } else { $cs = 0; } // Check for cell Spacing. if ($_POST['meas'] == "perc") { $ms = "%"; } else { $ms = ""; } if ($col && $row) { print "<table border=\"$border\" cellpadding=\"$cp\" cellspacing=\"$cs\" width=\"$width$ms\">\n"; for ($r=0; $r<$row; $r++) { print "<tr>\n"; if($r != $row) { for ($i=0; $i<$col; $i++) { $cell = $i+1; print "<td>$cell</td>\n"; } if($i == $col) { print "</tr>\n"; } } } print "</table>\n"; echo"<textarea name=\"code\" rows=\"15\" cols=\"50\" >"; print "<table border=\"$border\" cellpadding=\"$cp\" cellspacing=\"$cs\" width=\"$width$ms\">\n"; for ($r=0; $r<$row; $r++) { print "<tr>\n"; if($r != $row) { for ($i=0; $i<$col; $i++) { print "<td></td>\n"; } if($i == $col) { print "</tr>\n"; } } } print "</table>\n"; echo"</textarea>"; } } ?> </p> </div> </div> <div id="navigation"> <p><strong>Set your table settings in the form inputs</strong> listed below. </p> </div> <div id="extra"> <p><strong>Table Settings</strong> <br /> <form action="index.php" method="post"> <p><b># of Columns:</b><br /> <input type="text" name="columns" size="15" maxlength="15" value="<?php if (isset($_POST['columns'])) echo $_POST['columns']; ?>" /></p> <p><b># of Rows:</b><br /> <input type="text" name="rows" size="15" maxlength="15" value="<?php if (isset($_POST['rows'])) echo $_POST['rows']; ?>" /> </p> <p><b>Border Width:</b><br /> <input type="text" name="border" size="15" maxlength="15" value="<?php if (isset($_POST['border'])) echo $_POST['border']; ?>" /> </p> <p><b>Cell Padding:</b><br /> <input type="text" name="cp" size="15" maxlength="15" value="<?php if (isset($_POST['cp'])) echo $_POST['cp']; ?>" /></p> <p><b>Cell Spacing:</b><br /> <input type="text" name="cs" size="15" maxlength="15" value="<?php if (isset($_POST['cs'])) echo $_POST['cs']; ?>" /> </p> <p><b>Table Width:</b><br /> <input type="text" name="width" size="15" maxlength="15" value="<?php if (isset($_POST['width'])) echo $_POST['width']; ?>" /> % <input name="meas" type="radio" value="perc"> or PX <input name="meas" type="radio" value="pix"></p> <div align="left"><input type="submit" name="submit" value="Create" /></div> <input type="hidden" name="submitted" value="TRUE" /> </form> </p> </div> <div id="footer"><p>Sample Code Only</p></div> </div> </body> </html>
  24. Hi all, Trying again, Hoping someone can shed some light on this question. Im writing a very basic email function I was using mail() but when it was sent - all mails were sent but the page itself would timeout I hit refresh (Which was a big mistake) and it sent all the emails out again! So I rewrote it to use PEAR but I need to pass the recipients email as a variable to track who it was sent to. Using PEAR I have an array of recipients Is it possible to pass the individual email in a variable in the message itself? If you look at the $html variable in the code below, Where it says ***NEEDS TO BE EMAIL ADDRESS*** Thats where I need the single email so when the email is opened that 1 email address gets inserted into the DB I tried adding $html in a foreach but only got the last email address Then I tried just passing the $recipients variable but anly got ARRAY in the DB Any help would be appreciated include('Mail.php'); include('Mail/mime.php'); // Constructing the email $sender = "from address"; // Your name and email address $track_id = date("D M j Y - g:i a"); $recipients = array(); $query = "SELECT * FROM mailer WHERE mail_receive='Yes'"; $result = @mysql_query ($query); // Run the query. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $recipients[] = $row['mail_email']; // Recipient name and email address } $html = "<img src=\"http://www.site.com/tracksent.php?t=$em&e=***NEEDS TO BE EMAIL ADDRESS***&track_id=$track_id\" width=\"1\" height=\"1\"><br />$message"; $subject = $em; // Subject for the email $text = 'Your eMail will only accept text messages.To see this message as intended visit this link '; $crlf = "\n"; $headers = array( 'From' => $sender, 'Return-Path' => $sender, 'Subject' => $subject ); // Creating the Mime message $mime = new Mail_mime($crlf); // Setting the body of the email $mime->setTXTBody($text); $mime->setHTMLBody($html); // Add an attachment //$file = "Hello World!"; //$file_name = "Hello text.txt"; //$content_type = "text/plain"; //$mime->addAttachment ($file, $content_type, $file_name, 0); // Set body and headers ready for base mail class $body = $mime->get(); $headers = $mime->headers($headers); // SMTP params $smtp_params["host"] = "smtp.site.com"; // SMTP host $smtp_params["port"] = "587"; $smtp_params["auth"] = true; $smtp_params["username"] = "uname"; $smtp_params["password"] = "upass"; // Sending the email using smtp $mail =& Mail::factory("smtp", $smtp_params); $result = $mail->send($recipients, $headers, $body); if($result) { echo("Your message has been sent!"); echo"<h3>$em was sent to:</h3>"; foreach($recipients as $k => $value){ echo "$value <br />"; $query = "INSERT INTO sent (title, sent_to, track_id, track_key) VALUES ('$em', '$value', '$track_id', '$k')"; $result = @mysql_query ($query); // Run the query. } } else { echo("Your message was not sent: " . $result); }
  25. I finally figured out using pear intead of mail() But here is my problem, When using mail() I was sending an image w/ the email to track who opens it etc... Now with pear, I dont have an individual tag to id each email because all the recipients are in 1 array. Is there a way to track the emails? basically I was passing the email address to the url and then when they opened the email I would record the email address to the database. This is what Im using but it only passes the very last recipient as the value for $k include('Mail.php'); include('Mail/mime.php'); // Constructing the email $sender = "from address"; // Your name and email address $track_id = date("D M j Y - g:i a"); $recipients = array(); $query = "SELECT * FROM mailer WHERE mail_receive='Yes'"; $result = @mysql_query ($query); // Run the query. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $recipients[] = $row['mail_email']; // Recipient name and email address } foreach($recipients as $k => $sendto){ $html = "<img src=\"http://www.site.com/tracksent.php?t=$em&e=$k&track_id=$track_id\" width=\"1\" height=\"1\"><br />$message"; } $subject = $em; // Subject for the email $text = 'Your eMail will only accept text messages.To see this message as intended visit this link '; $crlf = "\n"; $headers = array( 'From' => $sender, 'Return-Path' => $sender, 'Subject' => $subject ); // Creating the Mime message $mime = new Mail_mime($crlf); // Setting the body of the email $mime->setTXTBody($text); $mime->setHTMLBody($html); // Add an attachment //$file = "Hello World!"; //$file_name = "Hello text.txt"; //$content_type = "text/plain"; //$mime->addAttachment ($file, $content_type, $file_name, 0); // Set body and headers ready for base mail class $body = $mime->get(); $headers = $mime->headers($headers); // SMTP params $smtp_params["host"] = "smtp.site.com"; // SMTP host $smtp_params["port"] = "587"; $smtp_params["auth"] = true; $smtp_params["username"] = "uname"; $smtp_params["password"] = "upass"; // Sending the email using smtp $mail =& Mail::factory("smtp", $smtp_params); $result = $mail->send($recipients, $headers, $body); if($result) { echo("Your message has been sent!"); echo"<h3>$em was sent to:</h3>"; foreach($recipients as $k => $value){ echo "$value <br />"; $query = "INSERT INTO sent (title, sent_to, track_id, track_key) VALUES ('$em', '$value', '$track_id', '$k')"; $result = @mysql_query ($query); // Run the query. } } else { echo("Your message was not sent: " . $result); }
×
×
  • 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.