Jump to content

nadiam

New Members
  • Posts

    8
  • Joined

  • Last visited

nadiam's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. i used var_dump and the result IS null. then coz i always automatically think its a php problem i took a look instead at my html and found that the drop down wasn't in the form tags.
  2. but doesn't my ->bindParam() need to be in the loop coz of [$i] ?
  3. 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.
  4. 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. 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!
  5. <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.
  6. this is my php code for my profile.php. it is to display the users name after login. <?php session_start(); require "connect.php"; if($_SESSION['name']) { $name = $_SESSION['name']; $query = mysql_query("SELECT name FROM register WHERE name ='$name'"); $numrows = mysql_num_rows($query); if(1 == $numrows) { while ($rows = mysql_fetch_assoc($query)) { echo "Welcome, ".$rows['name']."!"; } } } ?> i want to display this: while ($rows = mysql_fetch_assoc($query)) { echo "Welcome, ".$rows['name']."!"; } 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!
  7. 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(); var contentDivs = new Array(); function init() { // Grab the tab links and content divs from the page var tabListItems = document.getElementById('tabs').childNodes; for ( var i = 0; i < tabListItems.length; i++ ) { if ( tabListItems[i].nodeName == "LI" ) { var tabLink = getFirstChildWithTagName( tabListItems[i], 'A' ); var id = getHash( tabLink.getAttribute('href') ); tabLinks[id] = tabLink; contentDivs[id] = document.getElementById( id ); } } // Assign onclick events to the tab links, and // highlight the first tab var i = 0; for ( var id in tabLinks ) { tabLinks[id].onclick = showTab; tabLinks[id].onfocus = function() { this.blur() }; if ( i == 0 ) tabLinks[id].className = 'selected'; i++; } // Hide all content divs except the first var i = 0; for ( var id in contentDivs ) { if ( i != 0 ) contentDivs[id].className = 'tabContent hide'; i++; } } function showTab() { var selectedId = getHash( this.getAttribute('href') ); // Highlight the selected tab, and dim all others. // Also show the selected content div, and hide all others. for ( var id in contentDivs ) { if ( id == selectedId ) { tabLinks[id].className = 'selected'; contentDivs[id].className = 'tabContent'; } else { tabLinks[id].className = ''; contentDivs[id].className = 'tabContent hide'; } } // Stop the browser following the link return false; } function getFirstChildWithTagName( element, tagName ) { for ( var i = 0; i < element.childNodes.length; i++ ) { if ( element.childNodes[i].nodeName == tagName ) return element.childNodes[i]; } } function getHash( url ) { var hashPos = url.lastIndexOf ( '#' ); return url.substring( hashPos + 1 ); } this is a sample of my html tab code: <ul id="tabs"> <li><a href="#jan">January</a></li> <li><a href="#feb">February</a></li> <li><a href="#march">March</a></li> </ul> <div class="tabContent" id="jan"> <form method="post" action="income.php"> <table border="1" rules="groups" cellpadding="10px;" class="tableincome"> <thead> <th>Monthly Salary</th> <th></th> <th>RM</th> </thead> <tr> <td>Basic Salary</td> <td></td> <td><center><input type="text" name="basic" size="11" placeholder="0" value="<?php if(isset($_POST['basic'])){echo htmlentities($_POST['basic']);} ?>"></center></td> </tr> </table> <input type="submit" value="Save" class="jansave" name="jansave"> </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.