Jump to content

denno020

Members
  • Posts

    761
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by denno020

  1. Oh wait, I'm sorry, I can see what's happening there.. Maybe it's not formatting it properly? Try echoing out $start_time, to see what format it's in?
  2. Is this just a typo here or is it how you have it in your code? You will need to enter the actual numbers there, like you have for $end_time.
  3. echoing text into a variable? With your code I would write it like this: if({'paid1'} == no){ $paid1b = "Pay Now"; }else{ $paid1b = "Yes"; } echo $paid1b Don't quote me on the formatting of that above code, I'm always getting confused between () [] {}, and the needs for them in different situations, but the gist of what I've written should work.. Hope that helps Denno
  4. I can give you some psuedo code, as it's late and I should be in bed lol. Assuming the countdowns are for the same day hours_left = target_hours - current_hours; if(target_minutes < current_minutes){ hours_left = hours_left - 1; minutes_left = (60 - current_minutes) + target_minutes; }else{ minutes_left = target_minutes - current_minutes; } seconds_left = (same idea as minutes) Fairly sure that would work. Obviously test though . Hope that helps. Denno
  5. Hey guys and girls, Name is Luke, but nickname is Denno. I came across this site as I needed help with some php, which I have received exceptionally quickly. Have asked the same question on two other web development forums, and I still haven't got an answer there, so I'll be here from now on! I look forward to learning lots, and hopefully helping people with some of the more simple php/web development problems they may have. Denno
  6. Awesome, thankyou very much. I will change to that code . Thanks to everyone for their advice too, it all helped me to understand the problem. Denno
  7. I'm not really in need of a more efficient way, I don't think. I guess I could still implement the SELECT COUNT. After trying it before, without success, I just wanted to use the first thing that I could get working, which was the other method lol. If I wanted to use the SELECT COUNT query though, I would just assign $numRegistrations = $query? (where $query = mysql_query($sqlCommand, $myConnection) or die (mysqli_error()) Is there any other steps or is the returned query the exact answer I'm after? Tah Denno
  8. I feel like a douche bag! The mixing of the mysqli and mysql is exactly what the problem was! I was having troubles with trying to run mysql queries before because I was using mysqli to connect to the database. Problem is now fixed, and it works like a charm. Thanks heaps!
  9. Ohhhhkk. So because I use mysqli_query(), the mysql_num_rows doesn't work? I have tried to connect to my database using mysql before, however it didn't work. But I shall try again right now and see how I go, using the code provided by OOP. Will post back with a result. Thanks
  10. yeah mate, that's what I want. That functionality, however it just refuses to work. I've got that listed in my code as (1). Also, be aware that I don't have all 3 of those options in there at the time of testing, I've only put them in to illustrate the different combinations I've used. Thanks
  11. I wish to have a page that will display a form if there aren't already enough registrations in the database. The following it an outline of how it will be: <?php require_once "../scripts/connect_to_mysql.php"; //this works fine // Count how many records in the database (1) $sqlCommand = "SELECT * FROM teams"; (2) $sqlCommand = "SELECT COUNT (*) FROM teams"; (3) $sqlCommand = "SELECT COUNT (id) FROM teams"; $query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error()); (1) $numRegistrations = mysql_num_rows($query); //Count how many rows are returned from the query above (2) $numRegistrations = $query (3) $numRegistrations = mysql_num_rows($query); mysqli_free_result($query); ?> (Some HTML code, like DOCTYPE, head, start of body tags) <?php if($numRegistrations > 35){ echo "Sorry, registrations for this event is at it's maximum."; }else{ ?> <form blah blah blah> </form> <?php } ?> (end of body and html tag) You'll see above there is (1), (2), (3). These are the main 3 that I've been trying, and they match up the $sqlCommand to the $numRegistrations. What would be the problem with this code? I use wamp server to test, have been using it for ages. Chrome browser to test in. If I remove the database query, the rest of the page will load. With the query in there, only the HTML code up until the database query is parsed, so therefore nothing is display on the page. Please help. Thanks Denno
×
×
  • 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.