Jump to content

DarkPrince2005

Members
  • Posts

    307
  • Joined

  • Last visited

About DarkPrince2005

  • Birthday 02/16/1983

Profile Information

  • Gender
    Male
  • Location
    South Africa

DarkPrince2005's Achievements

Advanced Member

Advanced Member (4/5)

1

Reputation

  1. Hi Guys and Gals The below code reads from a database and builds a tree structure. But my problem is in the collapse and expanding of the 'child' tr. Currently it expands the next tr, but if there is more than 1 child you have to first click the first chhild to expand the second child and so forth. Is there a way with jquery to expand a class until the next occurance of another class? <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> </head> <?php mysql_connect('localhost','root',''); mysql_select_db('samaedbm'); ini_set('display_errors', 1); ini_set('memory_limit', '640M'); ini_set('max_execution_time', 6000); error_reporting(E_ALL); function addnode($pid, $ind, $search){ global $modx; $sql = "select * from edbm_content where parentid = '".$pid. "' and description like '%". $search . "%'"; $ind .= '-'; $res = mysql_query($sql); while ($row = mysql_fetch_array($res)){ if ($pid == $row["id"]) { if (strlen($ind) == 1){ echo '<tr class="header0" id="header0"><td><span class="expanderSign">[+]</span> ' . $row["description"].'</td><td>'.$row["parentid"].'</td><td>'.$row["id"].'</td></tr>'; } } if ($pid != $row["id"]) { if (strlen($ind) == 1){ echo '<tr class="header1" id="header1" style="display:none;"><td style="padding-left:10px;"><span class="expanderSign">[+]</span> ' . $row["description"].'</td><td>'.$row["parentid"].'</td><td>'.$row["id"].'</td></tr>'; } if (strlen($ind) == 2){ echo '<tr class="header2" id="header2" data-for="header1" style="display:none;"><td style="padding-left:20px;"><span class="expanderSign">[+]</span> ' . $row["description"].'</td><td>'.$row["parentid"].'</td><td>'.$row["id"].'</td></tr>'; } if (strlen($ind) == 3){ echo '<tr data-for="header3" style="display:none;"><td style="padding-left:30px;"><span class="expanderSign">[+]</span> ' . $row["description"].'</td><td>'.$row["parentid"].'</td><td>'.$row["id"].'</td></tr>'; } addnode($row["id"], $ind, $search); } } return; } echo '<table style="font-size:13;">'; addnode(505000, '', ''); echo '</table>'; ?> <script type="text/javascript"> $(".header0").click(function() { $(".header1").slideToggle(500); if (jQuery(".expanderSign").text() == "[+]"){ jQuery(".expanderSign").text("[-]"); } else { jQuery(".expanderSign").text("[+]"); } }); $(".header1").children("td").click(function() { $(obj).closest('tr').nextAll(':has(.header2):first').find('.header2').show(); if (jQuery(".expanderSign").text() == "[+]"){ jQuery(".expanderSign").text("[-]"); } else { jQuery(".expanderSign").text("[+]"); } }); $(".header2").children("td").click(function() { $(this).parent().next("tr").show(); if (jQuery(".expanderSign").text() == "[+]"){ jQuery(".expanderSign").text("[-]"); } else { jQuery(".expanderSign").text("[+]"); } }); </script>
  2. Hi everyone I'm trying to generate a pdf file using TCPDF through a foreach loop. My problem is that its only generating the first entry in the array and not the second. (I'm doing this through MODx) <?php ini_set("display_errors", 1); $action = $_REQUEST['action']; switch($action) { case "generate_pdf": $id = (int) $_POST['id']; $html =''; require_once( $modx->config['base_path'].'/assets/tcpdf/examples/tcpdf_include.php'); // create new PDF document $pdf = new TCPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Focus on Health'); $pdf->SetTitle('CPD Activity Record'); $pdf->SetSubject('CPD Activity Record'); $pdf->SetKeywords('CPD, Activity, Record'); // remove default header/footer $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(5, 5, 5); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) if (@file_exists($modx->config['base_path'].'/assets/tcpdf/lang/eng.php')) { require_once($modx->config['base_path'].'/assets/tcpdf/lang/eng.php'); $pdf->setLanguageArray($l); } // --------------------------------------------------------- // set font $pdf->SetFont('helvetica', '', 9); $pdf->AddPage(); $html .= '<h1>Number of Active CEU's</h1>'; $ik = 1; $gr_arr = array(1=>'CLINICAL CEU\'S',2=>'ETHICS CEU\'S'); $data = array(); foreach($gr_arr as $group_id => $group_title){ $level1_total = 0; $level2_total = 0; $level3_total = 0; $sql = "SELECT c.*,uc.certificate_file FROM foh_conferences c LEFT JOIN foh_users_certification uc ON c.attachment_id=uc.id WHERE c.user_id = '".$_POST["id"]."' AND group_id = '".$group_id."' and (conference_accured + INTERVAL 2 YEAR) > NOW();"; $query = new xPDOCriteria($modx, $sql); $query->prepare(); $query->stmt->execute(); $data["conferences"] = array(); $conferences = array(); while($row = $query->stmt->fetch(PDO::FETCH_OBJ)) { $conferences[] = $row; $data["conferences"][] = $row; } /*$html .= '<pre>'; var_dump($conferences); $html .= '</pre>';*/ $sql2 = "SELECT e.*, e.exam_id AS renew_exam_id,s.title,s.show_level,a.pass_marks,a.total_marks,a.stotalmarks,s.accreditation_number,s.short_description, s.description,a.finished,g.title,s.number_ceu,s.group_clinical,s.group_ethics,s.date_accured,s.date_valid FROM foh_exams e INNER JOIN foh_survey s ON s.sid=e.sid LEFT JOIN foh_professions g ON s.sid = g.id INNER JOIN foh_answers a ON a.a_id=e.aid WHERE e.user_id = '".$_POST["id"]."'"; $query2 = new xPDOCriteria($modx, $sql2); $query2->prepare(); $query2->stmt->execute(); $data["exams"] = array(); $exams = array(); while($row2 = $query2->stmt->fetch(PDO::FETCH_OBJ)) { $exams[] = $row2; $data["exams"][] = $row2; } $ik++; $data["group_name"] = $group_title; $data["key"] = $group_id; /*$html .= '<pre>'; var_dump($data); $html .= '</pre>';*/ $html .= '<table cellpadding="3" cellspacing="0" border="0" style="border:1px solid #ccc;width:960px" class="ui-widget ui-corner-all"> <tr> <td colspan="9" style="text-align:center" class="ui-widget-header"> <h3>TOTAL '.$data["group_name"].'</h3> </td> </tr> <tr> <td rowspan="2" class="ui-widget-header" bgcolor="#cccccc">Name of provider</td> <td rowspan="2" class="ui-widget-header" bgcolor="#cccccc">Descriptions Of Activity</td> <td rowspan="2" class="ui-widget-header" bgcolor="#cccccc" width="100">Accreditation Number</td> <td rowspan="1" class="ui-widget-header" colspan="2" bgcolor="#cccccc">Date</td> <td rowspan="2" class="ui-widget-header" colspan="1" bgcolor="#cccccc">Level1</td> <td rowspan="2" class="ui-widget-header" colspan="1" bgcolor="#cccccc">Level2</td> <td rowspan="2" class="ui-widget-header" bgcolor="#cccccc">Level3</td> <td rowspan="2" class="ui-widget-header" bgcolor="#cccccc">Total</td> </tr> <tr> <td bgcolor="#cccccc" class="ui-widget-header">Date Accrued</td> <td bgcolor="#cccccc" class="ui-widget-header">Date Valid</td> </tr>'; foreach($data["exams"] as $exam) { if(($exam->status == 'failed'||$exam->status == 'completed') && (($exam->group_clinical==1 && $data["key"]==1) || ($exam->group_ethics==1 && $data["key"]==2)) ) { $html .= '<tr> <td>'.$exam->title.'</td> <td>'.$exam->short_description.'</td> <td>'.$exam->accreditation_number.'</td> <td align="center">'.($exam->status == 'completed'||$exam->status == 'failed'?date('Y/m/d',strtotime($exam->date_accured.'')):'----/--/--').'</td> <td align="center">'.($exam->status == 'completed'||$exam->status == 'failed'?date('Y/m/d',strtotime($exam->date_valid)):'----/--/--').'</td> <td class="center_points">'; if($exam->status == 'completed' && $exam->show_level == 1) { $html .= $exam->number_ceu; $level1_total += $exam->number_ceu; }else{ $html .= '--'; } $html .= '</td> <td class="center_points">'; if($exam->status == 'completed' && $exam->show_level == 2) { $html .= $exam->number_ceu; $level2_total += $exam->number_ceu; }else{ $html .= '--'; } $html .= '</td> <td class="center_points">'; if($exam->status == 'completed' && $exam->show_level == 3) { $html .= $exam->number_ceu; $level3_total += $exam->number_ceu; }else{ $html .= '--'; } $html .= '</td> <td class="center_points">'; if($exam->status == 'completed') { $html .= $exam->number_ceu; }else{ $html .= '--'; } $html .= '</td> </tr>'; } } foreach($data["conferences"] as $conf) { if($conf->conference_accured != '0000-00-00') { $conference_accured = strtotime($conf->conference_accured.' +2 year -1 day'); if($conference_accured > mktime()) { $html .= '<tr> <td>'.$conf->conference_name.'</td> <td>'.$conf->conference_description; if($conf->attachment_id != 0) { $html .= '<br/> <a href="'.base_url().'uploaduser_certificate/'.$conf->certificate_file.'" target="_blank">View File</a>'; } $html .= '</td> <td>'.$conf->conference_number.'</td> <td>'; if($conf->conference_accured == '0000-00-00') { $html .= '----/--/--'; }else{ $html .= date('Y/m/d',strtotime($conf->conference_accured.'')); } $html .= '</td> <td>'; if($conf->conference_accured == '0000-00-00') { $html .= '----/--/--'; }else{ $html .= date('Y/m/d',strtotime($conf->conference_accured.' +2 year -1 day')); } $html .= '</td> <td class="center_points">'; if($conf->level == 1){ $html .= $conf->points; $level1_total += $conf->points; } $html .= '</td> <td class="center_points">'; if($conf->level == 2){ $html .= $conf->points; $level2_total += $conf->points; } $html .= '</td> <td class="center_points">'; if($conf->level == 3){ $html .= $conf->points; $level3_total += $conf->points; } $html .= '</td> <td class="center_points">'.$conf->points.'</td> </tr>'; } } } $html .= '<tr> <td><b>Total Points</b></td> <td> </td> <td> </td> <td> </td> <td> </td> <td class="center_points"><b>'.$level1_total.'</b></td> <td class="center_points"><b>'.$level2_total.'</b></td> <td class="center_points"><b>'.$level3_total.'</b</td> <td class="center_points"><b>'.($level1_total+$level2_total+$level3_total).'</b></td> </tr> <tr> <td><b>Points Lapsed</b></td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td><b>Total Valid Points</b></td> <td></td> <td></td> <td></td> <td></td> <td class="center_points"><b>'.$level1_total.'</b></td> <td class="center_points"><b>'.$level2_total.'</b></td> <td class="center_points"><b>'.$level3_total.'</b></td> <td class="center_points"><b>'.($level1_total+$level2_total+$level3_total).'</b></td> </tr>'; $html .= '</table><br /><br />'; $level1_total = 0; $level2_total = 0; $level3_total = 0; } unset($data); $pdf->writeHTML($html, true, 0, true, 0); $pdf->lastPage(); $filename = $modx->config['base_path'].'/assets/report/'.$_POST["id"].'-'.date("Y-m-d H:i:s").'.pdf'; $fileatt = $pdf->Output($filename, 'F'); $json = array("message" => $fileatt); echo $fileatt; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $fileatt1 = $filename; // Path to the file $fileatt_type = "application/pdf"; // File Type $fileatt_name = $_POST["id"]."-".date("Y-m-d H:i:s").".pdf"; // Filename that will be used for the file as the attachment $email_from = "sales@mysite.com"; // Who the email is from $email_subject = "Your attached file"; // The Subject of the email $email_message = "Here is your CPD Activity Report<br>"; $email_message .= "<br>"; // Message that the email has in it $email_to = ''; // Who the email is to $headers = "From: ".$email_from; $file = fopen($fileatt1,'rb'); $data = fread($file,filesize($fileatt1)); 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) { $message = "Your file was successfully created and has been sent\n to the appropriate email address specified.\n Make sure to check your junk mail!\n"; } else { $message = "Sorry but the email could not be sent. Please go back and try again!"; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// echo json_encode(array('message' => $message)); break; default: echo json_encode(array('message' => 'Unknown action')); break; } die();
  3. Hi everyone I would like to know if anyone has ever successfully been able to display a TinyMCE editor in a while loop? It only displays the first loop, and not the second while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo '<form method="post" style="margin-top:20px;"><table> <tr> <td>Content Name</td> <td><input type="hidden" name="idwidget" value="'.$row["id"].'" /><input type="text" name="name" value="'.$row["content_name"].'" /></td> </tr> <tr> <td>Content</td> <td><textarea id="mcecontent" class="mcecontent" name="mcecontent" rows="15" cols="80">'.$row["content"].'</textarea></td> </tr> <tr> <td>Active</td> <td>'; if($row["active"] == "1"){ echo '<input type="checkbox" name="active" checked="checked" />'; } else { echo '<input type="checkbox" name="active" />'; } echo '</td> </tr> </table>'; } It is suppose to display for mcecontent textarea.
  4. lol... ok what I think is that I'd have to send the cookie string that is compiled by the script to a php script to save it to a database. $(settings.columns).each(function(i){ cookieString += (i===0) ? '' : '|'; $(settings.widgetSelector,this).each(function(i){ cookieString += (i===0) ? '' : ';'; /* ID of widget: */ cookieString += $(this).attr('id') + ','; /* Color of widget (color classes) */ cookieString += $(this).attr('class').match(/\bcolor-[\w]{1,}\b/) + ','; /* Title of widget (replaced used characters) */ cookieString += $('h3:eq(0)',this).text().replace(/\|/g,'[-PIPE-]').replace(/,/g,'[-COMMA-]') + ','; /* Collapsed/not collapsed widget? : */ cookieString += $(settings.contentSelector,this).css('display') === 'none' ? 'collapsed' : 'not-collapsed'; }); }); $.cookie(settings.saveToCookie,cookieString,{ expires: 10 //path: '/' }); or just refresh the page after each change to then run a mysql query.... What do you think?.... I'm not sure on editing the js, so I'd go for option 2... I'm really brand new to ajax
  5. /* * Script from NETTUTS.com [by James Padolsey] V.2 (ENHANCED, WITH COOKIES!!!) * @requires jQuery($), jQuery UI & sortable/draggable UI modules & jQuery COOKIE plugin */ var iNettuts = { jQuery : $, settings : { columns : '.column', widgetSelector: '.widget', handleSelector: '.widget-head', contentSelector: '.widget-content', /* If you don't want preferences to be saved change this value to false, otherwise change it to the name of the cookie: */ saveToCookie: 'inettuts-widget-preferences', widgetDefault : { movable: true, removable: true, collapsible: true, editable: true, colorClasses : ['color-yellow', 'color-red', 'color-blue', 'color-white', 'color-orange', 'color-green'] }, widgetIndividual : {} }, init : function () { this.attachStylesheet('inettuts.js.css'); this.sortWidgets(); this.addWidgetControls(); this.makeSortable(); }, getWidgetSettings : function (id) { var $ = this.jQuery, settings = this.settings; return (id&&settings.widgetIndividual[id]) ? $.extend({},settings.widgetDefault,settings.widgetIndividual[id]) : settings.widgetDefault; }, addWidgetControls : function () { var iNettuts = this, $ = this.jQuery, settings = this.settings; $(settings.widgetSelector, $(settings.columns)).each(function () { var thisWidgetSettings = iNettuts.getWidgetSettings(this.id); if (thisWidgetSettings.removable) { $('<a href="#" class="remove">CLOSE</a>').mousedown(function (e) { /* STOP event bubbling */ e.stopPropagation(); }).click(function () { if(confirm('This widget will be removed, ok?')) { $(this).parents(settings.widgetSelector).animate({ opacity: 0 },function () { $(this).wrap('<div/>').parent().slideUp(function () { $(this).remove(); }); }); } return false; }).appendTo($(settings.handleSelector, this)); } if (thisWidgetSettings.editable) { $('<a href="#" class="edit">EDIT</a>').mousedown(function (e) { /* STOP event bubbling */ e.stopPropagation(); }).toggle(function () { $(this).css({backgroundPosition: '-66px 0', width: '55px'}) .parents(settings.widgetSelector) .find('.edit-box').show().find('input').focus(); return false; },function () { $(this).css({backgroundPosition: '', width: '24px'}) .parents(settings.widgetSelector) .find('.edit-box').hide(); return false; }).appendTo($(settings.handleSelector,this)); $('<div class="edit-box" style="display:none;"/>') .append('<ul><li class="item"><label>Change the title?</label><input value="' + $('h3',this).text() + '"/></li>') .append((function(){ var colorList = '<li class="item"><label>Available colors:</label><ul class="colors">'; $(thisWidgetSettings.colorClasses).each(function () { colorList += '<li class="' + this + '"/>'; }); return colorList + '</ul>'; })()) .append('</ul>') .insertAfter($(settings.handleSelector,this)); } if (thisWidgetSettings.collapsible) { $('<a href="#" class="collapse">COLLAPSE</a>').mousedown(function (e) { /* STOP event bubbling */ e.stopPropagation(); }).click(function(){ $(this).parents(settings.widgetSelector).toggleClass('collapsed'); /* Save prefs to cookie: */ iNettuts.savePreferences(); return false; }).prependTo($(settings.handleSelector,this)); } }); $('.edit-box').each(function () { $('input',this).keyup(function () { $(this).parents(settings.widgetSelector).find('h3').text( $(this).val().length>20 ? $(this).val().substr(0,20)+'...' : $(this).val() ); iNettuts.savePreferences(); }); $('ul.colors li',this).click(function () { var colorStylePattern = /\bcolor-[\w]{1,}\b/, thisWidgetColorClass = $(this).parents(settings.widgetSelector).attr('class').match(colorStylePattern) if (thisWidgetColorClass) { $(this).parents(settings.widgetSelector) .removeClass(thisWidgetColorClass[0]) .addClass($(this).attr('class').match(colorStylePattern)[0]); /* Save prefs to cookie: */ iNettuts.savePreferences(); } return false; }); }); }, attachStylesheet : function (href) { var $ = this.jQuery; return $('<link href="' + href + '" rel="stylesheet" type="text/css" />').appendTo('head'); }, makeSortable : function () { var iNettuts = this, $ = this.jQuery, settings = this.settings, $sortableItems = (function () { var notSortable = ''; $(settings.widgetSelector,$(settings.columns)).each(function (i) { if (!iNettuts.getWidgetSettings(this.id).movable) { if(!this.id) { this.id = 'widget-no-id-' + i; } notSortable += '#' + this.id + ','; } }); return $('> li:not(' + notSortable + ')', settings.columns); })(); $sortableItems.find(settings.handleSelector).css({ cursor: 'move' }).mousedown(function (e) { $sortableItems.css({width:''}); $(this).parent().css({ width: $(this).parent().width() + 'px' }); }).mouseup(function () { if(!$(this).parent().hasClass('dragging')) { $(this).parent().css({width:''}); } else { $(settings.columns).sortable('disable'); } }); $(settings.columns).sortable({ items: $sortableItems, connectWith: $(settings.columns), handle: settings.handleSelector, placeholder: 'widget-placeholder', forcePlaceholderSize: true, revert: 300, delay: 100, opacity: 0.8, containment: 'document', start: function (e,ui) { $(ui.helper).addClass('dragging'); }, stop: function (e,ui) { $(ui.item).css({width:''}).removeClass('dragging'); $(settings.columns).sortable('enable'); /* Save prefs to cookie: */ iNettuts.savePreferences(); } }); }, savePreferences : function () { var iNettuts = this, $ = this.jQuery, settings = this.settings, cookieString = ''; if(!settings.saveToCookie) {return;} /* Assemble the cookie string */ $(settings.columns).each(function(i){ cookieString += (i===0) ? '' : '|'; $(settings.widgetSelector,this).each(function(i){ cookieString += (i===0) ? '' : ';'; /* ID of widget: */ cookieString += $(this).attr('id') + ','; /* Color of widget (color classes) */ cookieString += $(this).attr('class').match(/\bcolor-[\w]{1,}\b/) + ','; /* Title of widget (replaced used characters) */ cookieString += $('h3:eq(0)',this).text().replace(/\|/g,'[-PIPE-]').replace(/,/g,'[-COMMA-]') + ','; /* Collapsed/not collapsed widget? : */ cookieString += $(settings.contentSelector,this).css('display') === 'none' ? 'collapsed' : 'not-collapsed'; }); }); $.cookie(settings.saveToCookie,cookieString,{ expires: 10 //path: '/' }); }, sortWidgets : function () { var iNettuts = this, $ = this.jQuery, settings = this.settings; /* Read cookie: */ var cookie = $.cookie(settings.saveToCookie); if(!settings.saveToCookie||!cookie) { /* Get rid of loading gif and show columns: */ /*$('body').css({background:'#fff'});*/ $(settings.columns).css({visibility:'visible'}); return; } /* For each column */ $(settings.columns).each(function(i){ var thisColumn = $(this), widgetData = cookie.split('|')[i].split(';'); $(widgetData).each(function(){ if(!this.length) {return;} var thisWidgetData = this.split(','), clonedWidget = $('#' + thisWidgetData[0]), colorStylePattern = /\bcolor-[\w]{1,}\b/, thisWidgetColorClass = $(clonedWidget).attr('class').match(colorStylePattern); /* Add/Replace new colour class: */ if (thisWidgetColorClass) { $(clonedWidget).removeClass(thisWidgetColorClass[0]).addClass(thisWidgetData[1]); } /* Add/replace new title (Bring back reserved characters): */ $(clonedWidget).find('h3:eq(0)').html(thisWidgetData[2].replace(/\[-PIPE-\]/g,'|').replace(/\[-COMMA-\]/g,',')); /* Modify collapsed state if needed: */ if(thisWidgetData[3]==='collapsed') { /* Set CSS styles so widget is in COLLAPSED state */ $(clonedWidget).addClass('collapsed'); } $('#' + thisWidgetData[0]).remove(); $(thisColumn).append(clonedWidget); }); }); /* All done, remove loading gif and show columns: */ /*$('body').css({background:'#000'});*/ $(settings.columns).css({visibility:'visible'}); } }; iNettuts.init();
  6. Greetings everyone, I really hope someone would be able to help me quickly... I'm not very clued up on ajax,jquery or javascript, and would really love some help in converting the attached js file to use a database instead of cookies. Please guys, thanx in advance.
  7. Hi Everyone I am currently using a theme for wordpress and I'm trying to get an image to show in the blog excerpt on the home page... What I would like to achieve is something similar to http://blog.afridesign.com/ to showcase my portfolio. Thanx for any help in advance
  8. http://stackoverflow.com/questions/377632/add-update-and-edit-an-xml-file-with-php
  9. Thanx xyph, easy and stupid error... lol.
  10. Hi Guys I have a piece of code that checks if a file exists in a location, and if it does to then display a specific icon. The problem I'm having is that the file does exist but my code says it doesn't. The file name contains an & character. Any solutions???? if(file_exists('quotes/'.htmlentities($row["Quote_ID"]).'-'.htmlentities($row["Client"]).'-'.htmlentities($row["QuoteRevision"]).'.pdf')){ echo '<a href="quotes/'.htmlentities($row["Quote_ID"]).'-'.htmlentities($row["Client"]).'-'.htmlentities($row["QuoteRevision"]).'.pdf" target="_blank"><img src="images/icons/pdf.png" border="0" title="View File" /></a>'; } else { echo '<a href="quote_pdf.php?id='.htmlentities($row["Quote_ID"]).'&cid='.htmlentities($row["Client"]).'&rev='.htmlentities($row["QuoteRevision"]).'&redirect=quote_list"><img src="images/icons/pdf_inac.png" border="0" /></a>'; }
  11. I'm using a custom code module to construct a form. On submit it validates all fields, while keeping the entered values. The problem however is that instead of keeping the emaill address it displays javascript in the associated text field. Any sollutions? [b]<?php if(isset($_POST["submit"]) && $_POST["submit"] == "Book Now"){ $err = 0; $msg = ""; if(isset($_POST["fname"]) && $_POST["fname"] != ""){ if(!preg_match("/^[a-zA-Z ]/",$_POST["fname"])){ $err++; $msg .= "Your name contains invalid characters.<br />"; } } else { $err++; $msg .= "Please enter your name.<br />"; } if(isset($_POST["company"]) && $_POST["company"] != ""){ if(!preg_match("/^[a-zA-Z0-9 -]+$/i",$_POST["company"])){ $err++; $msg .= "Your company name contains invalid characters.<br />"; } } else { $err++; $msg .= "Please enter your company name.<br />"; } if(isset($_POST["department"]) && $_POST["department"] != ""){ if(!preg_match("/^[a-zA-Z ]/",$_POST["department"])){ $err++; $msg .= "Department contains invalid characters.<br />"; } } else { $err++; $msg .= "Please enter your department.<br />"; } if(isset($_POST["tel"]) && $_POST["tel"] != ""){ if((preg_match("/^[0-9 ]{12}$/",$_POST["tel"])) || (preg_match("/^[0-9 ]{10}$/",$_POST["tel"]))){ } else { $err++; $msg .= "Please enter a valid telephone number.<br />"; } } else { $err++; $msg .= "Please enter a telephone number.<br />"; } if(isset($_POST["cell"]) && $_POST["cell"] != ""){ if((preg_match("/^[0-9 ]{10}$/",$_POST["cell"])) || (preg_match("/^[0-9 ]{12}$/",$_POST["cell"]))){ } else { $err++; $msg .= "Please enter a valid Mobile Number.<br />"; } } else { $err++; $msg .= "Please enter a Mobile Number.<br />"; } if(isset($_POST["fax"]) && $_POST["fax"] != ""){ if((preg_match("/^[0-9 ]{10}$/",$_POST["fax"])) || (preg_match("/^[0-9 ]{12}$/",$_POST["fax"]))){ } else { $err++; $msg .= "Please enter a valid fax number.<br />"; } } if(isset($_POST["pcontact"]) && $_POST["pcontact"] != ""){ if((preg_match("/^[0-9 ]{10}$/",$_POST["pcontact"])) || (preg_match("/^[0-9 ]{12}$/",$_POST["pcontact"]))){ } else { $err++; $msg .= "Please enter a valid contact number.<br />"; } } else { $err++; $msg .= "Please enter a valid contact number.<br />"; } if(isset($_POST["email"]) && $_POST["email"] != ""){ if(!ereg("^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $_POST["email"])){ $err++; $msg .= "Please enter a valid email address.<br />"; } } else { $err++; $msg .= "Please enter a email address.<br />"; } if(isset($_POST["pemail"]) && $_POST["pemail"] != ""){ if(!ereg("^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $_POST["pemail"])){ $err++; $msg .= "Please enter a valid email address.<br />"; } } else { $err++; $msg .= "Please enter a email address.<br />"; } if($err == 0){ mysql_connect("localhost","root",""); mysql_select_db("dbase"); $sql = mysql_query("insert into table values ('','".$_POST["title"]."','".$_POST["fname"]."','".$_POST["company"]."','".$_POST["department"]."','".$_POST["address"]."','".$_POST["city"]."','".$_POST["tel"]."','".$_POST["cell"]."','".$_POST["fax"]."','".$_POST["email"]."','".$_POST["course_name"]."','".$_POST["sdate"]."','".$_POST["edate"]."','".$_POST["order_number"]."','".$_POST["prev_training"]."','".$_POST["diet_req"]."','".$_POST["pname"]."','".$_POST["pcontact"]."','".$_POST["pemail"]."')") or die (mysql_err()); if($sql){ $msg .= "Your booking form has been successfully sent.<br />"; } } } ?> <form action="<?php echo $_SERVER["REQUEST_URI"]; ?>" method="post"> <?php echo '<font color="#F00F00">'.$msg.'</font>'; ?> <table> <tr> <td>Title:</td> <td>Name (Printed on Certificate):</td> </tr> <tr> <td><input type="radio" name="title" value="Mr." />Mr. <input type="radio" name="title" value="Mrs." />Mrs.</td> <td><input type="text" name="fname" size="40" value="<?php echo $_POST["fname"]; ?>" /></td> </tr> <tr> <td>Company:</td> <td>Department:</td> </tr> <tr> <td><input type="text" name="company" size="40" value="<?php echo $_POST["company"]; ?>" /></td> <td><input type="text" name="department" size="30" value="<?php echo $_POST["department"]; ?>" /></td> </tr> <tr> <td>Address:</td> <td></td> </tr> <tr> <td colspan="2"><input type="text" name="address" size="80" value="<?php echo $_POST["address"]; ?>" /></td> </tr> <tr> <td>City:</td> <td></td> </tr> <tr> <td><input type="text" name="city" size="30" value="<?php echo $_POST["city"]; ?>" /></td> <td></td> </tr> <tr> <td>Tel:</td> <td>Mobile:</td> </tr> <tr> <td><input type="text" name="tel" size="30" value="<?php echo $_POST["tel"]; ?>" /></td> <td><input type="text" name="cell" size="30" value="<?php echo $_POST["cell"]; ?>" /></td> </tr> <tr> <td>Fax:</td> <td>Email:</td> </tr> <tr> <td><input type="text" name="fax" size="30" value="<?php echo $_POST["fax"]; ?>" /></td> <td><input type="text" name="email" size="40" value="<?php echo htmlentities($_POST["email"]); ?>" /></td> </tr> <tr> <td>Training Course Name:</td> <td></td> </tr> <tr> <td colspan="2"><input type="text" name="course_name" size="60" value="<?php echo $_GET["course_name"]; ?>" /></td> </tr> <tr> <td>Start Date:</td> <td>End Date:</td> </tr> <tr> <td><input type="text" name="sdate" size="20" value="<?php echo $_GET["sdate"]; ?>" /></td> <td><input type="text" name="edate" size="20" value="<?php echo $_GET["edate"]; ?>" /></td> </tr> <tr> <td>Order Number:</td> <td></td> </tr> <tr> <td><input type="text" name="order_number" size="40" value="<?php echo $_POST["order_number"]; ?>" /></td> <td></td> </tr> <tr> <td>Previous Bentley Training:</td> <td></td> </tr> <tr> <td colspan="2"><input type="text" name="prev_training" size="40" value="<?php echo $_POST["prev_training"]; ?>" /></td> </tr> <tr> <td>Special Dietary Requirements:</td> <td></td> </tr> <tr> <td colspan="2"><input type="text" name="diet_req" size="80" value="<?php echo $_POST["diet_req"]; ?>" /></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><b>Details of Person Responsible for Payment:</b></td> </tr> <tr> <td>Initials & Surname:</td> <td>Contact Number:</td> </tr> <tr> <td><input type="text" name="pname" size="40" value="<?php echo $_POST["pname"]; ?>" /></td> <td><input type="text" name="pcontact" size="40" value="<?php echo $_POST["pcontact"]; ?>" /></td> </tr> <tr> <td>Email:</td> <td></td> </tr> <tr> <td><input type="text" name="pemail" size="40" value="<?php echo $_POST["pemail"]; ?>" /></td> <td></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" name="submit" value="Book Now" /></td> </tr> </table> </form>[/b]
  12. Can anyone tell me why this is just echoing empty lines? When I do it in mysql it works. <?php $conn=odbc_connect('helpdesk','',''); $sql="SELECT * FROM invoices"; $rs=odbc_exec($conn,$sql); while(odbc_fetch_row($rs)){ mysql_connect("localhost","root",""); mysql_select_db("db"); $len = strlen(odbc_result($rs,"Invoice_ID")); //echo $len; if($len == "12"){ $new = str_replace("ITEC_Inv-00","ITECnerv_Inv-0000",odbc_result($rs,"Invoice_ID")); } else { if($len == "13"){ $new = str_replace("ITEC_Inv-00","ITECnerv_Inv-000",odbc_result($rs,"Invoice_ID")); } else { if($len == "14"){ $new = str_replace("ITEC_Inv-00","ITECnerv_Inv-00",odbc_result($rs,"Invoice_ID")); } else { $new = odbc_result($rs,"Invoice_ID"); } } } echo $new."<br />"; }
  13. How would I check for multiple date formats eg. dd/mm/yyyy, dd-mm-yyyy, yyyy-mm-dd, etc.
×
×
  • 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.