Jump to content

webguync

Members
  • Posts

    951
  • Joined

  • Last visited

Posts posted by webguync

  1. Sorry to not understand fully, but what am I doing wrong here?

    $outp = ["records" => []];
    while($rs = $result->fetch_array(MYSQLI_ASSOC)) {
        if ($outp != "") {$outp .= "";}
        $outp .= '{"Portrait":"'  . $rs["Portrait"] . '",';
        $outp .= '"First Name":"'  . $rs["FName"] . '",';
        $outp .= '"Last Name":"'   . $rs["LName"] . '",';
        $outp .= '"DOI":"'. $rs["DOI"] . '",';
        $outp .= '"MOI":"'. $rs["MOI"] . '",';
        $outp .= '"YOI":"'. $rs["YOI"] . '",';
        $outp .= '"ID":"'. $rs["id"] . '"}';
    }
    $outp ='{"records":['.$outp.']}';
    $conn->close();
    
    echo json_encode($outp);
    

    I get an error with this line 

    $outp = ["records" => []];
    

    Parse error: syntax error, unexpected '[' in Database-search/DB-Search.php on line 7

  2. $outp = "";
    while($rs = $result->fetch_array(MYSQLI_ASSOC)) {
        if ($outp != "") {$outp .= "";}
        $outp .= '{"Portrait":"'  . $rs["Portrait"] . '",';
        $outp .= '"First Name":"'  . $rs["FName"] . '",';
        $outp .= '"Last Name":"'   . $rs["LName"] . '",';
        $outp .= '"DOI":"'. $rs["DOI"] . '",';
        $outp .= '"MOI":"'. $rs["MOI"] . '",';
        $outp .= '"YOI":"'. $rs["YOI"] . '",';
        $outp .= '"ID":"'. $rs["id"] . '"}';
    }
    $outp ='{"records":['.$outp.']}';
    

    Hi for the above PHP code the output looks like this JSON format

    {

    "records": [{

    "Portrait": "image1.png",

    "First Name": "Dave",

    "Last Name": "Smith",

    "DOI": "20",

    "MOI": "0",

    "YOI": "2017",

    "ID": "1"

    } {

    "Portrait": "image2.png",

    "First Name": "Sally",

    "Last Name": "Jones",

    "DOI": "20",

    "MOI": "0",

    "YOI": "2009",

    "ID": "2"

    }]

    }

     

    and this doesn't validate because there should be comma in between records like this:

     

    {

    "records": [{

    "Portrait": "image1.png",

    "First Name": "Dave",

    "Last Name": "Smith",

    "DOI": "20",

    "MOI": "0",

    "YOI": "2017",

    "ID": "1"

    }, {

    "Portrait": "image2.png",

    "First Name": "Sally",

    "Last Name": "Jones",

    "DOI": "20",

    "MOI": "0",

    "YOI": "2009",

    "ID": "2"

    }]

    }

     

    I am trying to figure out how to get a comma added between records without also adding it at the end, b/c that is invalid also.

     

    Any ideas?

  3. Hi,I used bootstrap to create a webpage and one of the special effects is when you scroll down the page the section you are at is highlighted in the menu. This seems to work ok for all of my sections except the About Me section in which case the next section down (resume) is highlighted instead.

     

    Here is the specific area on the page (http://www.inspired-evolution.com/index.php#section-about).

     

    I was wondering if anyone familiar with Boostrap and the Amoeba theme had any suggestions on a fix for this.

     

    thanks in advance.

  4. Hi,

     

    I am using fancybox on my site and the function I am using to display the title and data-caption is this.

    $(document).ready(function() {
     $('.fancybox').fancybox({
      beforeShow : function(){
       this.title =  this.title +"<br>" + $(this.element).data("caption");
      }
     });
    }); // ready
    

    I would like to change this so that I can add a hypertext link.

     

    Here is what a sample of the HTML looks like:

    				<img src="img/portfolio/GSI_web.png" height="194" width="400" alt="Globalsoftwareinc.com" />
                                            <h4>www.globalsoftwareinc.com</h4>
    										 <div class="portfolio-desc align-center">
    											<div class="folio-info">
    												<h5><a title="globalsoftwareinc.com" href="#" title="www.globalsoftwareinc.com">Globalsoftwareinc.com</a></h5>
    												<a title="Global Software Inc. website" href="img/portfolio/GSI_web_large.png" class="fancybox" data-caption="I was the interactive web designer at Global Software, Inc. and assisted in the re-design and development of Global Software, Inc. in Drupal<br>www.globalsoftwareinc.com"><i class="fa fa-plus fa-2x"></i></a>
    											 </div>										   
    										 </div>
    									</div>
                                    </article>
    

    so for example I would want to make www.globalsoftwareinc a hyperlink and that isn't do-able currently. It breaks the code.

     

    thanks in advance!

  5. Hi, I am working on a project to help me learn more about JSON and JQuery and how they interact. I am able to pull in my JSON data fine and it displays in an HTML table. What isn't working is I want the tables rows to be striped, and normally this works, but I didn't know if it isn't working b/c it is AJAX or if I have something wrong with my JQuery. Also, I was hoping to add a reference to an image path in the JSON file as well, but wasn't sure how that is done or if it could be done at the JSON level.

     

    Here is my code that I am working on:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>JSON Presidents</title>
    	<style type="text/css">
            
            body{
                font-family:arial, helvetica, sans-serif;
            text-align:center;
                width:100%;
                margin:200px 0 0 0;
            }
            
    	#PresidentInfo{
    	width:75%;
    	margin:0 auto;
           
            
    	}
            
            table#data{
                width:100%;
            }
            
            table#data th{
                background:#333;
                color:#fff;
                text-align:center;
                text-shadow:1px 1px 1px rgba(0,0,0,1);
                padding:5px;
            }
            
            table#data td{
                border:1px solid #333;
                border-collapse:collapse;
                padding:10px;
                margin:0 5px 0 5px;
                text-align:center;
            }
            
            .odd {
       background: #ccc;
    }
                
    	
    
    	
    	
    	</style>
    </head>
    <body>
            
        <div id="PresidentInfo">
      
        </div>
    
        <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
    	   <script>
               (function ($) {
    $(document).ready (function(){
       $("tr:odd").addClass("odd");
        });
    });
    })(jQuery);
    </script>
        <script>
      $.getJSON('data.json', function(data) {
            var output="<table id='data'><tr><th>First Name:</th><th>Last Name:</th><th>Month of Inauguration:</th><th>Year of Inauguration:</th></tr>";
            for (var i in data.Presidents) {
                output+="<tr><td>" + data.Presidents[i].firstName + "</td><td>" + data.Presidents[i].lastName + "</td><td>" + data.Presidents[i].YearInauguratedPresident.month +  "</td><td>" + data.Presidents[i].YearInauguratedPresident.year + "</td></tr>";
            }
    
            output+="</tr></table>";
            document.getElementById("PresidentInfo").innerHTML=output;
      });
        </script>
     
    </body>
    </html>
    
    {"Presidents":[
            {
                "firstName":"Barack",
                "lastName":"Obama",
                "YearInauguratedPresident": {
                    "month":"January",
                    "day":20,
                    "year":2009
                }
            },
            {
                "firstName":"George W",
                "lastName":"Bush",
                "YearInauguratedPresident": {
                    "month":"January",
                    "day":20,
                    "year":2001
    				}
                },
    			     {
                "firstName":"Bill",
                "lastName":"Clinton",
                "YearInauguratedPresident": {
                    "month":"January",
                    "day":20,
                    "year":1993
    				}
                },
    			     {
                "firstName":"George",
                "lastName":"H.W Bush",
                "YearInauguratedPresident": {
                    "month":"January",
                    "day":20,
                    "year":1989
                }
            }
    ]}
    
  6. I need some help in altering this JQuery script if possible. I script as it currently stands creates a bar at the bottom of the page with a message that fades away after 5 secs. To trigger the bar you have to click a button. I would like to alter that so you don't need to click the button. The bar fades in after 5 seconds. Everything else I like.

     

    Here is the code

     

     

     
    (function($) {
     
    $.fn.bar = function(options) {
    var opts = $.extend({}, $.fn.bar.defaults, options);
    return this.each(function() {
    $this = $(this);
    var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
     
    $this.click(function(e){
    if(!$('.jbar').length){
    timeout = setTimeout('$.fn.bar.removebar()',o.time);
    var _message_span = $(document.createElement('span')).addClass('jbar-content').html(o.message);
    _message_span.css({"color" : o.color});
    var _wrap_bar;
    (o.position == 'bottom') ? 
    _wrap_bar   = $(document.createElement('div')).addClass('jbar jbar-bottom'):
    _wrap_bar   = $(document.createElement('div')).addClass('jbar jbar-top') ;
     
    _wrap_bar.css({"background-color"  : o.background_color});
    if(o.removebutton){
    var _remove_cross = $(document.createElement('a')).addClass('jbar-cross');
    _remove_cross.click(function(e){$.fn.bar.removebar();})
    }
    else{ 
    _wrap_bar.css({"cursor" : "pointer"});
    _wrap_bar.click(function(e){$.fn.bar.removebar();})
    } 
    _wrap_bar.append(_message_span).append(_remove_cross).hide().insertBefore($('.content')).fadeIn('fast');
    }
    })
     
     
    });
    };
    var timeout;
    $.fn.bar.removebar  = function(txt) {
    if($('.jbar').length){
    clearTimeout(timeout);
    $('.jbar').fadeOut('slow',function(){
    $(this).remove();
    });
    } 
    };
    $.fn.bar.defaults = {
    background_color  : '#fff',
    color  : '#000',
    position   : 'top',
    removebutton      : true,
    time   : 5000 
    };
     
    })(jQuery);
    
  7. Is there a way to just hide an external link to a JS file specifically in IE7? I have some JQuery slide in effects working fine in every browser I tested in except IE7.(the functiality is completely screwy in that browser) It's not a necessary functionality to the page, so instead of racking my brain trying to fix in IE7, I was just hoping to hide/disable the link (IE7 only). That way nothing will happen in IE7 which is what I want.

  8. I am trying to figure out why a form isn't submitting into a MySQL database. I am using JWuery in between but that isn't the problem. I have combed over the code several times, but cannot see any errors. Any suggestions on debugging? There are quite a few form fields. Here is the code.

     

    [Form code]

    
    <form id="ContactForm" action="">
    
    <p>
    <label>Title: <span>(optional)</span></label>
    <input id="Title" name="Title_t" maxlength="120" type="text" autocomplete="off"/>
    
    </p>
    <p>
    <label>First Name:<span class="red"><sup>*</sup></label>
    <input id="FName" name="FName_t" class="inplaceError" maxlength="120" type="text" autocomplete="off"/>
    <span class="error" style="display:none;"></span>
    </p>
    <p>
    <label>Last Name:<span class="red"><sup>*</sup></label>
    <input id="LName" name="LName_t" class="inplaceError" maxlength="120" type="text" autocomplete="off"/>
    <span class="error" style="display:none;"></span>
    </p>
    <p>
    <label>Name of Organization:<span class="red"><sup>*</sup></label>
    <input id="OrgName" name="OrgName_t" class="inplaceError" maxlength="120" type="text" autocomplete="off"/>
    <span class="error" style="display:none;"></span>
    </p>
    <p>
    <label>Name of Event:<span class="red"><sup>*</sup></label>
    <input id="EventName" name="EventName_t" class="inplaceError" maxlength="120" type="text" autocomplete="off"/>
    <span class="error" style="display:none;"></span>
    </p>
    
    <p>
    <label>Address:<span class="red"><sup>*</sup></label>
    <input id="Address1" name="Address_Name_t" class="inplaceError" maxlength="120" type="text" autocomplete="off"/>
    <span class="error" style="display:none;"></span>
    </p>
    
    <p>
    <label>Address: <span>(optional)</span></label>
    <input id="Address2" name="Address_Name2_t" class="inplaceError" maxlength="120" type="text" autocomplete="off"/>
    
    </p>
    
    <p>
    <label>City:<span class="red"><sup>*</sup></label>
    <input id="City" name="City_t" class="inplaceError" maxlength="120" type="text" autocomplete="off"/>
    <span class="error" style="display:none;"></span>
    </p>
    
    <p>
    <label>State:<span class="red"><sup>*</sup></label>
    <input id="State" name="State_t" class="inplaceError" maxlength="120" type="text" autocomplete="off"/>
    <span class="error" style="display:none;"></span>
    </p>
    
    <p>
    <label>Zip:<span class="red"><sup>*</sup></label>
    <input id="Zip" name="Zip_n" class="inplaceError" maxlength="120" type="text" autocomplete="off"/>
    <span class="error" style="display:none;"></span>
    </p>
    
    
    
    <p>
    <label>Fax:<span>optional</span></label>
    <input id="Fax" name="Fax_n" class="inplaceError" maxlength="120" type="text" autocomplete="off"/>
    
    </p>
    <p>
    <label>Start Date/Start Time:<span class="red"><sup>*</sup></label>
    <input id="StartDate" name="StartDate_d" class="inplaceError" maxlength="120" type="text" autocomplete="off"/>
    
    </p>
    <p>
    <label>End Date/End Time:<span class="red"><sup>*</sup></label>
    <input id="EndDate" name="EndDate_d" class="inplaceError" maxlength="120" type="text" autocomplete="off"/>
    
    </p>
    <p>
    <label>Cost of Event: <span>(optional)</span></label>
    <input id="Cost" name="Cost_n" maxlength="120" type="text" autocomplete="off"/>
    
    </p>
    
    <p>
    <label>Website:<span>(optional)</span></label>
    <input id="Website" name="Website_t" class="inplaceError" maxlength="120" type="text" autocomplete="off"/>
    </p>
    
    <p>
    <label>Description of Organization:<span class="red"><sup>*</sup><br /> <span>300 characters allowed</span></label>
    <textarea id="Description" name="Description_t" class="inplaceError" cols="6" rows="5" autocomplete="off"></textarea>
    <span class="error" style="display:none;"></span>
    </p>
    
    <p class="submit">
    <input id="send" type="button" value="Submit"/>
    <span id="loader" class="loader" style="display:none;"></span>
    <span id="success_message" class="success"></span>
    </p>
    <input id="newcontact" name="newcontact" type="hidden" value="1"></input>
    <p align="left"><span class="red"><sup>*</sup></span> Indicates a required field</p>
    </form>
    

     

     

    Submit Code

    
    <?php
    require_once("db.php"); /* Database Class */
    //require_once('utils/is_email.php'); /* Email Validation Script */
    
    /* Handle Ajax Request */
    if(isset($_POST['newcontact'])){
    $contact = new Contact();
    unset($contact);
    }
    else{
    header('Location: /');
    }
    
    /* Class Contact */
    class Contact{
    
    private $db; /* the database obj */
    
    private $errors = array(); /* holds error messages */
    private $num_errors; /* number of errors in submitted form */
    
    public function __construct(){
    $this->db = new DB();
    if(isset($_POST['newcontact']))
    $this->processNewMessage();
    else
    header("Location: /");
    }
    
    public function processNewMessage(){
    
    $Title = $_POST['Title_t'];
    $FName = $_POST['FName_t'];
    $LName = $_POST['LName_t'];
    $OrgName = $_POST['OrgName_t'];
    $EventName = $_POST['EventName_t'];
    $AddressName = $_POST['Address_Name_t'];
    $AddressName2 = $_POST['Address_Name2_t'];
    $City = $_POST['City_t'];
    $State = $_POST['State_t'];
    $Zip = $_POST['Zip_n'];
    $StartDate = $_POST['StartDate_d'];
    $EndDate = $_POST['EndDate_d'];
    $Website = $_POST['Website_t'];
    $Cost = $POST ['Cost_n'];
    $Description = $POST['Description_t'];
    
    /* Server Side Data Validation */
    
    /* Email Validation */
    //if(!$email || mb_strlen($email = trim($email)) == 0)
    //$this->setError('email','required field');
    //else{
    //if(!is_email($email))
    //$this->setError('email', 'invalid email');
    //else if(mb_strlen($email) > 120)
    //$this->setError('email', 'too long! 120');
    //}
    
    /* First Name Validation */
    if(!$FName || mb_strlen($FName = trim($FName)) == 0)
    $this->setError('FName_t', 'required field');
    else if(mb_strlen(trim($FName)) > 120)
    $this->setError('FName_t', 'too long! 120 characters');
    
    /* Last Name Validation */
    if(!$LName || mb_strlen($LName = trim($LName)) == 0)
    $this->setError('LName_t', 'required field');
    else if(mb_strlen(trim($LName)) > 120)
    $this->setError('LName_t', 'too long! 120 characters');
    
    /* Organization Validation */
    if(!$OrgName || mb_strlen($OrgName = trim($OrgName)) == 0)
    $this->setError('OrgName_t', 'required field');
    else if(mb_strlen(trim($OrgName)) > 120)
    $this->setError('OrgName_t', 'too long! 120 characters');
    
    /* Organization Validation */
    if(!$EventName || mb_strlen($EventName = trim($EventName)) == 0)
    $this->setError('EventName_t', 'required field');
    else if(mb_strlen(trim($EventName)) > 120)
    $this->setError('EventName_t', 'too long! 120 characters');
    
    /* Address Validation */
    if(!$AddressName || mb_strlen($AddressName = trim($AddressName)) == 0)
    $this->setError('Address_Name_t', 'required field');
    else if(mb_strlen(trim($AddressName)) > 120)
    $this->setError('Address_Name_t', 'too long! 120 characters');
    
    /* City Validation */
    if(!$City || mb_strlen($City = trim($City)) == 0)
    $this->setError('City_t', 'required field');
    else if(mb_strlen(trim($City)) > 120)
    $this->setError('City_t', 'too long! 120 characters');
    
    /* State Validation */
    if(!$State || mb_strlen($State = trim($State)) == 0)
    $this->setError('State_t', 'required field');
    else if(mb_strlen(trim($State)) > 12)
    $this->setError('State_t', 'too long! 12 characters');
    
    /* Zip Validation */
    if(!$Zip || mb_strlen($Zip = trim($Zip)) == 0)
    $this->setError('Zip_n', 'required field');
    else if(mb_strlen(trim($Zip)) > 12)
    $this->setError('Zip_n', 'too long! 12 characters');
    
    
    /* Start Date Validation */
    if(!$StartDate || mb_strlen($StartDate = trim($StartDate)) == 0)
    $this->setError('StarteDate_d', 'required field');
    else if(mb_strlen(trim($StartDate)) > 12)
    $this->setError('StartDate_d', 'too long! 12 characters');
    
    /* End Time Validation */
    if(!$EndDate || mb_strlen($EndDate = trim($EndDate)) == 0)
    $this->setError('EndDate_d', 'required field');
    else if(mb_strlen(trim($EndDate)) > 12)
    $this->setError('EndDate_d', 'too long! 12 characters');
    
    
    /* Description Validation */
    $Description = trim($Description);
    if(!$Description || mb_strlen($Description = trim($Description)) == 0)
    $this->setError('Description_t','required field');
    elseif(mb_strlen($Description) > 300)
    $this->setError('Description_t', 'too long! 300 characters');
    
    /* Errors exist */
    if($this->countErrors() > 0){
    $json = array(
    'result' => -1,
    'errors' => array(
    array('name' => 'Title_t' ,'value' => $this->error_value('Title_t')),
    array('name' => 'FName_t' ,'value' => $this->error_value('FName_t')),
    array('name' => 'LName_t' ,'value' => $this->error_value('LName_t')),
    array('name' => 'OrgName_t' ,'value' => $this->error_value('OrgName_t')),
    array('name' => 'EventName_t' ,'value' => $this->error_value('EventName_t')),
    array('name' => 'Address_Name_t' ,'value' => $this->error_value('Address_Name_t')),
    array('name' => 'Address_Name2_t' ,'value' => $this->error_value('Address_Name2_t')),
    array('name' => 'City_t' ,'value' => $this->error_value('City_t')),
    array('name' => 'State_t' ,'value' => $this->error_value('State_t')),
    array('name' => 'Zip_n' ,'value' => $this->error_value('Zip_n')),
    array('name' => 'StartDate_d' ,'value' => $this->error_value('StartDate_d')),
    array('name' => 'EndDate_d' ,'value' => $this->error_value('EndDate_d')),
    array('name' => 'Website_t' ,'value' => $this->error_value('Website_t')),
    array('name' => 'Cost_n' ,'value' => $this->error_value('Cost_n')),
    array('name' => 'Description_t' ,'value' => $this->error_value('Description_t')),
    )
    );
    $encoded = json_encode($json);
    echo $encoded;
    unset($encoded);
    }
    /* No errors, insert in db*/
    else{
    if(($ret = $this->db->dbNewMessage($Title)) > 0){
    $json = array('result' => 1);
    if(SEND_EMAIL)
    $this->sendEmail($Title);
    }
    else
    $json = array('result' => -2); /* something went wrong in database insertion */
    $encoded = json_encode($json);
    echo $encoded;
    unset($encoded);
    }
    }
    
    public function sendEmail($FName,$LName,$EventName,$OrgName,$Description){
    /* Just format the email text the way you want ... */
    $message_body = "Hi, ".$FName."(".$OrgName." - ".$EventName.") sent you a message from everyeveryevery.com\n"
    
    ."Description: "."\n"
    .$Description_t;
    $headers = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">";
    
    return mail(EMAIL_TO,MESSAGE_SUBJECT,$message_body,$headers);
    }
    
    public function setError($field, $errmsg){
    $this->errors[$field] = $errmsg;
    $this->num_errors = count($this->errors);
    }
    
    public function error_value($field){
    if(array_key_exists($field,$this->errors))
    return $this->errors[$field];
    else
    return '';
    }
    
    public function countErrors(){
    return $this->num_errors;
    }
    };
    ?>
    

     

    Submit to Database

    
    <?php
    require_once("config.php"); /* Configuration File */
    
    class DB{
    
    private $link;
    
    public function __construct(){
    $this->link = mysqli_connect(DB_SERVER, DB_USER, DB_PASS,DB_NAME);
    if (mysqli_connect_errno())
    exit();
    }
    
    public function __destruct() {
    mysqli_close($this->link);
    }
    
    public function dbNewMessage($Title,$FName,$LName,$OrgName,$EventName,$AddressName,$AddressName2,$City,$State,$Zip,$StartDate,$EndDate,$Website,$Cost,$Description){
    $Title = mysqli_real_escape_string($this->link,$Title);
    $FName = mysqli_real_escape_string($this->link,$FName);
    $LName = mysqli_real_escape_string($this->link,$LName);
    $OrgName = mysqli_real_escape_string($this->link,$OrgName);
    $EventName = mysqli_real_escape_string($this->link,$EventName);
    $AddressName = mysqli_real_escape_string($this->link,$AddressName);
    $AddressName2 = mysqli_real_escape_string($this->link,$AddressName2);
    $City = mysqli_real_escape_string($this->link,$City);
    $State = mysqli_real_escape_string($this->link,$State);
    $Zip = mysqli_real_escape_string($this->link,$Zip);
    $StartDate = mysqli_real_escape_string($this->link,$StartDate);
    $EndDate = mysqli_real_escape_string($this->link,$EndDate);
    
    $Website = mysqli_real_escape_string($this->link,$Website);
    $Cost = mysqli_real_escape_string($this->link,$Cost);
    $Description= mysqli_real_escape_string($this->link,$Description);
    
    
    
    mysqli_autocommit($this->link,FALSE);
    
    $query = "INSERT INTO Events(ID,Admin_n,Title_t,FName_t,LName_t,OrgName_t,EventName_t,Address_Name_t,Address_Name2_t,City_t,State_t,Zip_n,StartDate_d,EndDate_d,Website_t,Cost_n,Description_t)
    VALUES('NULL','0','$Title','$FName','$LName','$OrgName','$EventName','$AddressName','$AddressName2','$City','$State','$Zip','$StartDate','$EndDate','$Website','$Cost','$Description')";
    mysqli_query($this->link,$query);
    
    if(mysqli_errno($this->link))
    return -1;
    else{
    mysqli_commit($this->link);
    return 1;
    
    }
    }
    };
    ?>
    

     

    MySQL

     

    
    
    [color=#4f76ac]CREATE[/color] [color=#4f76ac]TABLE[/color] [color=#4f76ac]IF[/color] [color=#4f76ac]NOT[/color] [color=#4f76ac]EXISTS[/color] `Events` (
    `ID` [color=#4f76ac]int[/color](3) [color=#4f76ac]NOT[/color] [color=#4f76ac]NULL[/color] AUTO_INCREMENT,
    `Admin_n` [color=#4f76ac]int[/color](12) [color=#4f76ac]NOT[/color] [color=#4f76ac]NULL[/color],
    `Title_t` text [color=#4f76ac]NOT[/color] [color=#4f76ac]NULL[/color],
    `FName_t` text [color=#4f76ac]NOT[/color] [color=#4f76ac]NULL[/color],
    `LName_t` text [color=#4f76ac]NOT[/color] [color=#4f76ac]NULL[/color],
    `OrgName_t` text [color=#4f76ac]NOT[/color] [color=#4f76ac]NULL[/color],
    `EventName_t` text [color=#4f76ac]NOT[/color] [color=#4f76ac]NULL[/color],
    `Address_Name_t` text [color=#4f76ac]NOT[/color] [color=#4f76ac]NULL[/color],
    `Address_Name2_t` text [color=#4f76ac]NOT[/color] [color=#4f76ac]NULL[/color],
    `City_t` text [color=#4f76ac]NOT[/color] [color=#4f76ac]NULL[/color],
    `State_t` text [color=#4f76ac]NOT[/color] [color=#4f76ac]NULL[/color],
    `Zip_n` [color=#4f76ac]int[/color](7) [color=#4f76ac]NOT[/color] [color=#4f76ac]NULL[/color],
    `StartDate_d` [color=#4f76ac]datetime[/color] [color=#4f76ac]NOT[/color] [color=#4f76ac]NULL[/color],
    `EndDate_d` [color=#4f76ac]datetime[/color] [color=#4f76ac]NOT[/color] [color=#4f76ac]NULL[/color],
    `Website_t` text [color=#4f76ac]NOT[/color] [color=#4f76ac]NULL[/color],
    `Cost_n` [color=#4f76ac]bigint[/color](20) [color=#4f76ac]NOT[/color] [color=#4f76ac]NULL[/color],
    `Description_t` text [color=#4f76ac]NOT[/color] [color=#4f76ac]NULL[/color],
    `Date_Added` timestamp [color=#4f76ac]NOT[/color] [color=#4f76ac]NULL[/color] [color=#4f76ac]DEFAULT[/color] [color=#4f76ac]CURRENT_TIMESTAMP[/color] [color=#4f76ac]ON[/color] [color=#4f76ac]UPDATE[/color] [color=#4f76ac]CURRENT_TIMESTAMP[/color],
    [color=#4f76ac]PRIMARY[/color] [color=#4f76ac]KEY[/color] (`ID`),
    FULLTEXT [color=#4f76ac]KEY[/color] `Title_t` (`Title_t`),
    FULLTEXT [color=#4f76ac]KEY[/color] `FName_t` (`FName_t`),
    FULLTEXT [color=#4f76ac]KEY[/color] `LName_t` (`LName_t`),
    FULLTEXT [color=#4f76ac]KEY[/color] `OrgName_t` (`OrgName_t`),
    FULLTEXT [color=#4f76ac]KEY[/color] `EventName_t` (`EventName_t`),
    FULLTEXT [color=#4f76ac]KEY[/color] `Address_Name_t` (`Address_Name_t`),
    FULLTEXT [color=#4f76ac]KEY[/color] `Address_Name2_t` (`Address_Name2_t`),
    FULLTEXT [color=#4f76ac]KEY[/color] `City_t` (`City_t`),
    FULLTEXT [color=#4f76ac]KEY[/color] `State_t` (`State_t`),
    FULLTEXT [color=#4f76ac]KEY[/color] `Website_t` (`Website_t`),
    FULLTEXT [color=#4f76ac]KEY[/color] `Description_t` (`Description_t`)
    ) ENGINE=MyISAM [color=#4f76ac]DEFAULT[/color] CHARSET=latin1 AUTO_INCREMENT=7 ;
    

     

    JQuery

    
    
    $(document).ready(function() {
    contact.initEventHandlers();
    });
    var contact = {
    initEventHandlers : function() {
    /* clicking the submit form */
    $('#send').bind('click',function(event){
    $('#loader').show();
    setTimeout('contact.ContactFormSubmit()',500);
    });
    /* remove messages when user wants to correct (focus on the input) */
    $('.inplaceError',$('#ContactForm')).bind('focus',function(){
    var $this = $(this);
    var $error_elem = $this.next();
    if($error_elem.length)
    $error_elem.fadeOut(function(){$(this).empty()});
    $('#success_message').empty();
    });
    /* user presses enter - submits form */
    $('#ContactForm input,#ContactForm textarea').keypress(function (e) {
    if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
    $("#send").click();
    return false;
    }
    else
    return true;
    });
    },
    ContactFormSubmit : function() {
    $.ajax({
    type : 'POST',
    url : 'PHP/contact.php?ts='+new Date().getTime(),
    dataType : 'json',
    data : $('#ContactForm').serialize(),
    success : function(data,textStatus){
    //hide the ajax loader
    $('#loader').hide();
    if(data.result == '1'){
    //show success message
    $('#success_message').empty().html('Message sent');
    //reset all form fields
    $('#ContactForm')[0].reset();
    //envelope animation
    $('#envelope').stop().show().animate({'marginTop':'-175px','marginLeft':'-246px','width':'492px','height':'350px','opacity':'0'},function(){
    $(this).css({'width':'246px','height':'175px','margin-left':'-123px','margin-top':'-88px','opacity':'1','display':'none'});
    });
    }
    else if(data.result == '-1'){
    for(var i=0; i < data.errors.length; ++i ){
    if(data.errors[i].value!='')
    $("#"+data.errors[i].name).next().html('<span>'+data.errors[i].value+'</span>').fadeIn();
    }
    }
    },
    error : function(data,textStatus){}
    });
    }
    };
    

  9. sorry, I wasn't clear with that. I want to add a unique ID to the row in the HTML so that my JQuery will work, so it would need to be

    
    
    <table>
    <tr class="parent" id="row1" title="click to expand">
    <td>Name to be clicked</td>
    <tr>
    <tr class="child-row1">
    <td>More Info</td>
    </tr>
    
    <tr class="parent" id="row2" title="click to expand">
    <td>Another Name to be clicked</td>
    <tr>
    <tr class="child-row2">
    <td>More Info</td>
    </tr>
    </table>
    

  10. I am displaying data in an html table from MySQL via PHP. I am trying to implement JQuery show/hide functionality, but in order for it to work, I need to make some adjustments in the PHP. Currently since my code is within a loop each row will have the same ID as I have it now, and I need each row to have a unique ID, so that you can open and close reach parent row independently.

     

    Currently it is.

    <table>
    <tr class="parent" id="row1" title="click to expand">
    <td>Name to be clicked</td>
    <tr>
    <tr class="child-row1">
    <td>More Info</td>
    </tr>
    
    <tr class="parent" id="row1" title="click to expand">
    <td>Another Name to be clicked</td>
    <tr>
    <tr class="child-row1">
    <td>More Info</td>
    </tr>
    </table>
    

     

    code I am using to pull in the data

     

    
    <?php
    $host="localhost";
    $username="uname";
    $password="pw";
    $database="DB";
    
    mysql_connect($host,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    $results = mysql_query('SELECT * FROM organization ORDER BY notes_tdate_created_d ASC');
    $results_array = array();
    while ($row = mysql_fetch_array($results)) {
    $results_array[$row['id']] = $row;
    }
    ?>
    
    
    <?php foreach ($results_array as $id => $record) { ?>
    <tr class="parent" id="Org" title="click for more organizational information">
    
    <td colspan="8" class="OrgName"><?php echo $record['company_t'];?></td></td>
    </tr>
    
    <tr class="child-Org">
    <th>Address 1</th>
    <th>Address 2</th>
    <th>City</th>
    <th>State</th>
    <th>Zip</th>
    <th>Phone Number</th>
    <th>Email</th>
    <th>Website</th>
    </tr>
    
    <tr class="child-Org">
    <td><?php echo $record['address1_t'];?></td>
    <td><?php echo $record['address2_t'];?></td>
    <td><?php echo $record['city_t'];?></td>
    <td><?php echo $record['state_t'];?></td>
    <td><?php echo $record['zip_t'];?></td>
    <td><?php echo $record['phone_t'];?></td>
    <td><a href="mailto:<?php echo $record['email_t'];?>"><?php echo $record['email_t'];?></a></td>
    <td><a href="http://<?php echo $record['url_t'];?>"><?php echo $record['url_t'];?></a></td>
    </tr>
    <tr class="child-Org">
    <td colspan="8">
    <?php echo $record['profile_t'];?></td>
    
    </tr>
    <?php } ?>
    

  11. I sort of have this working, but it's kind of in reverse of what I want it to do. The child rows are displaying until you click the parent row, and then they are hidden. I would like the reverse to occur. I want the child rows to be hidden until clicked and then they display. Here is my code.

    
    <script type="text/javascript">
    $(function() {
    $('tr.parent')
    .css("cursor","pointer")
    .attr("title","click to display more organizational information")
    .click(function(){
    $(this).siblings('.child-'+this.id).toggle();
    });
    $('tr[@class^=child-]').hide().children('td');
    });
    </script>
    

    
    <tr class="parent" id="Org" title="click for more organizational information">
    
           <td colspan="7" class="OrgName"><?php echo $record['company_t'];?></td><td><div class="arrow"></div></td>
    </tr>
    
    <tr class="child-Org">
    <td><?php echo $record['address1_t'];?></td>
    <td><?php echo $record['address2_t'];?></td>
    <td><?php echo $record['city_t'];?></td>
    <td><?php echo $record['state_t'];?></td>
    <td><?php echo $record['zip_t'];?></td>
    <td><?php echo $record['phone_t'];?></td>
    <td><a href="mailto:<?php echo $record['email_t'];?>"><?php echo $record['email_t'];?></a></td>
    <td><a href="http://<?php echo $record['url_t'];?>"><?php echo $record['url_t'];?></a></td>
    </tr>
    <tr class="child-Org">
    <td colspan="7">
    <?php echo $record['profile_t'];?></td>
    
    </tr>
    

  12. I am using some JQuery to show and hide tables rows on click. It actually works well, but what I would really need to do is show multiple table rows on a click event. Currently I am only showing the subsequent first child row from the row being clicked. Not sure how I would show more than the one row, so that is what I need help with. Here is my current code.

     

    The HTML

    <table id="MyTable">
    
    <tr>
    <td>data 1</td>
    <td>data 2</td>
    <td>data 3</td>
    
    </tr>
    <tr>
    <td colspan="3">
    <h4>Additional information</h4>
    <ul>
    <li><a href="">link 1</a></li>
    <li><a href="">link 2</a></li>
    <li><a href="">link 3</a></li>
    </ul>
    </td>
    </tr>
    <tr><td>Currently, I can't be hidden and displayed, but I would like to be!</td></tr>
    </table>
    

    Javascript

    
    <script type="text/javascript">
    $(document).ready(function(){
    $("#MyTable tr:odd").addClass("odd");
    $("#MyTable tr:not(.odd)").hide();
    $("#MyTable tr:first-child").show();
    
    $("#MyTable tr.odd").click(function(){
    $(this).next("tr").toggle();
    $(this).find(".arrow").toggleClass("up");
    });
    //$("#MyTable").jExpand();
    });
    </script>
    

     

    JQuery

    
    (function($){
    $.fn.jExpand = function(){
    var element = this;
    
    $(element).find("tr:odd").addClass("odd");
    $(element).find("tr:not(.odd)").hide();
    $(element).find("tr:first-child").show();
    
    $(element).find("tr.odd").click(function() {
    $(this).next("tr").toggle();
    });
    
    }
    })(jQuery);
    

  13. I am trying to validate a phone number when submitting a form. The code I am using to validate is

     

    
    /* Phone Number Validation */
    if(!mb_eregi("/[0-9]/","-",$phone))
    $this->setError('phone', 'invalid phone number');
    elseif(mb_strlen(trim($phone)) > 12)
    $this->setError('phone', 'too long! 12 characters');
    

     

    I want the format to be 123-123-1234

     

    I get an invalid phone number display when I test and enter the phone number in that format. I must have something wrong. The phone name is set right and the variable $phone is right. Anything else to check?

×
×
  • 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.