Jump to content

airpirate007

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Everything posted by airpirate007

  1. Figured it out. I had a } in the wrong place, it needed to be on the end instead of after the while statement <?php include_once('config.php'); $send_db = 'db'; $send_table= 'table'; //query to pull names and email addresses from the db $result = mysql_query("SELECT distinct(order_num),email,name,tracking,id,date FROM $send_db.$send_table where email_sent is NULL") or die ('Error: '.mysql_error()); if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to send, so I am exiting"; exit; } while ($row = mysql_fetch_array($result)) { $email_id = $row['id']; $order_num = $row['order_num']; $name = $row['name']; $email = $row['email']; $date = $row['date']; $tracking = $row['tracking']; $to = "$email"; $headers = "From: donotreply@website.com\r\n"; $headers .= "Reply-To: donotreply@website.com\r\n"; $subject = "Your Order Number $order_num Has Shipped"; $body = "\n\n ---------------------------------------------\n DO NOT REPLY TO THIS MESSAGE \n ---------------------------------------------\n \n $name\n \n Thank you for Ordering our product!\n \n Your Order Number $order_num has shipped on $date and should arrive to you shortly.\n Your Order Shipped via the USPS First Class Mail. The tracking number for your package is $tracking \n \n For Customer Service please call phone number. For Returns, please contact Customer Service at the above phone number for Return Authorization. \n \n Thank you! \n Company \n \n \n \n \n "; mail($to, $subject, $body, $headers); //update email_sent to Y $result1 = mysql_query("UPDATE $send_db.$send_table set email_sent = 'Y' where order_num = '$order_num' and email = '$email';"); if (!$result1) { echo "Could not successfully run query against the DB: " . mysql_error(); exit; } } ?>
  2. I am trying to come up with a script that sends my clients their tracking number when they order from me. I upload their info into a MySQL DB and then I want to run a script that sends an email to the client with their tracking and order information. Then I want it to update that row to show that the email has been sent. I came up with a script, but it only sends an email to, and updates, the last row in the DB. So I need it to loop somehow through the script for every row in the DB that hasn't already been updated. Any help would be appreciated. <?php include_once('config.php'); $send_db = 'db'; $send_table= 'table'; //query to pull names and email addresses from the db $result = mysql_query("SELECT distinct(order_num),email,name,tracking,id,date FROM $send_db.$send_table where email_sent is NULL") or die ('Error: '.mysql_error()); if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to send, so I am exiting"; exit; } while ($row = mysql_fetch_array($result)) { $email_id = $row['id']; $order_num = $row['order_num']; $name = $row['name']; $email = $row['email']; $date = $row['date']; $tracking = $row['tracking']; } $to = "$email"; $headers = "From: donotreply@website.com\r\n"; $headers .= "Reply-To: donotreply@website.com\r\n"; $subject = "Your Order Number $order_num Has Shipped"; $body = "\n\n ---------------------------------------------\n DO NOT REPLY TO THIS MESSAGE \n ---------------------------------------------\n \n $name\n \n Thank you for Ordering our product!\n \n Your Order Number $order_num has shipped on $date and should arrive to you shortly.\n Your Order Shipped via the USPS First Class Mail. The tracking number for your package is $tracking \n \n For Customer Service please call phone number. For Returns, please contact Customer Service at the above phone number for Return Authorization. \n \n Thank you! \n Company \n \n \n \n \n "; mail($to, $subject, $body, $headers); //update email_sent to Y $result1 = mysql_query("UPDATE $send_db.$send_table set email_sent = 'Y' where order_num = '$order_num' and email = '$email';"); if (!$result1) { echo "Could not successfully run query against the DB: " . mysql_error(); exit; } ?>
  3. So I know a little about PHP but I am no expert by any means. But I have a project that I am working on for a fantasy football league and need some help. My users pick players from a list and then their selections are put into a database. So more than one user is likely to pick the same player. Then I need to score the players based off their games for the week. So I have code that gets the Distinct PlayerID and creates a form to update the player score (see code below), but I have no idea how to process the form. It's a little more complicated then the forms I've used before because the MySQL query would need to UPDATE all the rows for each individual PlayerID. Am I making any sense? Anyway, here is the code. If anyone has suggestions on how to process this form or a better way of doing it then please let me know. <? print '<form id="form1" name="form1" method="post" action="update_player.php">'; // Connecting, selecting database $link = mysql_connect('localhost','user','pass'); if (!$link) { die('Could not connect: ' . mysql_error()); } //Query $query=mysql_query("select DISTINCT(PlayerID), PlayerName, Team From fantasy4.temp ORDER BY Team;") or die ('Could not connect: ' . mysql_error()); print' <center> <table align=center border=0 cellpadding=0 cellspacing=2 width=350> <tr align=center> <td width=50 align=center><b>Player ID </b></td> <td width=50 align=center><b>Team</b></td> <td width=200 align=center><b>Player Name</b></td> <td width=50 align=center><b>Score</b></td> <tr><td colspan="10" bgcolor="black" height="1"></td></tr> '; while($row=mysql_fetch_array($query)){ if($color == 1) { print '<tr bgcolor=#dDdDdD> <td align=center> ' . $row['PlayerID'] . ' </td> <td align=center> ' . $row['Team'] . ' </td> <td align=center> ' . $row['PlayerName'] . ' </td> <td align=center> <input name="' . $row['PlayerID'] . '" type="text" id="' . $row['PlayerID'] . '" size="5" maxlength="5" /> </td> </tr>'; $color=0; } else { print '<tr> <td align=center> ' . $row['PlayerID'] . ' </td> <td align=center> ' . $row['Team'] . ' </td> <td align=center> ' . $row['PlayerName'] . ' </td> <td align=center> <input name="' . $row['PlayerID'] . '" type="text" id="' . $row['PlayerID'] . '" size="5" maxlength="5" /> </td> </tr>'; $color=1; } } print '</table>'; print '<input type="submit" name="button" id="button" value="Update Player Scores" /></form>'; ?> This is what I tried that did not work <? // Connecting, selecting database $link = mysql_connect('localhost','user','pass'); if (!$link) { die('Could not connect: ' . mysql_error()); } //Query $query=mysql_query("select DISTINCT(PlayerID) From fantasy4.temp;") or die ('Could not connect: ' . mysql_error()); while($row=mysql_fetch_array($query)){ $PlayerID = $_POST[$row['PlayerID']]; } while($score = array($_POST['$PlayerID'])){ //Insert Query $query2=mysql_query("UPDATE fantasy4.temp set Score='$score' where PlayerID='$PlayerID'") or die ('Yikes could not connect: ' .mysql_error()); $result = @mysql_query($query2); } //Check whether the query was successful or not if($result) { header("location: register-success.php"); exit(); }else { die("Query failed - " .mysql_error()); } ?>
×
×
  • 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.