Jump to content

nadiam

New Members
  • Posts

    8
  • Joined

  • Last visited

Posts posted by nadiam

  1. i have an rsvp page where the table is populated by guests according to event selected in the drop down list. the rsvp table has 2 columns: guest names and status. status(radio button) is divided into 3: unconfirmed(default status), attending and not attending. user has to choose either one. but i am having trouble saving the status. tia for any help!

     

    this is the saving code:

    <?php
    if(isset($_SESSION['sess_user_id']))
    {
    	if(isset($_POST['save-rsvp']))
    	{
    		require "connection.php";
    		$name = $_POST['name'];
    		$radio = $_POST['rsvp'];
    		$session = $_SESSION['sess_user_id'];
    
    		$rsvp = $dbh->prepare("UPDATE guest SET status = ? WHERE guser_id = ? AND guest_name = ?");
    
    		$rad = implode("','", $radio);
    
    		for($i = 0; $i < count($_POST['name']); $i++)
    		{
    			if(trim($_POST['name'][$i]) !== '')// validate this form
                {
    				$rsvp->bindParam(1, $rad, PDO::PARAM_INT);
    				$rsvp->bindParam(2, $session, PDO::PARAM_INT);
    				$rsvp->bindParam(3, $name[$i], PDO::PARAM_STR);
    				$rsvp->execute();
    			}
    		}
    	}
    }
    ?>
    

    which when save doesn't save according to status selected. for example

     

    5 names: noreen, pete, marzuki, nora, mishal

     

    noreen                   unconfirmed

    pete                       attending

    marzuki                  attending

    nora                       attending

    mishal                   not attending

    micah                    not attending

     

    when saved, all is saved as unconfirmed.

     

    noreen                   not attending

    pete                      attending

    marzuki                 not attending

    nora                      attending

    mishal                   not attending

    micah                    attending

     

    when saved, all is saved as not attending.

     

    noreen                   attending

    pete                       not attending

    marzuki                 attending

    nora                      not attending

    mishal                   attending

    micah                    not attending

     

    when saved, all is saved as attending.

     

    it seems to save according to first choice.

  2. hello. i got this error and i have no idea why or what is going on. could someone explain in layman's term please and help me out.

     

     

     

    Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'event_id' cannot be null' in /home/dhsbnet/public_html/ems/add_guest.php:36 Stack trace: #0 /home/dhsbnet/public_html/ems/add_guest.php(36): PDOStatement->execute() #1 {main} thrown in /home/dhsbnet/public_html/ems/add_guest.php on line 36

     

    code being referred to, line 36 is $guests->execute() :

    if(isset($_SESSION['sess_user_id']))
    {
      if(isset($_POST['save']))
      {
        require "connection.php";
        $name = $_POST['guest-name'];
        $event = $_POST['event'];
        $session = $_SESSION['sess_user_id'];
        $status = "";
        $status .= "0";
        $guests = $dbh->prepare("INSERT INTO guest(guser_id,guest_name,event_id,status) VALUES (?,?,?,?)");
        for($i = 0; $i < count($_POST['guest-name']); $i++)
        {
          if(trim($_POST['guest-name'][$i]) !== '')
          {
            $guests->bindParam(1, $session, PDO::PARAM_INT);
            $guests->bindParam(2, $name[$i], PDO::PARAM_STR);
            $guests->bindParam(3, $event, PDO::PARAM_INT);
            $guests->bindParam(4, $status, PDO::PARAM_INT);
            $guests->execute();
            if($guests->rowCount() > 0)
            {
              echo "<script>window.location.href = 'guest_list.php';</script>";
            } 
          }
        }
      }
    }
    <div class="dropdown">
        <label>Event : <label/>
        <select name="event" id="dd-event" required>
          <option value="0" selected>Event</option>
          <?php foreach($retrieve as $r): ?>
          <option value="<?=$r['event_id']?>"><?=$r['event_name']?></option>
          <?php endforeach ?>
        </select>
      </div>
    

    in db event_id column is int, not null, not auto incremented. TIA!

  3. <link rel="stylesheet" type="text/css" media="all" href="css/fullcalendar.css">
    <script type="text/javascript" src="js/jquery.1.7.2.js"></script>
    <script type="text/javascript" src="js/fullcalendar.js"></script>
    <script type="text/javascript" src="js/fullcalendar.min.js"></script>
    
    <script type="text/javascript">
        $(document).ready(function() {
            var date = new Date();
            var d = date.getDate();
            var m = date.getMonth();
            var y = date.getFullYear();
    
            $('#calendar').fullCalendar(
            {
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,basicWeek,basicDay'
                },
                editable :true,
                events: "http://localhost/EMS2/home.php",
            });
        })
    </script>
    
    <body>
        <div id="calendar"></div>
    </body>
    
    <?php
        require "connection.php";
    
    $query = "select * from event ";
    $res = mysql_query($query) or die(mysql_error());
    $events = array();
    while ($row = mysql_fetch_assoc($res)) {
        $start = $row['start'];
        $end = $row['end'];
        $title = $row['event_name'];
        $eventsArray['title'] = $title;
        $eventsArray['start'] = $start;
        $eventsArray['end'] = $end;
        $events[] = $eventsArray;
    }
    echo json_encode($events);
    ?>
    

    im trying to get data from my database and display them into the fullcalendar but with no success. i tried with the coding above but at the top of my page [{"title":"Game of Thrones","start":"9\/5\/2014 8:30pm","end":"9\/5\/2014 12:30am","allDay":""}] and my calendar empty.

     

    any help is much appreciated.

     

  4. this is my php code for my profile.php. it is to display the users name after login.

     

     

    1. <?php
    2. session_start();
    3.  
    4. require "connect.php";
    5. if($_SESSION['name'])
    6. {
    7. $name = $_SESSION['name'];
    8. $query = mysql_query("SELECT name FROM register WHERE name ='$name'");
    9. $numrows = mysql_num_rows($query);
    10.  
    11. if(1 == $numrows)
    12. {
    13. while ($rows = mysql_fetch_assoc($query))
    14. {
    15. echo "Welcome, ".$rows['name']."!";
    16. }
    17. }
    18. }
    19.  
    20. ?>

     

    i want to display this:

     

     

    1. while ($rows = mysql_fetch_assoc($query))
    2. {
    3. echo "Welcome, ".$rows['name']."!";
    4. }

     

    between some html. ive tried but it isnt working. this is the code i did:

     

    <?php if(1 == $numrows) { ?><?php while (@$rows = mysql_fetch_assoc(@$query))?><h3><?php echo "Welcome, ".@$rows['name']; ?><?php }?>

     

    i tried:

     

    <?php while (@$rows = mysql_fetch_assoc(@$query))?><h3><?php echo "Welcome, ".@$rows['name']; ?>

     

    but both doesnt work. as in only "Welcome, " is displayed in my page.

     

    any pointers is much appreciated! :)

     

     

  5. That is my js for my tabs and as the title article entails i want the current tab to be active even after reload.
    for example my webpage has 12 tabs for each month (January, february ... etc) and as for the tab content there is a form, table and save button. say i go to the february tab and fill in the form and then click save, i want it to still stay on the feb tab page instead of reverting back to january tab page which is what it does now. how do i achieve this??

     

     

       

        var tabLinks = new Array();

    1. var contentDivs = new Array();
    2.  
    3. function init() {
    4.  
    5. // Grab the tab links and content divs from the page
    6. var tabListItems = document.getElementById('tabs').childNodes;
    7. for ( var i = 0; i < tabListItems.length; i++ ) {
    8. if ( tabListItems[i].nodeName == "LI" ) {
    9. var tabLink = getFirstChildWithTagName( tabListItems[i], 'A' );
    10. var id = getHash( tabLink.getAttribute('href') );
    11. tabLinks[id] = tabLink;
    12. contentDivs[id] = document.getElementById( id );
    13. }
    14. }
    15.  
    16. // Assign onclick events to the tab links, and
    17. // highlight the first tab
    18. var i = 0;
    19.  
    20. for ( var id in tabLinks ) {
    21. tabLinks[id].onclick = showTab;
    22. tabLinks[id].onfocus = function() { this.blur() };
    23. if ( i == 0 ) tabLinks[id].className = 'selected';
    24. i++;
    25. }
    26.  
    27. // Hide all content divs except the first
    28. var i = 0;
    29.  
    30. for ( var id in contentDivs ) {
    31. if ( i != 0 ) contentDivs[id].className = 'tabContent hide';
    32. i++;
    33. }
    34. }
    35.  
    36. function showTab() {
    37. var selectedId = getHash( this.getAttribute('href') );
    38.  
    39. // Highlight the selected tab, and dim all others.
    40. // Also show the selected content div, and hide all others.
    41. for ( var id in contentDivs ) {
    42. if ( id == selectedId ) {
    43. tabLinks[id].className = 'selected';
    44. contentDivs[id].className = 'tabContent';
    45. } else {
    46. tabLinks[id].className = '';
    47. contentDivs[id].className = 'tabContent hide';
    48. }
    49. }
    50.  
    51. // Stop the browser following the link
    52. return false;
    53. }
    54.  
    55. function getFirstChildWithTagName( element, tagName ) {
    56. for ( var i = 0; i < element.childNodes.length; i++ ) {
    57. if ( element.childNodes[i].nodeName == tagName ) return element.childNodes[i];
    58. }
    59. }
    60.  
    61. function getHash( url ) {
    62. var hashPos = url.lastIndexOf ( '#' );
    63. return url.substring( hashPos + 1 );
    64. }

     

    this is a sample of my html tab code:

    1. <ul id="tabs">
    2. <li><a href="#jan">January</a></li>
    3. <li><a href="#feb">February</a></li>
    4. <li><a href="#march">March</a></li>
    5. </ul>
    6.  
    7. <div class="tabContent" id="jan">
    8. <form method="post" action="income.php">
    9. <table border="1" rules="groups" cellpadding="10px;" class="tableincome">
    10. <thead>
    11. <th>Monthly Salary</th>
    12. <th></th>
    13. <th>RM</th>
    14. </thead>
    15. <tr>
    16. <td>Basic Salary</td>
    17. <td></td>
    18. <td><center><input type="text" name="basic" size="11" placeholder="0" value="<?php if(isset($_POST['basic'])){echo htmlentities($_POST['basic']);} ?>"></center></td>
    19. </tr>
    20. </table>
    21. <input type="submit" value="Save" class="jansave" name="jansave">
    22. </div>

    thanks in advance!

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