Jump to content

csteff24

Members
  • Posts

    34
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

csteff24's Achievements

Member

Member (2/5)

0

Reputation

  1. Thank you! I'm not familiar with either of those methods, so sorry if I'm not making sense! CREATE TABLE `members` ( `id` int(4) NOT NULL auto_increment, `username` varchar(65) NOT NULL default '', `password` varchar(65) NOT NULL default '', `club` int(3) NOT NULL, `perm` tinyint(1) NOT NULL, `email` varchar(50) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=412 ; So in order to add the | to users with multiple clubs, do I have to go through manually, or can I do it an easier way?
  2. Right now I have a database that has a user field and a field for the ID of the club that they are advisor of The problem is that some people advise multiple clubs Right now I have them listed as seperate usernames For example: Username - ID - Password - Club John_Doe - 24 - password - 32 John_Does - 87 - password - 16 However, this causes problems when they log in - it turns into an infinite loop of some sort since there's two different users created with this same username Also, I have the name of their club show up using the Club ID, but if they have two clubs, how can I make both show up? Thank you! Let me know if this doesn't make sense...
  3. would using $SESSION_ be better than $COOKIE_ then? I'm just wondering if I do if ($_COOKIE['ID_staples_clubs'] == 'user') { $delete = "delete";} else {$delete = "";} isn't the 'user' that I'm comparing to the cookie just the word user? How do I compare it to the user that's stored?
  4. Oh, thank you! It's not coming up, though. I don't think I can compare the cookie to 'user', because I want to compare it to the user field in my database, not just the string "user" $getEvent_sql = "SELECT id, event_title, event_shortdesc, user, date_format(event_start, '%I:%i %p') AS fmt_date FROM calendar_events WHERE month(event_start) = '".$m."' AND dayofmonth(event_start) = '".$d."' AND year(event_start) = '".$y."' ORDER BY event_start"; $getEvent_res = mysqli_query($mysqli, $getEvent_sql) or die(mysqli_error($mysqli)); if (mysqli_num_rows($getEvent_res) > 0) { if ($_COOKIE['ID_staples_clubs'] == 'user') { $delete = "delete";} else {$delete = "";} $event_txt = "<ul>"; while ($ev = mysqli_fetch_array($getEvent_res)) { $event_title = stripslashes($ev["event_title"]); $event_shortdesc = stripslashes($ev["event_shortdesc"]); $id = $ev['id']; $fmt_date = $ev["fmt_date"]; $event_txt .= "<li><strong>".$fmt_date."</strong>: ".$event_title."</br>".$event_shortdesc."<br/>".$delete."</li>"; } $event_txt .= "</ul>"; mysqli_free_result($getEvent_res); } else { $event_txt = ""; }
  5. Am I trying to match the user correctly?
  6. Oh, good idea To match the user, I tried doing: if ($_COOKIE['ID_staples_clubs'] = 'user') { $delete = " ????";} else {$delete = "";} So if I have the username stored as a cookie, shouldn't ???? come up only if I'm logged in as the user who added the event? Because right now it's coming up no matter what.
  7. I have a calendar that users can add events to. When a user adds an event, it is displayed under "Today's Events" and the user that added it is saved in the calendar_events table under the user field for that event I'm trying to allow users to delete their events, but I'm not sure exactly what to do... here's the part that I'm having problems with...I know I should create a link to a delete.php file, but how would I call on the id of the event in that link? Also, right now the delete is coming up for every event, not just the ones which the user created if ($_COOKIE['ID_staples_clubs'] = 'user') { $delete = " ????";} else {$delete = "";} $event_txt .= "<li><strong>".$fmt_date."</strong>: ".$event_title."</br>".$event_shortdesc."<br/>".$delete."</li>"; } $event_txt .= "</ul>"; <html> <head> <title>Show/Add Events</title> </head> <body> <h1>Show/Add Events</h1> <?php $mysqli = mysqli_connect ------; //add new event if ($_POST) { $m = $_POST["m"]; $d = $_POST["d"]; $y = $_POST["y"]; $event_date = $y."-".$m."-".$d." ".$_POST["event_time_hh"].":".$_POST["event_time_mm"].":00"; $insEvent_sql = "INSERT INTO calendar_events (event_title, event_shortdesc, event_start, user) VALUES ('".$_POST["event_title"]."', '".$_POST["event_shortdesc"]."', '$event_date','".$_COOKIE['ID_staples_clubs']."')"; $insEvent_res = mysqli_query($mysqli, $insEvent_sql) or die(mysqli_error($mysqli)); } else { $m = $_GET["m"]; $d = $_GET["d"]; $y = $_GET["y"]; } //show events $getEvent_sql = "SELECT event_title, event_shortdesc, date_format(event_start, '%I:%i %p') AS fmt_date FROM calendar_events WHERE month(event_start) = '".$m."' AND dayofmonth(event_start) = '".$d."' AND year(event_start) = '".$y."' ORDER BY event_start"; $getEvent_res = mysqli_query($mysqli, $getEvent_sql) or die(mysqli_error($mysqli)); if (mysqli_num_rows($getEvent_res) > 0) { $event_txt = "<ul>"; while ($ev = mysqli_fetch_array($getEvent_res)) { $event_title = stripslashes($ev["event_title"]); $event_shortdesc = stripslashes($ev["event_shortdesc"]); $fmt_date = $ev["fmt_date"]; if ($_COOKIE['ID_staples_clubs'] = 'user') { $delete = " ????";} else {$delete = "";} $event_txt .= "<li><strong>".$fmt_date."</strong>: ".$event_title."</br>".$event_shortdesc."<br/>".$delete."</li>"; } $event_txt .= "</ul>"; mysqli_free_result($getEvent_res); } else { $event_txt = ""; } mysqli_close($mysqli); if ($event_txt != "") { echo "<p><strong>Today's Events:</strong></p> $event_txt <hr/>"; } if(isset($_COOKIE['ID_staples_clubs']) && isset($_COOKIE['Key_staples_clubs'])) { //show form echo " <form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\"> <p><strong>Would you like to add an event?</strong><br/> Complete the form below and press the submit button to add an event</p> <p><strong>Event Title:</strong><br/> <input type=\"text\" name=\"event_title\" size=\"25\" maxlength=\"25\" /> <p><strong>Event Description:</strong><br/> <input type=\"text\" name=\"event_shortdesc\" size=\"25\" maxlength=\"255\" /> <p><strong>Event Time (hh:mm):</strong><br/> <select name=\"event_time_hh\"> <option value=\"0\">12AM</option> <option value=\"1\">1AM</option> <option value=\"2\">2AM</option> <option value=\"3\">3AM</option> <option value=\"4\">4AM</option> <option value=\"5\">5AM</option> <option value=\"6\">6AM</option> <option value=\"7\">7AM</option> <option value=\"8\">8AM</option> <option value=\"9\">9AM</option> <option value=\"10\">10PM</option> <option value=\"11\">11PM</option> <option value=\"12\">12PM</option> <option value=\"13\">1PM</option> <option value=\"14\">2PM</option> <option value=\"15\">3PM</option> <option value=\"16\">4PM</option> <option value=\"17\">5PM</option> <option value=\"18\">6PM</option> <option value=\"19\">7PM</option> <option value=\"20\">8PM</option> <option value=\"21\">9PM</option> <option value=\"22\">10PM</option> <option value=\"23\">11PM</option> </select> : <input type=\"text\" name=\"event_time_mm\" size=\"2\" maxlength=\"2\" /> <input type=\"hidden\" name=\"m\" value=\"".$m."\"> <input type=\"hidden\" name=\"d\" value=\"".$d."\"> <input type=\"hidden\" name=\"y\" value=\"".$y."\"> <br/><br/> <input type=\"submit\" name=\"submit\" value=\"Add Event\"> </form>"; } ?> </body> </html> Thanks!
  8. I have a calendar that allows users to create events - However, if a specific date has multiple events, it only shows one How can I get them to all show up? preferably as a list... <?php ... define("ADAY", (60*60*24)); if ((!isset($_POST["month"])) || (!isset($_POST["year"]))) { $nowArray = getdate(); $month = $nowArray["mon"]; $year = $nowArray["year"]; } else { $month = $_POST["month"]; $year = $_POST["year"]; } $start = mktime (12, 0, 0, $month, 1, $year); $firstDayArray = getdate($start); ?> <html> <head> <title><?php echo "Calendar: ".$firstDayArray["month"]." ".$firstDayArray["year"]; ?></title> <script type="text/javascript"> function eventWindow(url) { event_popupWin = window.open(url, 'event', 'resizeable=yes, scrollbars=yes, toolbar=no, width=400, height=400'); event_popupWin.opener = self; } </script> <head> <body> <h1>Select a Month/Year Combination</h1> <form method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>"> <select name="month"> <?php $months = Array("January","February","March","April","May","June","July","August","September","October","November","December"); for ($x=1; $x <= count($months); $x++) { echo"<option value=\"$x\""; if ($x == $month) { echo " selected"; } echo ">".$months[$x - 1]."</option>"; } ?> </select> <select name="year"> <?php for ($x=2009; $x<=2015; $x++) { echo"<option"; if ($x == $year) { echo " selected"; } echo ">$x</option>"; } ?> </select> <input type="submit" name="submit" value="Go!"> </form> <br /> <?php $days = Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); echo "<table border=\"1\" cellpadding=\"5\"><tr>\n"; foreach ($days as $day) { echo "<td style=\"background-color: #CCCCCC; text-align: center; width: 14%\"><strong>$day</strong></td>\n"; } for ($count=0; $count < (6*7); $count++) { $dayArray = getdate($start); if (($count % 7) == 0) { if ($dayArray["mon"] != $month) { break; } else { echo "</tr><tr>\n"; } } if ($count < $firstDayArray["wday"] || $dayArray["mon"] != $month) { echo "<td> </td>\n"; } else { $chkEvent_sql = "SELECT event_title FROM calendar_events WHERE month(event_start) = '".$month."' AND dayofmonth(event_start) = '".$dayArray["mday"]."' AND year(event_start) = '".$year."' ORDER BY event_start"; $chkEvent_res = mysqli_query($mysqli, $chkEvent_sql) or die(mysqli_error($mysqli)); if (mysqli_num_rows($chkEvent_res) > 0) { $event_title = "<br/>"; while ($ev = mysqli_fetch_array($chkEvent_res)) { $event_title = stripslashes($ev["event_title"])."<br/>"; } mysqli_free_result($chkEvent_res); } else { $event_title = ""; } echo"<td valign=\"top\"><a href=\"javascript:eventWindow ('event.php?m=".$month."&d=".$dayArray["mday"]."&y=$year');\">".$dayArray["mday"]."</a><br/>".$event_title."</td>\n"; unset($event_title); $start += ADAY; } } echo "</tr></table>"; mysqli_close($mysqli); ?> </body> </html>
  9. Mod - in a very tired moment, I put up my database password...any chance I can get that deleted? Thank you!
  10. I have a calendar that users can add events to, and I had it previously so that the hour had to be entered 1 - 24. I wanted it to be 1 - 12 and users can select AM or PM The code I've done for PM isn't working. Am I making this too complicated? Thanks! <html> <head> <title>Show/Add Events</title> </head> <body> <h1>Show/Add Events</h1> <?php $mysqli = mysqli_connect ("97.74.218.110","csteffen","Summer09","csteffen"); //add new event if ($_POST) { $m = $_POST["m"]; $d = $_POST["d"]; $y = $_POST["y"]; if ($_POST["event_time_ampm"] = am) { $event_date = $y."-".$m."-".$d." ".$_POST["event_time_hh"].":".$_POST["event_time_mm"].":00"; } else if ($_POST["event_time_ampm"] = pm) { while ($hour = $_POST["event_time_hh"] + 12) { $event_date = $y."-".$m."-".$d." ".$hour.":".$_POST["event_time_mm"].":00"; }} $insEvent_sql = "INSERT INTO calendar_events (event_title, event_shortdesc, event_start) VALUES ('".$_POST["event_title"]."', '".$_POST["event_shortdesc"]."', '$event_date')"; $insEvent_res = mysqli_query($mysqli, $insEvent_sql) or die(mysqli_error($mysqli)); } else { $m = $_GET["m"]; $d = $_GET["d"]; $y = $_GET["y"]; } //show events $getEvent_sql = "SELECT event_title, event_shortdesc, date_format(event_start, '%I:%i %p') AS fmt_date FROM calendar_events WHERE month(event_start) = '".$m."' AND dayofmonth(event_start) = '".$d."' AND year(event_start) = '".$y."' ORDER BY event_start"; $getEvent_res = mysqli_query($mysqli, $getEvent_sql) or die(mysqli_error($mysqli)); if (mysqli_num_rows($getEvent_res) > 0) { $event_txt = "<ul>"; while ($ev = mysqli_fetch_array($getEvent_res)) { $event_title = stripslashes($ev["event_title"]); $event_shortdesc = stripslashes($ev["event_shortdesc"]); $fmt_date = $ev["fmt_date"]; $event_txt .= "<li><strong>".$fmt_date."</strong>: ".$event_title."</br>".$event_shortdesc."</li>"; } $event_txt .= "</ul>"; mysqli_free_result($getEvent_res); } else { $event_txt = ""; } mysqli_close($mysqli); if ($event_txt != "") { echo "<p><strong>Today's Events:</strong></p> $event_txt <hr/>"; } if(isset($_COOKIE['ID_staples_clubs']) && isset($_COOKIE['Key_staples_clubs'])) { //show form echo " <form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\"> <p><strong>Would you like to add an event?</strong><br/> Complete the form below and press the submit button to add an event</p> <p><strong>Event Title:</strong><br/> <input type=\"text\" name=\"event_title\" size=\"25\" maxlength=\"25\" /> <p><strong>Event Description:</strong><br/> <input type=\"text\" name=\"event_shortdesc\" size=\"25\" maxlength=\"255\" /> <p><strong>Event Time (hh:mm):</strong><br/> <input type=\"text\" name=\"event_time_hh\" size=\"2\" maxlength=\"2\" /> : <input type=\"text\" name=\"event_time_mm\" size=\"2\" maxlength=\"2\" /> <select name=\"event_time_ampm\"> <option value=\"am\">AM</option> <option value=\"pm\">PM</option> </select> <input type=\"hidden\" name=\"m\" value=\"".$m."\"> <input type=\"hidden\" name=\"d\" value=\"".$d."\"> <input type=\"hidden\" name=\"y\" value=\"".$y."\"> <br/><br/> <input type=\"submit\" name=\"submit\" value=\"Add Event\"> </form>"; } ?> </body> </html> [code]
  11. I'm getting the error -- Parse error: syntax error, unexpected '{' in /home/content/c/s/t/csteffen242/html/staples/event.php on line 46 I checked it over and couldn't find anything wrong with an extra bracket, but I could easily be missing something simple <html> <head> <title>Show/Add Events</title> </head> <body> <h1>Show/Add Events</h1> <?php $mysqli = mysqli_connect --- //add new event if ($_POST) { $m = $_POST["m"]; $d = $_POST["d"]; $y = $_POST["y"]; $event_date = $y."-".$m."-".$d." ".$_POST["event_time_hh"].": ".$_POST["event_time_mm"].":00"; $insEvent_sql = "INSERT INTO calendar_events (event_title, event_shortdesc, event_start) VALUES ('".$_POST["event_title"]."', '".$_POST["event_shortdesc"]."', '$event_date')"; $insEvent_res = mysqli_query($mysqli, $insEvent_sql) or die(mysqli_error($mysqli)); } else { $m = $_GET["m"]; $d = $_GET["d"]; $y = $_GET["y"]; } //show events $getEvent_sql = "SELECT event_title, event_shortdesc, date_format(event_start, '%1:%i %p') as fmt_date FROM calendar_events WHERE month(event_start) = '".$m."' AND dayofmonth(event_start) = '".$d."' AND year(event_start)= '".$y."' ORDER BY event_start"; $getEvent_res = mysqli_query($mysqli, $getEvent_sql) or die(mysqli_error($mysqli)); if (mysqli_num_rows($getEvent_res) > 0) { $event_txt = "<ul>"; while ($ev = @mysqli_fetch_array($getEvent_res)) { $event_title = stripslashes($ev["event_title"]); $fmt_date = $ev["fmt_date"]; $event_txt .= "<li><strong>".$fmt_date."</strong>: ".$event_title."</br>".$event_shortdesc."</li>"; } $event_txt .= "</ul>"; mysqli_free_result($getEvent_res); } else { $event_txt = ""; } mysqli_close($mysqli); if ($event_txt != "" { echo "<p><strong>Today's Events:</strong></p> $event_txt <hr/>"; } //show form echo " <form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\"> <p><strong>Would you like to add an event?</strong><br/> Complete the form below and press the submit button to add an event</p> <p><strong>Event Title:</strong><br/> <input type=\"text\" name=\"event_title\" size=\"25\" maxlength=\"25\" /> <p><strong>Event Title:</strong><br/> <input type=\"text\" name=\"event_shortdesc\" size=\"25\" maxlength=\"255\" /> <p><strong>Event Time (hh:mm):</strong><br/> <select name=\"event_time_hh\">"; for ($x=1; $x <= 24; $x++) {echo "<option value=\"$x\">$x</option>"; } echo "</select> : <select name=\"event_time_mm\"> <option value=\"00\">00</option> <option value=\"00\">15</option> <option value=\"00\">30</option> <option value=\"00\">45</option> </select> <input type=\"hidden\" name=\"m\" value=\"".$m."\"> <input type=\"hidden\" name=\"d\" value=\"".$d."\"> <input type=\"hidden\" name=\"y\" value=\"".$y."\"> <br/><br/> <input type=\"submit\" name=\"submit\" value=\"Add Event\"> </form>"; ?> </body> </html>
  12. I guess using PHP in MySQL would be a slight problem... haha shows how little I know Thank you! It worked!
  13. Thank you! The only problem is my advisors field is first and last names, they're not seperated :/ Is there a way to change all of the spaces into underscores? I think I'll just do full name user names ex: advisor: Dan Smith --> username: dan_smith I have no idea if this is the correct, but this is what I have so far... INSERT INTO members2 (username, club) SELECT strtolower(str_replace(" ","_", advisor)), id FROM clubs
  14. I have a database of clubs, and each of them has an advisor As an easy way to add users to the members database, I was thinking I could use mysql to find the first letter of each advisor name, and then the last name (everything after the space) and combine them to create the username to be saved on the members database. Also, I would like the club ID from the club database to be saved to the "club" field of the members database. Any suggestions?? Thank you!
×
×
  • 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.