Jump to content

clausowitz

Members
  • Posts

    79
  • Joined

  • Last visited

    Never

Posts posted by clausowitz

  1. I did reload the pages.

    With the POST you mean in the target php page I guess.

    <?php
    // Start_session, check if user is logged in or not, and connect to the database all in one included file
    include_once("scripts/checkuserlog.php");
    $q_id=$_POST['id'];
    $q_rating=$_POST['rating'];
    $sql = mysql_query("UPDATE restaurants SET votes= votes + 1, rating='".$q_rating."' WHERE id='".$q_id."' LIMIT 1");
    
    ?>

  2. PFMaBiSmAd,

     

    that is what I have been trying all along. except my first line was:

    var dataString = 'id='+ id + '&rating=' + result;

    It doesn't work however.

    When I add the variables in the URL like you suggested the database gets updated but not through the ajax function.

     

    I have no clue,

    MArco

  3. <?php
    // Start_session, check if user is logged in or not, and connect to the database all in one included file
    include_once("scripts/checkuserlog.php");
    include("scripts/check_page_name.php");
    ?>
    <?php
    ////////////////////////////////////////////////      Member log in double check       ///////////////////////////////////////////////////
    if (!isset($_SESSION['idx'])) { 
        $msgToUser = '<br /><br /><font color="#FF0000">Only site members can do that</font><p><a href="register.php">Join Here</a></p>';
        include_once 'msgToUser.php'; 
        exit(); 
    } else if ($logOptions_id != $_SESSION['id']) {
    $msgToUser = '<br /><br /><font color="#FF0000">Only site members can do that</font><p><a href="register.php">Join Here</a></p>';
        include_once 'msgToUser.php'; 
        exit(); 
    }
    
    // DEFAULT QUERY STRING
    $queryString = "ORDER BY name";
    // DEFAULT MESSAGE ON TOP OF RESULT DISPLAY
    $queryMsg = "Showing Restaurants in alfabetical order.";
    
    $status_name = 'checked';
    $status_food = 'unchecked';
    $status_rating = 'unchecked';
    
    // IF WE HAVE A SESSION THEN FILL $OPTION WITH A VALUE
    if(isset($_POST['submit'])) {
       		$_SESSION['order'] = $_POST['status'];
    }
    if(isset($_SESSION['order'])) {
    if($_SESSION['order'] == 'name') { $status_name = 'checked'; }
    if($_SESSION['order'] == 'food') { $status_food = 'checked'; }
    if($_SESSION['order'] == 'rating') { $status_rating = 'checked'; }
    	$what = $_SESSION['order'];
        	$queryString = "ORDER BY $what";
    	if($what == 'rating') { $queryString = "ORDER BY $what DESC";
    	   }
    }  // end of if(isset($_SESSION....
    /////////////// END SET UP FOR SEARCH CRITERIA QUERY SWITCH MECHANISMS */////////////
    
    //////////////  QUERY THE MEMBER DATA USING THE $queryString variable's value
    $sql = mysql_query("SELECT * FROM restaurants $queryString");  // WHERE email_activated='1' ORDER BY id ASC"); 
    //////////////////////////////////// Adam's Pagination Logic ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    $outputList = '';
    $nr = mysql_num_rows($sql); // Get total of Num rows from the database query
    if ($nr){  // if we found any records we will proceed
    if (isset($_GET['pn'])) { // Get pn from URL vars if it is present
        $pn = preg_replace('#[^0-9]#i', '', $_GET['pn']); // filter everything but numbers for security(new)
        //$pn = ereg_replace("[^0-9]", "", $_GET['pn']); // filter everything but numbers for security(deprecated)
    } else { // If the pn URL variable is not present force it to be value of page number 1
        $pn = 1;
    } 
    //This is where we set how many database items to show on each page 
    $itemsPerPage = 10; 
    // Get the value of the last page in the pagination result set
    $lastPage = ceil($nr / $itemsPerPage);
    // Be sure URL variable $pn(page number) is no lower than page 1 and no higher than $lastpage
    if ($pn < 1) { // If it is less than 1
        $pn = 1; // force if to be 1
    } else if ($pn > $lastPage) { // if it is greater than $lastpage
        $pn = $lastPage; // force it to be $lastpage's value
    } 
    // This creates the numbers to click in between the next and back buttons
    $centerPages = ""; // Initialize this variable
    $sub1 = $pn - 1;
    $sub2 = $pn - 2;
    $add1 = $pn + 1;
    $add2 = $pn + 2;
    if ($pn == 1) {
    $centerPages .= '  <span class="pagNumActive">' . $pn . '</span>  ';
    $centerPages .= '  <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a>  ';
    } else if ($pn == $lastPage) {
    $centerPages .= '  <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a>  ';
    $centerPages .= '  <span class="pagNumActive">' . $pn . '</span>  ';
    } else if ($pn > 2 && $pn < ($lastPage - 1)) {
    $centerPages .= '  <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub2 . '">' . $sub2 . '</a>  ';
    $centerPages .= '  <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a>  ';
    $centerPages .= '  <span class="pagNumActive">' . $pn . '</span>  ';
    $centerPages .= '  <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a>  ';
    $centerPages .= '  <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add2 . '">' . $add2 . '</a>  ';
    } else if ($pn > 1 && $pn < $lastPage) {
    $centerPages .= '  <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a>  ';
    $centerPages .= '  <span class="pagNumActive">' . $pn . '</span>  ';
    $centerPages .= '  <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a>  ';
    }
    // This line sets the "LIMIT" range... the 2 values we place to choose a range of rows from database in our query
    $limit = 'LIMIT ' .($pn - 1) * $itemsPerPage .',' .$itemsPerPage; 
    // Now we are going to run the same query as above but this time add $limit onto the end of the SQL syntax
    // $sql2 is what we will use to fuel our while loop statement below
    $sql2 = mysql_query("SELECT * FROM restaurants $queryString $limit") ; 
    //////////////////////////////// END Adam's Pagination Logic ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////// Adam's Pagination Display Setup ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    $paginationDisplay = ""; // Initialize the pagination output variable
    // This code runs only if the last page variable is not equal to 1, if it is only 1 page we require no paginated links to display
    if ($lastPage != "1"){
        // This shows the user what page they are on, and the total number of pages
        $paginationDisplay .= 'Page <strong>' . $pn . '</strong> of ' . $lastPage. '<img src="images/clearImage.gif" width="48" height="1" alt="Spacer" />';
    // If we are not on page 1 we can place the Back button
        if ($pn != 1) {
        $previous = $pn - 1;
    	$paginationDisplay .=  '   <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $previous . '"> Back</a> ';
        } 
        // Lay in the clickable numbers display here between the Back and Next links
        $paginationDisplay .= '<span class="paginationNumbers">' . $centerPages . '</span>';
        // If we are not on the very last page we can place the Next button
        if ($pn != $lastPage) {
            $nextPage = $pn + 1;
    	$paginationDisplay .=  '   <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $nextPage . '"> Next</a> ';
        } 
    }
    
    ///////////////////////////////////// END Adam's Pagination Display Setup ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Build the Output Section Here
    $status = '';
    
    $i = 0;
    while($row = mysql_fetch_array($sql2)) { 
    
    $id = $row["id"];
    $name = $row["name"];
    $food = $row["food"];
    $address = $row["address"];
    $telephone = $row["telephone"];
    $rating = $row["rating"];
    $votes = $row["votes"];
    
    ///////  Mechanism to Display Pic. See if they have uploaded a pic or not  //////////////////////////
    $check_pic = "images/restaurants/$id.jpg";
    if (file_exists($check_pic)) {
        $user_pic = "<img src=\"$check_pic\" width=\"150px\" heigth=\"100px\" border=\"0\" />"; // forces picture to be 120px wide and no more
    } else {
    $user_pic = "<img src=\"images/no_map.png\" width=\"150px\" heigth=\"100px\" border=\"0\" />"; // forces default picture to be 120px wide and no more
    }
    $i++;	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Assign star image
    if ($rating <= 0  ){$rater_stars = "0px";}
    if ($rating >= 1  ){$rater_stars = "25px";}
    if ($rating >= 2  ){$rater_stars = "50px";}
    if ($rating >= 3  ){$rater_stars = "75px";}
    if ($rating >= 4  ){$rater_stars = "100px";}
    if ($rating >= 5  ){$rater_stars = "125px";}
    
    $star = '<ul class="star-rating">
    <li class="current-rating" id="current-rating'.$id.'" style="width: '.$rater_stars.'"></li>
    <li><a href="javascript:void(0)" onclick="vote(1,'.$votes.','.$rating.','.$id.'); return false;" 
               title="1 star out of 5" class="one-star"></a></li>
    <li><a href="javascript:void(0)" onclick="vote(2,'.$votes.','.$rating.','.$id.'); return false;" 
               title="2 star out of 5" class="two-stars"></a></li>
    <li><a href="javascript:void(0)" onclick="vote(3,'.$votes.','.$rating.','.$id.'); return false;" 
               title="3 star out of 5" class="three-stars"></a></li>
    <li><a href="javascript:void(0)" onclick="vote(4,'.$votes.','.$rating.','.$id.'); return false;" 
               title="4 star out of 5" class="four-stars"></a></li>
    <li><a href="javascript:void(0)" onclick="vote(5,'.$votes.','.$rating.','.$id.'); return false;" 
               title="5 star out of 5" class="five-stars"></a></li>
    </ul><div id="current-rating-result"></div>';
    
    if ($i&1) { $outputList .= '<table width="100%" cellpadding="4" style="background-color: #FFFFFF; border="0">'; }
    else { $outputList .= '<table width="100%" cellpadding="4" style="background-color: #E7F3FE; border="0">';  }
    $outputList .= '<tr>
    <td>  </td>
    </tr><tr>
       <td width="12%" rowspan="6"><div style=" height:125px; overflow:hidden;">' . $user_pic . '</div></td>
       <td width="10%" class="style7"><div valign="right">Name:  </div></td>
       <td colspan="2"><font color="#3300CC"><b>' . $name . '</b></font></a> </td>
    </tr>
    <tr>
       <td width="10%" ><div valign="right">Food:</div></td>
       <td width="48%" valign="left">' . $food . ' </td>
       <td width="28%" valign="left"><div align="right">'.$star.'
       </div></td>
       <td width="2%" > </td>
    </tr>
    <tr>
       <td width="10%" ><div valign="right">Address:</div></td>
       <td colspan="2" width="48%" valign="left">' . $address . ' </td>
    </tr>
    <tr>
       <td width="10%" ><div valign="right">Telephone:</div></td>
       <td width="48%" valign="left">' . $telephone . ' </td>
    </tr><tr>
    <td>  </td>
    </tr>
    </table>
    ';
    } 
    }
    
    // close while //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////// END QUERY THE MEMBER DATA & Build the Output Section ////////////////////////////
    
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Catering, Restaurants and Entertainment</title>
    <link href="style/stars.css" rel="stylesheet" type="text/css" />
    <link href="style/main.css" rel="stylesheet" type="text/css" />
    <link rel="icon" href="favicon.ico" type="image/x-icon" />
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <script src="js/jquery-1.4.2.js" type="text/javascript"></script>
    <style type="text/css">
    <!--
    .pagNumActive {
    color: #000;
    border:#060 1px solid; background-color: #D2FFD2; padding-left:3px; padding-right:3px;
    }
    .paginationNumbers a:link {
    color: #000;
    text-decoration: none;
    border:#999 1px solid; background-color:#F0F0F0; padding-left:3px; padding-right:3px;
    }
    .paginationNumbers a:visited {
    color: #000;
    text-decoration: none;
    border:#999 1px solid; background-color:#F0F0F0; padding-left:3px; padding-right:3px;
    }
    .paginationNumbers a:hover {
    color: #000;
    text-decoration: none;
    border:#060 1px solid; background-color: #D2FFD2; padding-left:3px; padding-right:3px;
    }
    .paginationNumbers a:active {
    color: #000;
    text-decoration: none;
    border:#999 1px solid; background-color:#F0F0F0; padding-left:3px; padding-right:3px;
    }
    -->
    </style>
    <script language="javascript" type="text/javascript">
    function vote(x,votes,rating,id) {
    			current_rate =x+rating;
    		mem = votes+1;
    		sum = current_rate/mem;
    		result = sum.toFixed(1)
    		rating = result * 25;
    		document.getElementById('current-rating'+id).style.width = rating+'px';
    		document.getElementById('current-rating'+id).innerHTML= 'Thanks for your vote!<br />'
    	    var dataString = 'id='+ x + '&rating=' + result;
    		$.ajax({
    		   type: "POST",
    		   url: "score.php?id='+x+&rating='+result+" , // page where insertion to database should have made
    		   success: function(msg){
    			 alert("Counter updated" );
    		   }
    		 });
    }
    
    </script>
    </head>
    <body>
    <?php include_once "header_template.php"; ?>
    <table width="900" border="0" style="background-color: #F2F2F2; border:#CCC 1px solid;" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="738" valign="top"><div><?php include_once "leaderBoardAd.php"; ?></div>
          <div style="margin-left:64px; margin-right:64px;">
            <h2><span class="textsize15">List of <?php echo $nr; ?> restaurants.</span><br /><br />
          <table width="105%" align="center" border="0" cellpadding="6">
          <tr>
            <td bgcolor="#F2F2F2" width="30%"><form id="form1" name="form1" method="post" action="restaurants.php">
              <input name='status' type='radio' id='choose' value='name' <?PHP print $status_name; ?> />Order by Name 
            </td>
            <td bgcolor="#F2F2F2" width="29%">
              <input name='status' type='radio' id='choose' value='food' <?PHP print $status_food; ?>/>Order by Food
            </td>
            <td bgcolor="#F2F2F2" width="41%">
              <input name='status' type='radio' id='choose' value='rating' <?PHP print $status_rating; ?>/>
              Order By Rating                 
              <input name="submit" type="submit" id="submit" value="Go" />
            </form></td>
          </tr>
        </table> 
          </h2>
          </div>
          <div style="margin-left:58px; margin-right:58px; padding:6px; background-color:#FFF; border:#999 1px solid;"><?php echo $paginationDisplay; ?></div>
          <table width="80%" align="center" cellpadding="6">
            <tr>
              <td><?php //echo "$queryMsg"; ?><br /><br />
    <?php echo "$outputList"; ?></td>
            </tr>
          </table>
          <div style="margin-left:58px; margin-right:58px; padding:6px; background-color:#FFF; border:#999 1px solid;"><?php echo $paginationDisplay; ?></div>
    <br /><br /><br /></td>
        <td width="160" valign="top"><?php include_once "right_AD_template.php"; ?></td>
      </tr>
    </table>
    <?php include_once "footer_template.php"; ?>
    </body>
    </html>
    

  4. Hi All,

     

    I have this php code to update my database but it doesn't work.

    <?php
    // Start_session, check if user is logged in or not, and connect to the database all in one included file
    include_once("../scripts/checkuserlog.php");
    $q_id=$_GET['id'];
    $q_rating=$_GET['rating'];
    $sql = mysql_query("UPDATE restaurants SET votes= votes + 1, rating='".$q_ratin."' WHERE id='".$q_id."' LIMIT 1");
    
    ?>

     

    The page gets fed by an AJAX call. But I cannot check if any values get to the php page.

     

    <script language="javascript" type="text/javascript">
    function vote(x,votes,rating,id) {
    			current_rate =x+rating;
    		mem = votes+1;
    		sum = current_rate/mem;
    		result = sum.toFixed(1)
    		rating = result * 25;
    		document.getElementById('current-rating'+id).style.width = rating+'px';
    		document.getElementById('current-rating'+id).innerHTML= 'Thanks for your vote!<br />'
    	    var dataString = 'id='+ x + '&rating=' + result;
    		$.ajax({
    		   type: "POST",
    		   url: "score.php?id='+x+&rating='+result+" , // page where insertion to database should have made
    		   success: function(msg){
    			 alert("Counter updated" );
    		   }
    		 });
    }
    
    </script>

     

    MArco

  5. I created a javascript session variable±

     

    function change(x) {

     

        sessvars.grid = document.getElementById(x).alt;

     

    }

     

    Now I want to pass the variable to the url but it doesn´t work±

     

    <div align="right" style="padding:4px; background-color:#D2F0D3;"><a href="#" onclick="return false" onmousedown="javascript:toggleViewMap('google_map');">close map</a></div>

    <iframe width="550" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/api/staticmap?center='+sessvars.grid&zoom=12&markers=color:red|label:B|'+sessvars.grid&size=550x300&sensor=false">"></iframe>

    <div align="left" style="padding:4px; background-color:#D2F0D3;"><a href="#" onclick="return false" onmousedown="javascript:toggleViewMap('google_map');">close map</a></div>

        </div>

     

    Any thought=

  6. I have a script that will display a google map on my form.

    The lat and lon for the google map are stored in a hidden textbox.

    I use a javascript to retrieve the value of the textbox:

     

    <script type="text/javascript">document.getElementById('MyTextBox').value</script>

     

    Now I want to use this value, which is something like `30.123456, 29.123456` in the string:

     

    <div align="right" style="padding:4px; background-color:#D2F0D3;"><a href="#" onclick="return false" onmousedown="javascript:toggleViewMap('google_map');">close map</a></div>

    <iframe width="550" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/api/staticmap?center='<?php echo ("javascript:document.getElementById('MyTextBox').value"); ?>'&zoom=12&markers=color:red|label:B|'<?php echo ("javascript:document.getElementById('MyTextBox').value"); ?>'&size=550x300&sensor=false">">'</iframe>

    <div align="left" style="padding:4px; background-color:#D2F0D3;"><a href="#" onclick="return false" onmousedown="javascript:toggleViewMap('google_map');">close map</a></div>

        </div>

     

    This code doesn´t return the values, what is wrong?

     

    Marco

  7. There is not the problem. All the buttons have the right lat and lon in the alt of the image.

    <?php $grid = '<a href="#" onclick="return false" onmousedown="javascript:toggleViewMap(\'google_map\');"><img src="images/btn-viewMap.gif" border="0" alt="'. $lat . ',' . $lon . '"></a>'; } else { $grid = '<img src="images/no_map.png" width="150" height="100" border="0"/>';} ?> 

     

    The question is how do I pass them on to the code which opens the google map.

  8. they are in my database.

     

    <?php
    $sql = mysql_query("SELECT * FROM shops WHERE type='bookshop'"); 
    while($row = mysql_fetch_array($sql)) { 
    
    $id = $row["id"];
    $name = $row["name"];
    $address = $row["address"];
    $telephone = $row["telephone"];
    if ($row["website"]){
    	$website = $row["website"] ;
    }
    $rating = $row["rating"];
    $lat = $row["lat"];
    $lon = $row["lng"]; ?>

  9. Hi,

     

    I need to get some lat and lon for a google map from an button being clicked.

     

    <?php $grid = '<a href="#" onclick="return false" onmousedown="javascript:toggleViewMap(\'google_map\');"><img src="images/btn-viewMap.gif" border="0" alt="'. $lat . ',' . $lon . '"></a>'; } else { $grid = '<img src="images/no_map.png" width="150" height="100" border="0"/>';} ?> 

     

    I load some buttons on the form with different lat lon for a location of a shop.

    Then when I click the button I want the lat lon loaded in a google map.

    <div id="google_map">
    <div align="right" style="padding:4px; background-color:#D2F0D3;"><a href="#" onclick="return false" onmousedown="javascript:toggleViewMap('google_map');">close map</a></div>
    <?php echo'<iframe width="550" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/api/staticmap?center='. $lat .',' . $lon . '&zoom=12&markers=color:red|label:B|' .$lat . ',' . $lon . '&size=550x300&sensor=false">">';?></iframe>
    <div align="left" style="padding:4px; background-color:#D2F0D3;"><a href="#" onclick="return false" onmousedown="javascript:toggleViewMap('google_map');">close map</a></div>
        </div>

     

    With  the code I have now I always get the same lat lon. How can I read the correct lat lon?

     

  10. I have some code to delete posted messages. However when no checkbox has been checked and I go to the delete page I get an error.

    Unidentified index checkbox. Is there a way to prevent this?

     

    <?php $outputList .=  '<td width="10%" ><div class="name" align="left"><input type="checkbox" name="checkbox[]" id="checkbox[]" value="' . $id . '" /></div></td>'; ?>

     

    <?php
    
    $checkbox = '';
    $result = '';
    
    if($_POST['delete']&& $_POST['checkbox'] <> '') // from button name="delete"
     {
    $checkbox = $_POST['checkbox']; //from name="checkbox[]"
    	 $countCheck = count($_POST['checkbox']);
    
    for($i=0;$i<$countCheck;$i++)
    	 {
    		 $del_id  = $checkbox[$i];
    
    $sql = "DELETE from bulletin_board where id = $del_id";
    $result = mysql_query($sql);
    
    	 }
    		 if($result)
    	 {	
    			 header('Location: bb_index.php');
    		 }
    		 else
    		 {
    echo "Error: ".mysql_error();
    		 }
     } else {
    		 $msgToUser = '<br /><br /><font color="#FF0000">No messages were checked to delete.</font><p><a 	href="bb_index.php">Go Back</a></p>';
        include_once 'msgToUser.php';
     }
    ?>

  11. Hi,

     

    I use a page to post a message on a bulletin board. When I send the POST to the next page which deals with the  process of saving the message, two variables get recognized but the third not. $name=$_POST['name']; and $message=$_POST['message']; get recognized but $image=$_POST['image']; not.

    and I get the famous error Notice: Undefined index: image.

     

    I don't see the difference between them.

    <?php
    $pageDisplay = '<form name="new_message" enctype="multipart/form-data" action="news/post.php" method="post"><p>Welcome <b>'. $logOptions_username . '</b> post your message here.<br></p>
    <input type="hidden" name="post" value="yes">
    <p>
    Heading<br>
    <input type="text" name="name" size="50">
    </p>
    <p>
    Message<br>
    <textarea name="message" rows="5" cols="50"></textarea>
    </p>
    <p>
    Picture<br>
    <input name="image" type="file"> [under construction]
    </p>
    <p>
    <input type="submit" value=\'Post Message\'>
    <input type="reset" value="Reset">
    </p>
    </form>';
    ?>
    

     

    Marco

  12. Hi All,

    I have a month calendar on my homepage I want to be able to refresh it when the user clicks next month or last month with AJAX.

    That way not the whole page gets refreshed. When the user clicks next month there will normally be a php POST with a variable that gives the date like for example:

    index.php?date=1313013600. That should be given with the AJAX code I believe.

     

    <?php if(!isset($_REQUEST['date'])){ 
       $date = mktime(0, 0, 0, date('m'),  date('d'),  date('Y')); 
    } else { 
       $date = $_REQUEST['date']; 
    } 
    
    // Build Previous and Next Links 
    $previous_link = "<a href=\"".$_SERVER['PHP_SELF']."?date="; 
    if($month == 1){ 
       $previous_link .= mktime(0, 0, 0, 12, $day, ($year -1)); 
    } else { 
       $previous_link .= mktime(0, 0, 0, ($month -1), $day, $year); 
    } 
    $previous_link .= "\"><< Prev</a>"; 
    
    $next_link = "<a href=\"".$_SERVER['PHP_SELF']."?date="; 
    if($month == 12){ 
       $next_link .= mktime(0, 0, 0, 1, $day, ($year + 1)); 
    } else { 
       $next_link .= mktime(0, 0, 0, ($month +1), $day, $year); 
    } 
    $next_link .= "\">Next >></a>"; ?> 

     

    Is there anyone who knows how to do this? This is my first AJAX experience.

    Marco

  13. I have a calendar displayed in my index.php. When I click next month the whole page gets refreshed.

    Is there a way that the calendar refreshes without doing the whole page?

     

     <?php if (isset($_SESSION['idx'])) {
        echo '<div class="container" style="font-size:15px; margin-bottom:5px;">
    	<table width="97%" border="0">
              <tr>
                <td width="78%" ><div style="font-size:15px;"><strong>MAAC Calendar</strong></div></td>
                <td width="11%"><a href="calen.php"><img src="images/calendar.png" alt="Add or Edit events in the calendar" border="0" align="left" width="30" height="30" /></a></td></tr></table><p>';
    		include_once "mijnkalender.php";
           echo ' </p>
          </div><br />';}
          ?>

     

    The problem start I guess where the calendar sends variables when the page goes to the next month.

    <?php if(!isset($_REQUEST['date'])){ 
       $date = mktime(0, 0, 0, date('m'),  date('d'),  date('Y')); 
    } else { 
       $date = $_REQUEST['date']; 
    } 
    
    // Build Previous and Next Links 
    $previous_link = "<a href=\"".$_SERVER['PHP_SELF']."?date="; 
    if($month == 1){ 
       $previous_link .= mktime(0, 0, 0, 12, $day, ($year -1)); 
    } else { 
       $previous_link .= mktime(0, 0, 0, ($month -1), $day, $year); 
    } 
    $previous_link .= "\"><< Prev</a>"; 
    
    $next_link = "<a href=\"".$_SERVER['PHP_SELF']."?date="; 
    if($month == 12){ 
       $next_link .= mktime(0, 0, 0, 1, $day, ($year + 1)); 
    } else { 
       $next_link .= mktime(0, 0, 0, ($month +1), $day, $year); 
    } 
    $next_link .= "\">Next >></a>"; ?> 

  14. I display people who have their birthday in a so called container.

    There was no problem with two people but now when there are more the container is not big enough.

    Is there a way I can make sure that the result of the query always fit?

     

    <?php if (isset($_SESSION['idx'])) {
    echo '<div class="container" style="font-size:15px; margin-bottom:5px;"><p><strong>
    Birthdays</strong></p>';
    echo "$birthday_form";
    echo '<p> </p><p> </p><p> </p>';
    echo '</div><br />';}
    ?>

     

    <?php
    $day = date('d');
    $month = date('m'); 
    $week = date('d'+7);
    $i = 0;
    
    $sql = mysql_query("SELECT * FROM myMembers WHERE birthday <> ''"); // query the member
    
    $birthday_form = '<table border="0" align="left" cellpadding="3"> ';
    while($row = mysql_fetch_array($sql)){
    $birthday_date = explode("-",$row["birthday"]);
    $birthday_year = $birthday_date[0];
    $birthday_day = $birthday_date[2];
        $birthday_month = $birthday_date[1];
    $born = $row["birthday"];
    $dayoftheweek = date('l', strtotime($born));
    $MonthDiff = date("m") - $birthday_month;
        $DayDiff = date("d") - $birthday_day;
    $YearDiff = date("Y") - $birthday_year;
    if ($DayDiff < 0 || $MonthDiff < 0) {
              $YearDiff--; }
    
    if (($birthday_day >= $day && $birthday_day <= $day+7) && $month == $birthday_month) {
    	$i++;
    	$UserID = $row["id"];
    	$firstname = $row["firstname"];
    	$lastname = $row["lastname"];
    	$birthday_month = date( 'F', mktime(0, 0, 0, $birthday_month) );
    	$birthday_form .= '<tr><td><a href="profile.php?id=' . $UserID . '" title="' . $firstname . ' ' . $lastname . '"><font color="#F00000">' . $firstname . ' ' . $lastname . '</font></a><br><font color="#999999">' . $dayoftheweek . ' ' . $birthday_day . ' ' . $birthday_month . ' - ' . $YearDiff . ' years old</font></td></tr>';
    }  
    }
    if($i == 0) {
    $birthday_form .= '<tr><td><font color="#999999">No birthdays this week.</font></td> ';
    		}
    $birthday_form .= '</tr></table> ';
    
    ?>

     

    Marco

  15. I have this code that I use to show a google map in my website.

    somehow the php variables inside the code don't display their value. When I echo them at the end of the page I do get the values but not inside these lines.

    Is there a way that I can convert these php variables into something I can just put in there without echoing?

     

     

    "http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=<?php echo "$home_address,+$residence,+$host";?>&ie=UTF8&hq=&hnear=<?php echo "$home_address,+$residence,+$host";?>&z=12&output=embed

     

    Marco

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