Jump to content

webguy262

Members
  • Posts

    95
  • Joined

  • Last visited

Posts posted by webguy262

  1. Thanks for the response...

     

    The sitemap for the site will have links to ~200 landing pages that should ideally have url's ending in html.

     

    Rather than have to create ~200 distinct pages, I thought it might be possible to have all the xxx.html url's call the same php page, and dynamically

    serve up the various pages, with titles, keywords, alt tags, content, etc. programmed to reflect the url requested.

     

    I want to do this with pages that load as html pages, tho, not php pages with get's in the url.

     

    Thoughts?

     

  2. Working on a site with a couple hundred virtually identical landing pages to maximize SEO.

     

    Rather than hard code the pages, I am wondering if there is a way to have one page that handles all the url's and dynamically codes and loads with title, keywords, content & alt tags all specific to the particular url requested.

     

    Seems like the challenge is doing it in a way that does not constitute a redirect.

     

    Is it better to do this in the .htaccess?

     

     

  3. this does not work for me...

     

    $category=mysql_real_escape_string($_GET['category']);
    if (is_int($category)) {
    

     

    i echo out $category and confirm it is an integer and yet the if statement does not fire

     

    what am i missing?

  4. That suggestion helped me find the problem...

     

    Another form in the project displays the imploded array as a comma delimited list. I added a space after the comma in the implode statement so I could just grab the string and output it as is.  So when I ran the in_array, I was comparing strings with the extra space, against strings without the space.

     

    Thanks for your help!

  5. Thanks xyph... I'm almost there!

     

    The issue now is that only the first of several checked values comes back checked.

     

    Here's the current code...

     

    <?php
    // $session->userinfo['specialization'] is a database field.
    
    // echo $session->userinfo['specialization']; THIS WORKS AND OUTPUTS THREE VALUES AS "Automotive, Aerospace, Biotech/Life Sciences"
    
    $aSpecialization = array('Automotive', 'Aerospace', 'Biotech/Life Sciences', 'Chemicals', 'Damages Analysis', 'Electronics', 'Litigation', 'Manufacturing ', 'Materials', 'Medical Devices', 'Mobile Applications', 'Patent Prosecution', 'Physics', 'Renewable Energy', 'Semiconductors', 'Software', 'Telecommunications', 'Utilities');
    
    //converting comma separated into array using explode function
    
      $dbspecialization= explode(',',$session->userinfo['specialization']);
      
      // echo $dbspecialization; THIS IS CONFIRMED AR AN ARRAY... OOUTPUTS 'Array'
    
      foreach ($aSpecialization as $specialization) {
    
         if(in_array($specialization,$dbspecialization)) {
          echo '<input name="specialization[]" type="checkbox" value="'.$specialization.'" CHECKED> '.$specialization.' <br />';
              } else {
          echo '<input name="specialization[]" type="checkbox" value="'.$specialization.'"> '.$specialization.' <br />';
              }
        }
    ?>
    

     

    So I'm still missing something.. Thoughts?

  6. Trying to get a form to display checked and unchecked values based on what is in the database.

     

    Hard coded form works fine. I implode the array and it goes into the database as a comma delimited string.

     

    But I need to let users edit the checkbox values, so I need to create the form by exploding the string, iterating through the array, and outputting the checkbox form elements.

     

    Here's what I have...

     

    <p>Specialization: 
    <p>
    <?php
    
    //echo $session->userinfo['specialization']; THIS DISPLAYS THE STRING CORRECTLY
    
    $aSpecialization = array('Automotive', 'Aerospace', 'Biotech/Life Sciences', 'Chemicals', 'Damages Analysis', 'Electronics', 'Litigation', 'Manufacturing ', 'Materials', 'Medical Devices', 'Mobile Applications', 'Patent Prosecution', 'Physics', 'Renewable Energy', 'Semiconductors', 'Software', 'Telecommunications', 'Utilities');
    
    //converting comma separated into array using explode function
    
      $dbspecialization= explode(',',$session->userinfo['specialization']);
      
      // echo $dbspecialization; THIS IS CONFIRMED AS AN array
    
      foreach ($aSpecialization as $specialization) {
    
         if(in_array($specialization,$dbspecialization)) {
          echo '<input name="specialization[]" type="checkbox" value="$specialization" CHECKED> $aSpecialization[] <br />';
              } else {
          echo '<input name="specialization[]" type="checkbox" value="$specialization"> $aSpecialization[] <br />';
              }
        }
    ?>

     

    But the output I get is...

     

    <input name="specialization[]" type="checkbox" value="$specialization" CHECKED> $aSpecialization[] <br />
    
    <input name="specialization[]" type="checkbox" value="$specialization"> $aSpecialization[] <br />
    
    <input name="specialization[]" type="checkbox" value="$specialization"> $aSpecialization[] <br />
    
    etc...
    
    

     

    What am I missing?

  7. Trying to sort out setting a cookie that allows visitor to decide which sub domain to go directly to in subsequent visits.

     

    Somewhat complicated by the fact that the sub domains are running seprate instances of wordpress.

     

    Here's the code... any suggestions appreciated!

     

    <?php
    if (isset($_POST['submitted']))
    {
    $site=$_POST['site'];
    setcookie("SitePref",$site, time() + 60*60*24*30, 'historybee.com');
    if ($site == 'ms')
    {
    header("Location: http://ms.historybee.com/"); 
    } 
    elseif ($site == 'hs') 
    {
    		define('WP_USE_THEMES', true);
    		require('./wp-blog-header.php');
    }
    
    } else {
    
    //if we have a cookie, load the site
    if (isset($_COOKIE['SitePref'])) 
    {
    		if (($_COOKIE['SitePref']) == 'hs') {
    			define('WP_USE_THEMES', true);
    			require('./wp-blog-header.php');
    	   		} else { 
    			header("Location: http://ms.historybee.com/");
    			}
    
    } else { //if we don't have a cookie, load the form ?>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title>The National History Bee</title>
    </head>
    <body style="margin:0;padding:0;background: url('http://ms.historybee.com/wp-content/themes/makinghistoryblue/img/body_bg_hb5.jpg') repeat-x scroll center top #F2BF3B;">
    
    <div align="center" style="width:800px;margin:0 auto;background:#fff;">
    
    <p><img src="http://ms.historybee.com/wp-content/themes/makinghistoryblue/img/nhb_logo.png">
    
    <p><h1>Welcome to the National History Bee!</h1>
    
    <p>The National History Bee has both High School and Middle School competitions. 
    
    <p>Please choose which site you would like to visit.  Your choice will be remembered for 30 days.
    
    <form action= "<?php echo $_SERVER['PHP_SELF']; ?>" method ="POST">
    
    <input type="radio" name="site" value="ms"> Middle School Competition
    
    <input type="radio" name="site" value="hs"> High School Competition
    
    <input type ="hidden" name="submitted" value="true">
    
    <p><input type="submit" value="Remember My Choice">
    </form>
    <br /><br /><br />
    </div>
    </body>
    </html>
    
    <?php } } ?>

  8. Gett an error from some custom code I inherited in a WordPress installation.

     

    Here is the error...

     

    Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct() [<a href='datetime.--construct'>datetime.--construct</a>]: Failed to parse time string (--) at position 0 (-): Unexpected character' in /home2/history8/public_html/bee/wp-content/themes/makinghistoryblue/beeteachers.php:27 Stack trace: #0 /home2/history8/public_html/bee/wp-content/themes/makinghistoryblue/beeteachers.php(27): DateTime->__construct('--') #1 /home2/history8/public_html/bee/wp-includes/plugin.php(395): bee_teachers('') #2 /home2/history8/public_html/bee/wp-admin/admin.php(151): do_action('bee_teachers', Array) #3 {main} thrown in /home2/history8/public_html/bee/wp-content/themes/makinghistoryblue/beeteachers.php on line 27

     

    Here is the code...

     

    <?php
    $teachers = $wpdb->get_results("SELECT * FROM bee_teachers,bee_postmeta WHERE bee_teachers.statebee=bee_postmeta.post_id and meta_key='regional_date' ORDER BY meta_value ASC");
    $today = new DateTime();
    foreach ($teachers as $teacher):
    	$site = get_post($teacher->statebee)->post_title;
    	$date = new DateTime($teacher->meta_value); // this is line 27, mentioned in the error
    	if($date<$today) $style=' style="color:#999"';
    	else $style='';
    ?>

     

    If I remm out these lines, the query works, just no styling difference based upon date...

     

    $date = new DateTime($teacher->meta_value); // this is line 27, mentioned in the error
    	if($date<$today) $style=' style="color:#999"';
    	else $style='';

     

    Thoughts?

     

  9. changed, but still nothing...

     

    <?php
    
    include ('tempconv.class.php');
    
    $temp = new Temperature(100);
    
    echo "In Fahrenheit: " . $temp->getTemp("f");
    
    ?>

     

    <?php
    
    class Temperature
    {
       private $temperature;
    
       public function __construct($value, $units = "c")
       {
          $units = strtolower($units);
    
          if ($units !== "c")
          {
             $val = $this->convertTemp($val, $units);
          }
    
          $this->temperature = $val;
       }
    
       public function getTemp($units = "c")
       {
          $units = strtolower($units);
    
          if ($units === "c")
          {
             return $this->temperature;
          }
          else
          {
             return $this->convertTemp($this->temperature, $units);
          }
       }
    
       public function setTemp($val, $units = "c")
       {
          $units = strtolower($units);
    
          if ($units === "c")
          {
             $this->temperature = $val;
          }
          else
          {
             $this->temperature = $this->convertTemp($val, $units);
          }
       }
    
       private function convertTemp($val, $units = "c");
       {
          $units = strtolower($units);
    
          if ($units === "c")
          {
             return $val;
          }
          else ($units === "f")
          {
             return $this->convertToFahrenheit($val);
          }
       }
    
       private function convertToFahrenheit($val)
       {
          $this->val = ($this->val / 5) * 9 + 32;
       }
    }
    
    ?>

     

    Appreciate you hanging in with me on this!

  10. OK, I think I'm starting to understand at least some of this...

     

    I don't need Kelvin, so I removed that.

     

    I put the formulas in, but not totally sure I did that right.

     

    Here's what I have at this point for the class:

     

    	
    
    <?php
    
    class Temperature
    {
       private $temperature;
    
       public function __construct($value, $units = "c")
       {
          $units = strtolower($units);
    
          if ($units !== "c")
          {
             $val = $this->convertTemp($val, $units);
          }
    
          $this->temperature = $val;
       }
    
       public function getTemp($units = "c")
       {
          $units = strtolower($units);
    
          if ($units === "c")
          {
             return $this->temperature;
          }
          else
          {
             return $this->convertTemp($this->temperature, $units);
          }
       }
    
       public function setTemp($val, $units = "c")
       {
          $units = strtolower($units);
    
          if ($units === "c")
          {
             $this->temperature = $val;
          }
          else
          {
             $this->temperature = $this->convertTemp($val, $units);
          }
       }
    
       private function convertTemp($val, $units = "c");
       {
          $units = strtolower($units);
    
          if ($units === "c")
          {
             return $val;
          }
          else ($units === "f")
          {
             return convertToFahrenheit($val);
          }
       }
    
       private function convertToFahrenheit($val)
       {
          $this->val = ($this->val / 5) * 9 + 32;
       }
    }
    
    ?>
    

     

    Am I close?

  11. Thanks for the input.

     

    I now have this for set/get...

     

    <?php
    
    private $tempC = null;
    private $tempF = null;
    
    public function getTempC(){
    	return $this->tempC;
    }
    
    public function setTempC($tempC){
    	$this->tempC = $tempC;
    }
    
    public function getTempF(){
    	return $this->tempF;
    }
    
    public function setTempF($tempF){
    	$this->tempF = $tempF;
    }
    
    ?>

     

    And this for the class and the formulas...

     

    <?php
    
          class Temp {
    
          public $tempC;
          public $tempF;
          
          function ConvertCF(){  
            $this->tempF = ($this->tempC / 5) * 9 + 32;
            return $this->tempF; 
          }
    
          function ConvertFC(){  
            $this->tempC = ($this->tempF - 32) / 9 * 5;
            return $this->tempC;  
          }
          
        } 
        
    ?>

     

    But I still don't know how to bring these pieces together.

     

    A big part of my problem is I don't really understand the get/set declaration.

     

    Do I really need it?

     

  12. I'm trying to write a class with getters and setters that converts between centigrade and fahrenheit so that when one value is set, it updates the other value.

     

    I'm struggling to bring together the pieces I think I need.

     

    I've got this for the setters and getters...

     

    	private $tempC = null;
    private $tempF = null;
    
    public function getTempC(){
    	return $this->tempC;
    }
    
    public function setTempC($tempC){
    	$this->tempC = $tempC;
    }
    
    public function getTempF(){
    	return $this->tempF;
    }
    
    public function setTempF($tempF){
    	$this->tempF = $tempF;
    }

     

    And this for the rest of the class (var's and functions)...

     

    <?php
    class Temp {
    
          var $TempC;
          var $TempF;
          
          function ConvertCF(){  
            $temp = ($TempC / 5) * 9 + 32;
            return $temp;  
          }
          
          function ConvertFC(){  
            $temp = ($TempF - 32) / 9 * 5;
            return $temp;  
          }
          
        } 
    ?>

     

    But I (obvioulsy) need some direction! 

  13. This did what I needed without a subselect...

     

    SELECT t1.user, MAX(t2.logindate)
    FROM t1
    LEFT OUTER JOIN t2 l
    ON t1.user = t2.user
    GROUP BY user
    ORDER BY logindate DESC
    

     

    ...key was GROUP BY

  14. user is in table1, logindate is in table2, userid is common to both tables.

     

    need a query that returns the userid, user, and ONLY THE MOST RECENT logindate for each user.

     

    i know i need a subselect and a MAX(), but i can't get exactly what i need

     

    closest i've come is getting a single result: the userid, user and logindate for the user with the most recent lastlogin

     

    appreciate your help

  15. Thanks to all who replied.

     

    What I want is best captured by ...

     

    SELECT max(date),email FROM ... GROUP BY email

     

    It omits duplicate email address and give the latest date an email was entered.

     

    Thanks again for helping me learn!

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