Jump to content

kannuk

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

kannuk's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for the feedback, AyKay47. I tried what you suggested but I don't even get that far because I get an error at line: $num_rows = mysql_num_rows($result); Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/... Maybe I need to sleep on this for a while!
  2. Hi - how's it going? I've been working on something with no luck and I'm wondering if you have any ideas. I have two tables; Members and Events. When a member logs in they are redirected to a page where I want them to be able to see a list of events that they have created based on a user ID that is common in both tables. So if the member has a memberID of 123 I want them to see any events that have the userID of 123. I used two different column names just for clarity. I've tried a number of variations on the following code: <?php session_start(); header("Cache-control: private"); // Connect to Database include ('includes/db.php'); //Has login info // If not logged in if (!$_SESSION['pkMemberID']) { echo ("<div class='box'><h2>Sorry, you are not logged in!</h2>"); exit(); } // Convert Session variable 'pkMemberID' to simple variable. $memberID = $_SESSION['memberID']; $pkMemberID = $_SESSION['pkMemberID']; $name = $_SESSION['name']; //Query Events $sql = "SELECT * FROM events WHERE userID = $memberID"; $result = mysql_query($sql); $num_rows = mysql_num_rows($result); echo ("<div>Events:<br />"); // Event exists if (!($num_rows == 0)) { $myrow = mysql_fetch_array($result); do { printf ('<span>– <a href="event_edit.php?pkEventID=%s">%s</a></span><br />', $myrow['pkEventID'], $myrow['eventName']); } while ($myrow = mysql_fetch_array($result)); } echo ("</div>"); //End Events //end page ?> Sometimes I get errors, sometimes just nothing. Any advice would be appreciated.
  3. I figured it out. I was having a derp moment I guess.
  4. Thanks for the reply. I've been testing different scenarios and the only error seems to be with the field upgrade6_fee. Not sure what to think - I've gone over it a dozen times!
  5. I am trying to add up all of the entries from the above fields into one number. I've looked at other examples and this seems to work in theory. Like I said, when I have some of the other fields filled in, it adds up but upgrade6_fee always seems to be missing from the total. So if the grand total is supposed to be 10,000 and there is one entry for upgrade6_fee = 200, the grand total only shows up at 9,800. My table has several hundred entries. The fields I used above are fees paid by the applicant. Fee1 is always filled out but the others may be 0. They are all decimals (00.0) in the table structure.
  6. Hey there - how are you? I'm trying to add up multiple fields from a table and it's mostly working but I have one curious error. It always seems to miss the field upgrade6_fee. I'm totally baffled. I thought it was my syntax but I'm not seeing anything wrong with it. Any ideas? Otherwise it all seems to be working. <?php $query = "SELECT fee1, upgrade3_fee, upgrade4_fee, upgrade5_fee, upgrade6_fee, upgrade7_fee, SUM(fee1 + upgrade3_fee + upgrade4_fee + upgrade5_fee + upgrade6_fee + upgrade7_fee) AS ttotal FROM Register"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo number_format(($row['ttotal']), 2); } ?>
  7. Thanks for the reply, Joel24. After some more messing around, this is what I ended up doing and it also works. $sql = ("SELECT * FROM Teamregister WHERE pkSoloregisterID=$pkSoloregisterID"); $query = mysql_query($sql); $result = mysql_query($sql); $myrow = mysql_fetch_array($result); $total = floatval( $myrow['fee'] ) + floatval( $myrow['upgrade7'] ) + floatval( $myrow['tax'] ); printf ('<form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <p>Your registration fee is <strong>$%s</strong>.</p>', number_format( $total, 2 )); echo ("<input type='hidden' name='item_name_1' value='Registration fee'>"); printf ('<input type="hidden" name="amount_1" value="%s">', number_format( $total, 2 )); echo ("<div align='center'> <input type='submit'' value='Pay Online'></div> </form> I appreciate you taking the time to respond!
  8. Hey! How've you been? This should be simple but I can't make it work. I have a few database values from a user entry. The page queries the database and I can print them no problem. I want to add them and display the total of these values. I've tried about two dozen ways of doing and I just can't get them to add. Where I have "fee_total" I want it to be the sum of the values "fee+upgrade7+tax". This is the snippet of what I'm working on. I won't attach any of what I have tried because, well, there are too many attempts and nothing worked $sql = ("SELECT * FROM Teamregister WHERE pkSoloregisterID=$pkSoloregisterID"); $query = mysql_query($sql); $result = mysql_query($sql); $myrow = mysql_fetch_array($result); printf ('<form action="https://www.mysite.com/cgi-bin/webscr" method="post"> <p>Your registration fee is <strong>$%s</strong>.</p>', $myrow['total_fee']); echo ("<input type='hidden' name='item_name_1' value='Registration Fee'>"); printf ('<input type="hidden" name="amount_1" value="%s">', $myrow['total_fee']); echo ("<br /><div align='center'> <input type='submit'' value='Pay Online'> </form>'); Make sense? Like I said, the values are already there but the math isn't happening. To check I tried using individual DB values instead of "total_fee" and the numbers show up. Just cannot get them to add.
  9. Hi Pickachu - It's TIME. Sorry, I thought I stated that upfront. Stored as 00:00:00 (h/m/s) 24 hour format.
  10. Hey - thanks for the feedback. litebearer, I am having a hard time getting my head around what to do with that code. I am not that experienced at PHP so I am sort of drawing a blank. Pickachu2000 - I have been trying to include DATE_FORMAT in the query but it is not working (at least not how I am doing it. Doesn't this have to be done below where the information is printed out, not in the query? Here is what I tried to include in the query: DATE_FORMAT(event_start, '%r'). I also tried with TIME_FORMAT. Sorry I'm just not getting it.
  11. Hi - I have been searching for a way to select the stored time from a database (stored in 24h format - 13:20:00) and display it as 12h format. I have checked a number of forums and nothing quite seems to fit the bill. I would like it to display as 2:00pm, 12:00am, etc. Here is what I have so far: $sql = ('SELECT * FROM events WHERE active="1" AND event_date >= CURRENT_DATE AND MONTH(event_date) = 1 order by event_date ASC, event_start ASC'); $result = mysql_query($sql); $num_rows = mysql_num_rows($result); // Yes Item if (!($num_rows == 0)) { $myrow = mysql_fetch_array($result); echo ('<span class="bold" style="font-size:14px">January</span>'); do { printf ('<span>Event Time: %s', $myrow['event_start']); if ($myrow['event_end'] != '') { printf (' to %s', $myrow['event_end']); } } while ($myrow = mysql_fetch_array($result)); } Right now this just shows the regular 24h format (hh:mm:ss) for any events in the month of January. I would like both "event_start" and "event_end" to show up in 12h format. I have tried a number of things but none of it works. I'm SURE it is something simple that I have missed. Thanks in advance for any help.
×
×
  • 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.