Jump to content

macattack

Members
  • Posts

    49
  • Joined

  • Last visited

    Never

About macattack

  • Birthday 10/02/1989

Profile Information

  • Gender
    Male
  • Location
    Summerside, PE, Canada

macattack's Achievements

Member

Member (2/5)

0

Reputation

  1. The line that is commented out was uncommented and it returned a 1. So yes, I'm sure the query itself works. It's all the stuff after that that won't work. It won't even return the 1 unless the entire part after (with the exception of the final curly brace) is commented out. If that part is left on, the page is blank.
  2. I have made a few changes to the code, but still no luck. require("mysql.php"); $con = mysql_connect(PATH,USERNAME,PASSWORD); $database = mysql_select_db(DATABASE); if(!$database) { header('Location: login.php?database=no'); } else { $surname1 = strtoupper($_POST['surname']); $name1 = strtoupper($_POST['name']); $surname = mysql_real_escape_string($surname1); $name = mysql_real_escape_string($name1); $query = mysql_query("SELECT * FROM Electors WHERE Surname='".$surname."' AND Name='".$name."';"); //echo mysql_num_rows($query); if(mysql_num_rows($query) >= 2) { echo "Who do you mean?<br/> <table border='1'><tr><th>Name</th><th>Surname</th><th>Address</th><th>Submit</th></tr>"; while($row=mysql_fetch_assoc($query)) { echo "<tr><form action='index.php?task=name&vid=".$row['V_ID']."' method='post'> <td>".$row['Name']."</td><td>".$row['Surname']."</td><td>"; if($row['unit'] != ' ') { echo $row['unit']."-"; } echo $row['number']." ".$row['street']." ".$row['streettype']."</td>"; echo "<td><input type='submit'></td></form></tr>"; } echo "</table>"; } if(mysql_num_rows($query) == 1) { echo "here"; $row = mysql_fetch_assoc($query)); header("Location: index.php?task=name&vid=".$row['V_ID']); } else { header("Location: index.php?task=name&exist=no"); } }
  3. It is returning 1 value (I used a name that I know is in the database once)
  4. I have the following code require("mysql.php"); $con = mysql_connect(PATH,USERNAME,PASSWORD); $database = mysql_select_db(DATABASE); if(!$database) { header('Location: login.php?database=no'); } else { $surname1 = strtoupper($_POST['surname']); $name1 = strtoupper($_POST['name']); $surname = mysql_real_escape_string($surname1); $name = mysql_real_escape_string($name1); $query = mysql_query("SELECT * FROM Electors WHERE Surname='".$surname."' AND Name='".$name."';"); if(mysql_num_rows($query) >= 2) { echo "Who do you mean?<br/> <table border='1'><tr><th>Name</th><th>Surname</th><th>Address</th><th>Submit</th></tr>"; while($row=mysql_fetch_assoc($query)) { echo "<tr><form action='index.php?task=name&vid=".$row['V_ID']."' method='post'> <td>".$row['Name']."</td><td>".$row['Surname']."</td><td>"; if($row['unit'] != ' ') { echo $row['unit']."-"; } echo $row['number']." ".$row['street']." ".$row['streettype']."</td>"; echo "<td><input type='submit'></td></tr>"; } } if(mysql_num_rows($query) == '1') { $row = mysql_fetch_assoc($query)); header("Location: index.php?task=name&vid=".$row['V_ID']); } else { header("Location: index.php?task=name&exist=no"); } } and for some reason, it won't execute past the first if(mysql_num_rows($query)) clause. If someone may know why (I bet it's a minor oversight that an hour or so of trying things hasn't caught) your help is greatly appreciated! Basically, I want to see if the same name is in the list more than once. If it is, the person should have the option to confirm who they are searching for, if it's there once, it should redirect automatically, and if it's not there at all, redirect and give an error message.
  5. The entire output works, with the exception of the V_ID row. The code is pasted below. $sql = "SELECT Electors.V_ID, Electors.Surname, Electors.Name, Electors.Middle, Electors.Phone, Electors.Unit, Electors.Number, Electors.Street, Electors.StreetType, Electors.Postal, Electors.Poll, Calls.V_ID FROM Electors LEFT JOIN Calls ON Electors.V_ID=Calls.V_ID WHERE Electors.Poll=".$_GET['poll']." AND Contact IS NULL AND Voted IS NULL LIMIT 5"; $query = mysql_query($sql); while($row = mysql_fetch_assoc($query)){ echo "<form action='dbupdate.php?task=call&poll=".$_GET['poll']."' method='post'> <input type='hidden' name='ID' value='".$row['V_ID']."'> <tr> <td><input type='hidden' name='surname' value=".$row['Surname']."'>".$row['Surname']."</td> <td><input type='hidden' name='name' value=".$row['Name']."'>".$row['Name']."</td> <td><input type='hidden' name='middle' value=".$row['Middle']."'>".$row['Middle']."</td> <td><input type='hidden' name='phone' value='".$row['Phone']."'>".$row['Phone']."</td> <td><input type='text' length='4' size='6' name='unit' value='".$row['Unit']."'></td> <td><input type='text' length='10' size='7' name='number' value='".$row['Number']."'></td> <td><input type='text' length='30' size='15' name='street' value='".$row['Street']."'></td> <td><input type='text' length='3' size='5' name='streettype' value='".$row['StreetType']."'></td> <td><input type='text' length='7' size='7' name='postal' value='".$row['Postal']."'></td> <td> <select name='call'> <option></option> <option value='1'>Reached</option> <option value='2'>Left Message</option> <option value='3'>No Answer</option> <option value='4'>Wrong Number</option> </select> </td> <td> <select name='support'> <option></option> <option value='pc' "; if($row['Support'] == 'pc'){ echo "selected"; } echo ">PC</option> <option value='lib' "; if($row['Support'] == 'lib'){ echo "selected"; } echo ">Liberal</option> <option value='NDP' "; if($row['Support'] == 'ndp'){ echo "selected"; } echo ">NDP</option> <option value='grn' "; if($row['Support'] == 'grn'){ echo "selected"; } echo ">Green</option> <option value='acc' "; if($row['Support'] == 'acc'){ echo "selected"; } echo ">Accessible/maybe PC</option> <option value='oth' "; if($row['Support'] == 'oth'){ echo "selected"; } echo ">Other</option> </select> </td> <td><input type='text' length='10' size='12' name='partymember' value=".$row['Partymember']."></td> <td><input type='checkbox' name='sign' value='R'></td> <td><input type='checkbox' name='volunteer' value='Y'></td> <td><input type='text' name='email' maxlength='50' value='".$row['Email']."'></td> <td><input type='checkbox' name='donate' value='y'></td> <td><input type='checkbox' name='nocall' value='1'></td> <td><input type='submit'></td> </tr></form>"; } As for the view source, again, same answer. Everything was displaying as it should, with the exception of the V_ID.
  6. Hello, I have mysql query that is returning the first five people that need to be called, $sql = "SELECT Electors.V_ID, Electors.Surname, Electors.Name, Electors.Middle, Electors.Phone, Electors.Unit, Electors.Number, Electors.Street, Electors.StreetType, Electors.Postal, Electors.Poll, Calls.V_ID FROM Electors LEFT JOIN Calls ON Electors.V_ID=Calls.V_ID WHERE Electors.Poll=".$_GET['poll']." AND Contact IS NULL AND Voted IS NULL LIMIT 5"; When I do mysql_fetch_assoc it works for every value except the V_ID value. The values are being printed to a table. It's not showing any errors. If anyone has a solution for this (likely simple) error, please let me know! Also, all values are varchar except V_ID. Thanks in advance!
  7. Thanks. It appears to work now. There are other issues, but not relating to the question at hand.
  8. Ah. There's a command I've never used before. I've done lots of inner joins, but never left/right. I will give that a try. Thanks.
  9. Hello, I'm trying to handle a large CSV file in my mysql. This is my first time dealing with an imported file, and I'm having a few issues. Here's the synopsis of what I'm doing: I receive a file about once per week. This file has ~15,000 names, phone numbers and addresses. During a 30 day period, everyone on the list must be called. I've set up a php file that will take each group from the list and assign it to someone, they do the call and collect the info they need. Here's the problem: I figure the best way to do this is with two tables (I could be mistaken) and the file will be uploaded into one table, the info we collect in the other. They are compared using the ID number in the file. I'm not sure how to begin the process: if someone has not been called yet, they need to be called, and info needs to be collected. When the list is updated, we need to call whoever was not called before. Is there a way to do this with one table, and have the CSV file update the name, phone number and address without affecting the info that we collect? I guess in case this isn't overly clear, if we have already called someone, we don't want to waste time calling them again. It would be appreciated if someone can suggest how I can 1) upload the CSV file without affecting the rest (my thought is the two table solution) and 2) make some kind of query so that only rows where the ID is not on the second list are returned. Once the call is made, a row will be added on the second list with the requisite information and ID number. Thank you in advance for your help.
  10. The excel file has the first, middle and last names. The likelihood of two names matching up is pretty low. It also has addresses, but those are subject to change. The rows are listed in my first post. ID, Phone 1, Volunteer and Sign are all blank.
  11. I have no idea why ID is blank. I don't make the Excel file. It comes from another organization. The ID shouldn't be blank, so I'm guessing the current version is just missing the ID for whatever reason. I can't dump the data on the table for that very reason – without an ID, I can't handle data in a separate table. I have to check the data and import any changes. That's the part that I don't know how to do. If the ID column wasn't blank, it'd be a walk in the park.
  12. I've looked around a bit for some info on this, but I've yet to find anything solid. What I have is an excel file with ~14,000 rows. The columns are as follows: ID, Poll, Last name, first name, middle name, unit, st no, street name, type, community, postal, phone 1, sign, volunteer. ID is blank in every row. On the old version of the file, there is a record under phone number. Every week, I am delivered a new copy of the sheet, with rows inserted randomly. What I need to do is take this file and import the changes into a MySQL database. The MySQL table has a few more rows. I'm wondering what the best way to go about this is. My thoughts are that I export it as a .csv file to start. But how do I import only the changes into the MySQL database? It has to check each row to see if the info is already there (and a 100% match). If the name is there but the address is different, that has to be changed, if no info is there, the entire record has to be added. The important thing is that this gets done without altering any other data in the MySQL table, because other identifying information about each person is in the table, but not in the excel sheets that I get. If someone can give me a hand with this it would be greatly appreciated. I'd prefer to not have to check 14,000 records by hand every week.
  13. That's exactly what I thought. It looks right, but doesn't seem to work. It sounds like everyone received the email though. The first few were unaffected by the bug. Is there a simple way to move past the PHP mail function and implement something else?
  14. No, it's not working. This morning I sent an email. It should have read: To John: "Hello John, --message---" To Jane: "Hello Jane, --message--" To Mary: "Hello Mary, --message--" Instead, every name was listed, with the subject in between each name. ie "Subject Hello John, Subject Hello Jane, Subject Hello Moe, etc. until end of list. --message--" It makes no sense (to me) Any help on why that happened would be great.
×
×
  • 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.