Jump to content

hosker

Members
  • Posts

    57
  • Joined

  • Last visited

Everything posted by hosker

  1. I have been trying to figure this out myself, but I am having no luck. Here is the following code that I have written: if (mysql_query("SELECT * FROM weekly_picks WHERE tournament = '$tournament' AND usr = '$usr'")) mysql_query("UPDATE weekly_picks SET player = '$golfer' WHERE tournament = '$tournament' AND user = '$usr'"); else mysql_query("INSERT INTO weekly_picks (t_id, tournament, user, player, backup, timestamp) VALUES ('$t_id', '$tournament', '$usr', '$golfer', '$backup', '$time')",$link) or die('Error, insert query failed'); This code will run, but all it does is add a new row into my database instead of updating what is already there when needed. Any help would be much appreciated.
  2. I have a form that gets submitted weekly and posts data into my DB for a players golf pick for the tournament that weekend. If the user changes their mind and wants to submit a different pick, I only want one instance of the tournament, user, and pick in the database, not multiple. I want to be able to have check to see if the tournament and user already exist in the database, and if they do, execute somecode, if not execute othercode.
  3. I have the following code that when used seperately work. How would I write an if..else statement that will make them work together? The following code give me an Parse Error, syntax error unexpected T_string. The following if my code I have tried, if (SELECT tournament FROM weekly_picks WHERE tournament = '$tournament') mysql_query("UPDATE weekly_picks SET player = '$golfer' WHERE tournament = '$tournament' AND user = '$usr'"); else mysql_query("INSERT INTO weekly_picks (t_id, tournament, user, player, backup, timestamp) VALUES ('$t_id', '$tournament', '$usr', '$golfer', '$backup', '$time')",$link) or die('Error, insert query failed'); I also know that values are being stored in the variables.
  4. I just thought of an additional question about inserting data into my database. With the form, I will be having fields disappear based upon times and will allow the user to revise their submission until they no longer can. However, I only want 1 entry per User per tournament. Is that something that is possible?
  5. Thanks for pointing out my typo litebearer!!
  6. Your code worked, thanks. It inserted all the data except for the value that was held in $tournament. However, it displayed that value to the screen and in the email that is sent as well. Any ideas?
  7. I am having difficulty inserting the following codes values into my database. I know that the variables contain a value as I am displaying them on the output screen. $link = mysql_connect($db_host,$db_user,$db_pass) or die('Unable to establish a DB connection'); mysql_select_db($db_database,$link); mysql_query("SET names UTF8"); $usr = $userid; $golfer = $_REQUEST['golfer']; $tourney = $_REQUEST['tournament']; $backup = $_REQUEST['backup']; date_default_timezone_set('US/Eastern'); $time = date("Y-m-d H:i:s"); $t_id=1; mysql_query("INSERT INTO weekly_picks (t_id, tournament, user, player, backup, timestamp) VALUES ('$t_id', '$tournament', '$usr', '$golfer', '$backup', '$time') or die('Error, insert query failed')"); echo $t_id; echo "<br />"; echo $tourney; echo "<br />"; echo $usr; echo "<br />"; echo $golfer; echo "<br />"; echo $backup; echo "<br />"; echo $time; echo "<br />"; echo $userdetail['email']; echo "<br />"; $to = $userdetail['email']; $subject = "Weekly Tournament Pick for: $tourney"; $message = "This email is to confirm your pick for $tourney has been received. Your pick is: $golfer. Your backup pick is: $backup The time it was submitted was $time Do not reply to this email, the mailbox does not exist. Contact me with any issues at [email protected]"; $from = "[email protected]"; $headers = "From:" . $from; mail($to,$subject,$message,$headers); ?> <div> <p>This is to confirm that your pick has been submitted for the following tournament: <?php echo $tourney; ?>. A confirmation of your pick as also been emailed to you.</p> <p>Your golfer: <?php echo $golfer; ?></p> <p>Your backup: <?php echo $backup; ?></p> <p>Your pick was submitted at: <?php echo $time; ?></p> </div>
  8. None of that really tells me how to compare the current timestamp with the fields in the database and pulley the data from the row that I want. Could you give me a few pointers here?
  9. I currently am working on a fantasy golf site. I have a table where I store each users picks by tournament. I want to be able to write a small snippet of code that can compare the current date and time to the Start Time in the database and display that weeks picks. I can do this the long way by extracting the date in each row and comparing it. Is there a way that I can do it without having to write out the code for each row in the database? this is the current code I have to do it the long way: <?php $result2 = mysql_query("SELECT * FROM `2010_Picks` WHERE Id = 2"); echo "<table border='1'> <tr> <th>Tournament</th> <th>Player</th> <th>Golfer</th> </tr>"; while($row2 = mysql_fetch_array($result2)) { $result = mysql_query("SELECT * FROM `2012_tournaments` WHERE id = 2"); while($row = mysql_fetch_array($result)) { $time1 = strtotime($row['start_date_time']); if ($time2 < $time1) { echo "<tr>"; echo "<td>" . $row2['tournament'] . "</td>"; echo "<td>" . $row2['player'] . "</td>"; echo "<td>" . $row2['golfer'] . "</td>"; echo "</tr>"; } else echo "This did not work"; }}echo "</table>"; ?> So here is a small sample of the data I have stored in my database: Date Start Time Tournament Jan. 2-92012-01-06 16:10:00Hyundai Tournament of Champions(Monday finish) Jan. 9-152012-01-12 16:00:00Sony Open in HawaiiJan. 16-222012-01-19 10:00:00Humana Challenge in partnership with the Clinton Foundation Jan. 23-292012-01-26 10:00:00Farmers Insurance Open Jan. 30-Feb. 5 2012-02-02 09:00:00Waste Management Phoenix Open Feb. 6-122012-02-09 10:00:00AT&T Pebble Beach National Pro-Am Feb. 13-192012-02-16 11:00:00Northern Trust Open Feb. 20-262012-02-23 09:25:00World Golf Championships-Accenture Match Play Championship Feb. 27-March 42012-03-01 07:00:00 The Honda Classic March 5-112012-03-08 07:00:00World Golf Championships-Cadillac Championship March 12-182012-03-15 07:00:00Transitions Championship March 19-252012-03-22 07:00:00Arnold Palmer Invitational presented by MasterCard March 26-April 12012-03-29 08:00:00Shell Houston Open April 2-82012-04-05 07:00:00Masters Tournament # April 9-152012-04-12 07:00:00RBC Heritage April 16-222012-04-19 09:00:00Valero Texas Open April 23-292012-04-26 07:00:00Zurich Classic of New Orleans April 30-May 62012-05-03 07:00:00Wells Fargo Championship May 7-132012-05-10 07:00:00THE PLAYERS Championship May 14-202012-05-17 09:00:00HP Byron Nelson Championship May 21-272012-05-24 09:00:00Crowne Plaza Invitational at Colonial May 28-June 32012-05-31 07:00:00 the Memorial Tournament presented by Nationwide Insurance June 4-102012-06-07 08:00:00FedEx St. Jude Classic June 11-172012-06-14 11:00:00U.S. Open # June 18-242012-06-21 07:00:00Travelers Championship June 25-July 12012-06-28 07:00:00AT&T National July 2-82012-07-05 07:00:00THe Greenbrier Classic July 9-152012-07-12 08:00:00John Deere Classic July 16-222012-07-19 01:00:00The Open Championship # July 23-292012-07-26 07:00:00RBC Canadian Open July 30-Aug. 52012-08-02 07:00:00World Golf Championships-Bridgestone Invitational Aug. 6-122012-08-09 07:00:00PGA Championship # Aug. 13-190000-00-00 00:00:00Off weekAug. 20-262012-08-23 07:00:00The Barclays Aug. 27-Sept. 32012-08-30 07:00:00Deutsche Bank Championship (Monday Finish) Sept. 3-92012-09-06 07:00:00BMW Championship Sept. 10-160000-00-00 00:00:00Off weekSept. 17-232012-09-20 10:00:00TOUR Championship by Coca-Cola
×
×
  • 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.