Jump to content

Bendude14

Members
  • Posts

    411
  • Joined

  • Last visited

    Never

Posts posted by Bendude14

  1. i spotted a few mistakes so i fixed them and added wednesday in for you too..

     

    <?php
    
    function getperiod()
    {
    date_default_timezone_set('America/Chicago');
    $mon_fri = array(725,810,815,900,906,921,927,1012,1018,1103,1109,1154,1200,1245,1250,1335,1340,1425);
    $tues_thur = array(725,813,818,907,912,1000,1005,1053,1058,1146,1151,1239,1244,1332,1337,1425);
    $wednesday = array(745,830,835,920,926,1011,1017,1102,1108,1153,1159,1244,1250,1335,1340,1425);
    $day = date('N');
    $time = date('Hi');
    
    // If it is Monday or Friday
    if (($day == 1) OR ($day == 5))
    {
    	for($i=0; $i<count($mon_fri) -1; $i++)
    	{
    		if (($mon_fri[$i] < $time) AND ($time < $mon_fri[$i+1]))
    		{
    			$period = $i+1;
    			$result = "Period $period ends at " . $mon_fri[$period];
    		}
    	}
    	//if we did not set a result school is out
    	if(empty($result))
    	{
    		echo "School is Out!";
    	}
    	//else display it
    	else
    	{
    		echo $result;
    	}
    
    }
    
    // If it is Tuesday or Thurs
    elseif (($day == 2) OR ($day == 4))
    {
    	for($i=0; $i<count($tues_thur) -1; $i++)
    	{
    		if (($tues_thur[$i] < $time) AND ($time < $tues_thur[$i+1]))
    		{
    			$period = $i+1;
    			$result = "Period $period ends at " . $tues_thur[$period];
    		}
    	}
    	if(empty($result))
    	{
    		echo "School is Out!";
    	}
    	else
    	{
    		echo $result;
    	}
    }
    
    // If it is Wednesday
    elseif ($day == 3)
    {
    	for($i=0; $i<count($wednesday) -1; $i++)
    	{
    		if (($wednesday[$i] < $time) AND ($time < $wednesday[$i+1]))
    		{
    			$period = $i+1;
    			$result = "Period $period ends at " . $tues_thur[$period];
    		}
    	}
    	if(empty($result))
    	{
    		echo "School is Out!";
    	}
    	else
    	{
    		echo $result;
    	}
    
    }
    
    elseif (($day == 6) OR ($day == 7)){ echo "It's the weekend!";}
    }
    ?>
    

  2. I did the first two for you... just wednesday left to do...

     

    <?php
    
    function getperiod()
    {
    date_default_timezone_set('America/Chicago');
    $mon_fri = array(725,810,815,900,906,921,927,1012,1018,1103,1109,1154,1200,1245,1250,1335,1340,1425);
    $tues_thur = array(725,813,818,907,912,1000,1005,1053,1058,1146,1151,1239,1244,1332,1337,1425);
    $wednesday = array(745,830,835,920,926,1011,1017,1102,1108,1153,1159,1244,1250,1335,1340,1425);
    $day = date('N');
    $time = date('Hi');
    
    // If it is Monday or Friday
    if (($day == 1) OR ($day == 5))
    {
    	for($i=0; $i<count($mon_fri); $i++)
    	{
    		if (($mon_fri[$i] < $time) AND ($time < $mon_fri[$i+1]))
    		{ 
    			$result = "Period $i ends at $mon_fri[$i]";
    		}
    	}
    	//if we did not set a result school is out
    	if(empty($result))
    	{
    		echo "School is Out!";
    	}
    	//else display it
    	else
    	{
    		echo $result;
    	}
    
    }
    
    // If it is Tuesday or Thurs
    elseif (($day == 2) OR ($day == 4))
    {
    	for($i=0; $i<count($tues_thur); $i++)
    	{
    		if (($tues_thur[$i] < $time) AND ($time < $tues_thur[$i+1]))
    		{
    			$result = "Period $i ends at $tues_thur[$i]";
    		}
    	}
    	if(empty($result))
    	{
    		echo "School is Out!";
    	}
    	else
    	{
    		echo $result;
    	}
    }
    
    // If it is Wednesday
    elseif ($day == 3)
    {
    	  if (($wednesday[0] < $time) AND ($time < $wednesday[1])){ echo "Period 1 ends at 8:30am";}
       elseif (($wednesday[2] < $time) AND ($time < $wednesday[3])){ echo "Period 2 ends at 9:20am";}
       elseif (($wednesday[4] < $time) AND ($time < $wednesday[5])){ echo "Period 4 ends at 10:11am";}
       elseif (($wednesday[6] < $time) AND ($time < $wednesday[7])){ echo "Period 5 ends at 11:02am";}
       elseif (($wednesday[8] < $time) AND ($time < $wednesday[9])){ echo "Period 6 ends at 11:53am";}
       elseif (($wednesday[10] < $time) AND ($time < $wednesday[11])){ echo "Period 7 ends at 12:44pm";}
       elseif (($wednesday[12] < $time) AND ($time < $wednesday[13])){ echo "Period 8 ends at 1:35pm";}
       elseif (($wednesday[14] < $time) AND ($time < $wednesday[15])){ echo "Period 9 ends at 2:25pm";}
       else { echo "School Is Out!";}
    
    }
    
    elseif (($day == 6) OR ($day == 7)){ echo "It's the weekend!";}
    }
    
    
    ?>
    

     

    maybe you could get the students to refine it futher as a bit of home work ;)

  3. I have a web menu that is now generated from an XML file and I was intending to use the menu.xml file to generate a sitemap whenever needed.

     

    My question is will that start to put a lot of load on the server and start to slow my site if the site gets big? Should I just write a script to write the sitemap to file and just run the script when i update the site?

     

    Thanks

    Ben

  4. thanks, instead of having a hidden form for each link i updated the hidden field before i submitted here it is if anyone else has a similar problem

     

    	function submitform(link)
    {
    	document.getElementById("hiddenMonth").value = link.innerHTML
    	form = document.getElementById("newsForm");
    	//submit form
    	form.submit();
    }

     

    and the anchor was <a href='#' onclick='submitform(this); return false;'>$month</a>

  5. thats because you want the value column this $row["site_name"] should be $row['value']

     

    you might want to try the code below if you have that many settings to retrieve.

     

    im presuming you only have two columns, setting and value this will get the value of setting and make it a variable storing the correct value inside it...

     

    $sql = "SELECT * FROM (yourprefix)_config"; 
    $result = mysql_query($sql);
    
    while ($row = mysql_fetch_row($result)) 
    {
    
    $$row[0] = $row[1];
    
    echo "KEY: " . $row[0] . " - Value: " . $row[1] . "<br />";
    
    }
    echo $site_title;
    

     

     

  6. Is it possible to add values to the post array from an anchor link?

     

    so my anchor is this <a href="news.php">January</a> is their anyway to add January to the post array which will be detected on news.php.

     

    I know i can use GET and just add it to the URL or instead of having anchors have a form which POST to news.php with buttons and style them like links, but i don't want to do this because it affects the layout to much..

     

    Ben

  7. have you had a go at this already?

     

    use this as your query

     

    "SELECT value FROM (yourprefix)_config WHERE setting = 'site_title'"

     

    This will return only one row containing your site title, have a go and post back what you have.

     

    well one row presuming you only have site_title in the setting column once, which you should have

  8. yes you need to change them to allow null as a value.

     

    As daniel said for having empty strings you are checking against that already with this code.

     

    if(empty($Gender))
       $Gender == null;
    else
       $Gender = $_POST["Gender"];   

  9. do you have a constraint on you table in mysql that does now allow null as a value? because otherwise that should work...

     

    If you check and their are no constraints on the column post your query here...

     

    When you say it doesn't work, what errors are you getting?

  10. well isset() checks if the variable was ever set.

     

    if $_POST["postedvariable"] is empty you can check this also like so

    if(empty($_POST["postedvariable"]))
    {
        //more code
    }

     

    if $_POST["postedvariable"] actually contains the value null you will have to check for this seperatly like so

     

    if($_POST["postedvariable"] == null)
    {
        //more code
    }
    

     

    with these examples you should be able to put them together and take action accordingly...

     

    Ben

  11. this error <b>URL file-access is disabled in the server configuration</b> is when you do not have acecss to a file through its absolute path... if the file is on the same server specifiy a relative path to it...

  12. well the only way you can get to the else statement for "No pictures" is if your last page equals 0. $lastpage is only set in once place which is here. 

     

    $lastpage = ceil($numrows/$rows_per_page);

     

    Now we know $rows_per_page = 1 so $numrows must be set to zero, try echoing out query_data[0] to see if it contains the correct result on each page....

     

    Ben

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