Jump to content

simonjk

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

simonjk's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for your reply. My statement 'doesn't work' refers to the fact that when I press the delete button, the row does not delete, i.e.e nothing happens. As for the code tags, you might note that there is not a clear button to enclose code. Unless you know what '#' means, you can't press the button to enclose the code! Perhaps replacing '#' with the word 'code' might just help? Thanks again though, Simon <?php $con = mysql_connect SECURITY DETAILS DELETED; if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("SECURITY DETAILS DELETED", $con); echo "<table width=800 Border=1>"; $userinfo = mysql_query("SELECT * FROM `awisemails` WHERE `userEmail`='$email'"); while($user = mysql_fetch_array($userinfo)) { echo "<td><br><FONT FACE=Arial,Helvetica SIZE=2 COLOR=BLACK>Forecast for <b>".$user['userfcstarea']."</b> is delivered at <b>" .$user['usersendtime']."</b></td><td><FONT FACE=Arial,Helvetica SIZE=2 COLOR=BLACK>"; echo "<form action=$_SERVER[php_SELF] method=post> <form action=$_SERVER[php_SELF] method=post> <input id=submit type=submit value=Delete /><br /> </p> </form></td></tr> "; // Connect to the MySQL $con = mysql_connect("SECURITY DETAILS DELETED"); if (!$con) { die('Could not connect: ' . mysql_error()); } $useremail = mysql_real_escape_string($_POST[$email]); $name = mysql_real_escape_string($_POST[$username]); $usertime = mysql_real_escape_string($_POST[$user['usersendtime']); mysql_query("DELETE FROM awisemails WHERE userEmail='".$useremail."' AND usersendtime='".$usertime."' AND username='".$name."'"); mysql_close($con); } echo "</table>"; end: ?>
  2. Hi, I now want to show visitors there account information and also want to show them when email weather forecasts will be delivered to them. I have done this without a problem. However, I am having difficulty when users want to delete their email request. I want to show them a 'delete' button next to their information, and then to delete the particular row in the table which includes this information. I have written some code (below) but it does not work. can you help please? Thanks, Simon <code> <?php $con = mysql_connect SECURITY DETAILS DELETED; if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("SECURITY DETAILS DELETED", $con); echo "<table width=800 Border=1>"; $userinfo = mysql_query("SELECT * FROM `awisemails` WHERE `userEmail`='$email'"); while($user = mysql_fetch_array($userinfo)) { echo "<td><br><FONT FACE=Arial,Helvetica SIZE=2 COLOR=BLACK>Forecast for <b>".$user['userfcstarea']."</b> is delivered at <b>" .$user['usersendtime']."</b></td><td><FONT FACE=Arial,Helvetica SIZE=2 COLOR=BLACK>"; echo "<form action=$_SERVER[php_SELF] method=post> <form action=$_SERVER[php_SELF] method=post> <input id=submit type=submit value=Delete /><br /> </p> </form></td></tr> "; // Connect to the MySQL $con = mysql_connect("SECURITY DETAILS DELETED"); if (!$con) { die('Could not connect: ' . mysql_error()); } $useremail = mysql_real_escape_string($_POST[$email]); $name = mysql_real_escape_string($_POST[$username]); $usertime = mysql_real_escape_string($_POST[$user['usersendtime']); mysql_query("DELETE FROM awisemails WHERE userEmail='".$useremail."' AND usersendtime='".$usertime."' AND username='".$name."'"); mysql_close($con); } echo "</table>"; end: ?> </CODE>
  3. Code should have been... function checkWord($icao) <code> return in_array(strtoupper($icao[0]), array('E', 'L', 'B'), $icao) ? TRUE : FALSE; if(checkWord() != FALSE) { //If all is well we can assign the value of POST field to a variable $userName = $_POST['userfcstarea']; } else { // if all is not well, we echo an error and exit the script echo 'Icao is invalid'; exit(); } </code>
  4. Sorry guys, I perhaps should have been a little clearer with what I am trying to do. The user will enter a code word ($icao) and this code is then to check that the word begins with an E, B or L. I want to run the functions and if all is well post it to a variable. This is the code I have (thanks to you). Does it look okay? I can't get it to work. Thanks again, Simon function checkWord($icao) return in_array(strtoupper($icao[0]), array('E', 'L', 'B'), $ficao) ? TRUE : FALSE; if(checkWord() != FALSE) { //If all is well we can assign the value of POST field to a variable $userName = $_POST['userfcstarea']; } else { // if all is not well, we echo an error and exit the script echo 'Icao is invalid'; exit(); }
  5. Thanks guys, that's great. What I would like to do is to return a message saying 'Location does not begin with E, B or L' if the conditions is true. How can I do this? Thanks again, Simon
  6. Thanks guys, You were spot on, no need for ID's...have it all working now. Thanks for your help when I could not see the wood for the trees! Simon
  7. Hi, This is perhaps a bit of a simple one, but I am not sure whether it is a preg_match or strpos that I should use. I have a form which is completed by the user. I want to check that in one of the form field entries the word they enter begins with E, L or B I thought it might be built as a function, something like function checkWord($word){ return preg_match('/^E)(/^L)(/^B/'), $word) ? TRUE : FALSE; Sorry if my attempt is laughable, can't seem to work this one out? Any help appreciated. Simon
  8. Thanks, will try to compress the table. Before that though, have you any idea why this won't work? How can I just get it to ignore missing ID's so long as they are less than the highest ID in the table column? $maxusers=mysql_query("SELECT MAX(ID) FROM `awisemails`"); $usercount=0; { do{$usercount++;.... (I then count through the users) . . . } while ($usercount <= $maxusers); Thanks, Simon
  9. Okay, thanks, now need to learn about joins. Simon
  10. I guess what I want it to do is to say 'if you don't find an ID, and the number is still below the maximum in ID then go back to 'do', add another 1 and keep going until the ID is greater than the maximum ID'. I hope this makes sense? Simon
  11. Thanks Spiderwell...I have to select some data off another table too and use the ID to do this, hence using the ID. Jesirose, I am not selecting all the users to email as there is then a condition from another table (it's actually the area they want to receive a weather forecast for). Thanks for your replies though. Simon
  12. Hi, I have a table in which one of the columns is called ID. This is an auto-increment column which assigns a new ID everytime a users joins (i.e.a new row is created in the table). Now, I need to send emails to the users and have some code written to do this. The problem is that if the ID is not recognised the code stops. What I would like the code to do it: 1. Set the ID number (starting from 1) 2. Find the maximum ID number (i.e. the highest number assigned) 3. Keep on incrementing through the ID numbers until the number is greater than the maximum ID number and then stop. Here's part of what I have so far but it does not seem to work and the code stops as soon as an ID is not found. At the ops of the code I have ... $maxusers=mysql_query("SELECT MAX(ID) FROM `awisemails`"); $usercount=0; { do{$usercount++;.... (I then count through the users) . . . } while ($usercount <= $maxusers); However, I must be dong something wrong? Wondered if anyone can spot it? Thanks, Simon
  13. Thanks for that, Unfortunately I already have the locations table and it is that where the look up takes place. Does that make sense? Simon
  14. Hi, I have a mysql table 'Users' of people who state which town they would like a weather forecast for. I then have a second table 'Locations' which contains town names and all the coordinates for that location. I then want to be able to send a user an email with a forecast for their selected town on running a PHO script. However, can someone help me with how I match up the 'Users' selected town, with the same town in the 'Location's table so that I can send an email of the forecast for their selected town? Seem to be going around in circles with this one. With thanks Simon
  15. Sincere apologies guys, it does work...there was a code error further into the script. Thanks for your help, that's excellent.
×
×
  • 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.