Jump to content

dmhall0

Members
  • Posts

    57
  • Joined

  • Last visited

    Never

Everything posted by dmhall0

  1. So then what would those users see... just a link that does nothing?! Thanks for the heads up.
  2. Ahhh... that would be it. Very cool. It appears I have some page layout/formating to do and the Update isn't working exactly, but I can figure that part out. Awesome work! Thanks a TON
  3. So something seems incorrect. I put the <script>...</script> in the <head> section and added the link as provided. I click on the link but nothing happens. Ideas? Thanks for the help!
  4. I have a standard html form that displays numeric values for 8 different fields. These increase based on other information and are typically marked as "readonly". I want to add a RESET link next to each field that allows the user to set these back to 0 (zero); then I have php UPDATE code already completed that updates the database. I assume I need a javascript function that does this, but my knowledge in this area is pretty much NULL. <a onclick="jsfunction" href="javascript:void(0);">Reset Value</a> Help with the function would be GREAT! Thanks
  5. Here is all my code. Like I say. It builds the calendar just fine and skips completely over the query. When I print the query it is correct. When I print_r() the array it looks correct also. As to the potential date format issue... my link on the day number works perfectly that redirects to another page. // Race schedule data $query4 = "SELECT * FROM u_raceschedule WHERE username = '" . $_SESSION['username'] . "'"; $allraces = mysqli_query($dbc, $query4) or die("Error 4: ".mysqli_error($dbc)); /* draws a calendar */ function draw_calendar($month,$year){ /* draw table */ $calendar = '<table cellpadding="0" cellspacing="0" class="calendar" align="center">'; /* table headings */ $headings = array('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday', 'Totals'); $calendar.= '<tr class="calendar-row"><td class="calendar-day-head">'.implode('</td><td class="calendar-day-head">',$headings).'</td></tr>'; /* days and weeks vars now ... */ $running_day = date('w',mktime(0,0,0,$month,1,$year)-1); $days_in_month = date('t',mktime(0,0,0,$month,1,$year)); $days_in_this_week = 1; $day_counter = 0; $dates_array = array(); $today = date('j'); $nowmonth = date('n'); $nowyear = date('Y'); /* row for week one */ $calendar.= '<tr class="calendar-row">'; /* print "blank" days until the first of the current week */ for($x = 0; $x < $running_day; $x++) { $calendar.= '<td class="calendar-day-np"> </td>'; $days_in_this_week++; } $x = 01; /* keep going with days.... */ for($list_day = '1'; $list_day <= $days_in_month; $list_day++) { if($list_day == $today && $month == $nowmonth && $year == $nowyear) { $calendar.= '<td class="calendar-day-today">'; } else { $calendar.= '<td class="calendar-day">'; } /* add in the day number */ $todaydate = $year.'-'.$month.'-'.$list_day; $calendar.= '<div class="day-number"><a href="diary_day.php?id='.$todaydate.'">'.$list_day.'</div>'; /** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !! IF MATCHES FOUND, PRINT THEM !! **/ // enter races if (mysqli_num_rows($allraces) > 0) { $races = array(); while ($row = mysqli_fetch_array($allraces)) { array_push($races, $row['race_date']); } // Insert empty question rows into the u_profile table, one per question foreach ($races as $race) { if ($race == $todaydate) { $calendar.= '<strong>Race</strong>'; } } } //Above here is end of event code $calendar.= str_repeat('<p> </p>',2); $calendar.= '</td>'; if($running_day == 6) { $calendar.= '</tr>'; if(($day_counter+1) != $days_in_month) { $calendar.= '<tr class="calendar-row">'; } $running_day = -1; $days_in_this_week = 0; } $days_in_this_week++; $running_day++; $day_counter++; } /* for loop ending */ /* finish the rest of the days in the week */ if($days_in_this_week < { for($x = 1; $x <= (8 - $days_in_this_week); $x++){ $calendar.= '<td class="calendar-day-np"> </td>'; } } /* final row */ $calendar.= '</tr>'; /* end the table */ $calendar.= '</table>'; /* all done, return result */ return $calendar; } Thanks everyone for the help! Really appreciate it.
  6. So yes everything actually is turned on and set to show errors. When I run the code I don't get any errors. With all that code in there as is it the entire file loads properly, just doesn't populate the events. I display the array of results from the query and that all looks correct. My table structure is correct. The "race_date" field is set to date and I am comparing it against the same format. No clue. Does my code look like it should work properly?
  7. Err... no. How do I do that? Sorry, still new to all this coding stuff.
  8. Wow. That looks intense. Since then I have been trying something else; but not sure if its breaking php "rules" as it doesn't seem to be working. I already have the looping of the month's days working, which is my $todaydate variable. So this portion - other than the query - will be inside that loop. $query4 = "SELECT * FROM u_raceschedule WHERE username = '" . $_SESSION['username'] . "'"; $allraces = mysqli_query($dbc, $query4) or die("Error 4: ".mysqli_error($dbc)); if (mysqli_num_rows($allraces) > 0) { $races = array(); while ($row = mysqli_fetch_array($allraces)) { array_push($races, $row['race_date']); } foreach ($races as $race) { if ($race == $todaydate) { $calendar.= '<a href="races_edit.php?id=' . $row['raceid'] . '"><font size = 2pt>' . $row['race_name'] . '</font></a>'; } } } It doesn't return anything. Ideas as to what is wrong? Thanks!
  9. PFMaBiSmAd Thanks for the info. Could you help with the code structure for that? Thanks again!
  10. When I print my query I get: SELECT * FROM health WHERE '2012-01-03' >= event_start AND '2012-01-03' <= event_end; Which when I run it in MySQL it work perfectly.
  11. I am trying to populate my even calendar with, well, events that are stored in a mysql table. I came across the following code and modified the query to work in my case. The code used mysql_query(), but I am using mysqli_query(), and for some reason it gets to that point and dies, but mysqli_error() doesn't even run; I just get "Error1:" If I take out the query part and only build the calendar it work perfectly. Does mysqli_query() not work inside a for loop? This hit my database for every day of the month, is there a better way? I also thought about running a query to pull all results then doing array_filter() inside the for loop for each day. Does this even work? I can't seem to figure it out. ..... for($list_day = '1'; $list_day <= $days_in_month; $list_day++) { if($list_day == $today && $month == $nowmonth && $year == $nowyear) { $calendar.= '<td class="calendar-day-today">'; } else { $calendar.= '<td class="calendar-day">'; } /* add in the day number */ $todaydate = $year.'-'.$month.'-'.$list_day; $calendar.= '<div class="day-number" onclick=window.location.href="viewday.php?name='.$_SESSION['username'].'&id='.$todaydate.'">'.$list_day.'</div>'; $y = 0; if(strlen($x) == '1') {$x = $y.$x; } /** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !! IF MATCHES FOUND, PRINT THEM !! **/ $todaydate = $year.'-'.$month.'-'.$list_day; $query = "SELECT * FROM health WHERE '$todaydate' >= event_start AND '$todaydate' <= event_end"; $results = mysqli_query($dbc, $query) or die ('Error1: '.mysqli_error($dbc)); if (mysqli_num_rows($results) > '0') { while($row = mysqli_fetch_array($results)){ extract($row); ...... I am open to any other suggestions also. Thanks for the help!
  12. PFMaBiSmAd - Thanks for the great reply! Yes, all my data is related. They are answers to a form; so I am trying to get them to reappear after the user has submitted them. My form is a mix of static text, checkboxes, and dropdowns so making that "dynamic" from a query out of mysql is a bit above my skill level at the moment. I got it to work, but I am running 22 queries! I know, not the most efficient way AT ALL, but it works and I have been struggling with this one for quite some time. Any suggestions are much appreciated.
  13. Here is my code from the above: $i=1; while ($i<=22) { $profile = "SELECT u_profile.answer " . "FROM questions, u_profile WHERE u_profile.username = '" . $_SESSION['username'] . "'" . "AND questions.questionid = u_profile.questionid AND questions.q_order IS NOT NULL " . "AND questions.q_order = '".$i."'"; //"ORDER BY questions.q_order ASC"; $data = mysqli_query($dbc, $profile) or die("Connection Error3: " . mysqli_error($dbc)); $profile.$i = $data; $i++; } When I try this it gets to the line just before this and stops. I tested my query in MySQL and it gives me exactly what is needed. Any ideas?
  14. Sorry. Yes I mean I get 1 column with 20 rows in my query, need each row assigned to a different variable. Thanks!
  15. I have a query that pulls 1 field with 20 rows of data. I need to assign each row to a different variable so that I can then display them in different locations on a page. I cannot make each row of data a different field because of other constraints. My data is very well normalized. I am using mysqli so something like the old mysql_result would be lovely! How can this be done without hitting my database 20 times? Thanks for the help.
  16. That got it... THANKS!!! mjdamato - Yours is very interesting and might be applicable in another situation for me... THANKS also!!
  17. I tried this and it just returned the "Select one..." option, with nothing in the dropdown.
  18. There is an error in the code, something about the (). Ideas?
  19. I have a function that creates a dropdown list in a form. The User saves their answer to the mysql table. How do I get their preselected answer back out of the table when they visit the form again? I know how to pull it from mysql and into a variable, but how to modify the below code to display the correct answer stumps me. Here is my dropdown function: function dropdown($array, $id) { echo '<select name="'.$id.'" id="'.$id.'" class="select"><option value="">Select one...</option>'; foreach($array as $key => $value) { echo '<option value="'.$value.'">'.$value.'</option>'; } echo '</select>'; } Thanks for the help!
  20. Sorry but I am still not following. Could I see an example? Please don't hate me! ha Thanks for the help.
  21. Here is the code: $profile = "SELECT questions.questionid, questions.question, u_profile.answer, questions.q_order " . "FROM questions, u_profile WHERE u_profile.username = '" . $_SESSION['username'] . "'" . "AND questions.questionid = u_profile.questionid AND questions.q_order IS NOT NULL " . "ORDER BY questions.q_order ASC"; $data = mysqli_query($dbc, $profile) or die("Connection Error3" . mysqli_error($dbc) ) ; $results = mysqli_fetch_assoc($data); for($i=0; $i < count($results); $i++) { echo "<span>{$results['question']}</span><input type=\"text\" value=\"{$results['answer']}\" name=\"answer\"></input><br />"; } I wasn't sure if using mysqli_fetch_assoc was correct as that part wasn't provided.
  22. Hi ddubs The loop you suggested doesn't work. It only returns the first row of results a bunch of times. Suggestions on how to fix?
  23. My tables are pretty well normalized. I have a question table, and answer table, and a question/answer table for those questions that have a drop down. For those questions that do not and can be anything (like someone's name), I don't of course. So for the questions that have a dropdown, how do I retrieve the user's answer; and for the questions totally dynamic, how do I make that work. Thanks for the help!
  24. I am sorry but I don't follow. How would I get the hash in the variable if the User leaves it blank? Sorry if this is all elementary mysql stuff.
  25. So how do I write the query to include them when there is a value, yet not include them if there isn't?
×
×
  • 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.