Jump to content

AshleighCo

Members
  • Posts

    14
  • Joined

  • Last visited

Profile Information

  • Gender
    Female
  • Location
    South Africa

AshleighCo's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Not to worry.....I'm looking into getting an IT guy to help onsite with my coding...thanks anyway.
  2. I tried adding: $date1 = date("Y.M.d",time() - ($agefrom * 365 * 24 * 60 * 60)); $date1 = date("Y.M.d",time() - ($ageto * 365 * 24 * 60 * 60)); but it didn't work...
  3. I have an advanced search from that has 20 fields and it works great however I'm having a problem with customising the age range search based on the $birthdate field (YYYY/MM/DD). The user inputs $agefrom and $ageto and then I don't know how to convert the birthdate field to an age to be able to echo only the users in that age range... <?php $cQuery = 'true and '; $aSearchcriteria = array(); //more code here...(other search input that works) if(isset($_POST['agefrom']) and trim($_POST['agefrom']) and strip_tags ($_POST['agefrom']) and mysql_real_escape_string ($_POST['agefrom'] )) if(isset($_POST['ageto']) and trim($_POST['ageto']) and strip_tags ($_POST['ageto']) and mysql_real_escape_string ($_POST['ageto'] )) { $cQuery .= "$birthdate BETWEEN '$agefrom' AND '$agefrom' and "; $aSearchcriteria[] = $agefrom; $aSearchcriteria[] = $ageto; } //more code here...(other search input that works) $data = mysql_query("SELECT * FROM table WHERE $cQuery order by name, surname") or die("SELECT Error: ".mysql_error()); // more code here // table echo here... ?>
  4. Hi Sen Li, thank for your response - I know the problem is: <Option VALUE="achievements">Achievements</option>. I know that is the line causing the problem because I don't have a column with that name ($achievements) - I've tried by creating an array for achievements and listed achieve1, achieve2, achieve3 etc....but it's not reading it... please accept my apologies for the sloppy coding - I'm not a programmer by trade but became a programmer after I became disabled and lost my job and I'm trying to get my business online... any help will be very gratefully appreciated....
  5. I have searched this forum as well as over 200 other forums and have not found the answer that is specific to my question. I have shortened my code drastically to assist in resolving this quickly - I have a search form that has criteria for the search criteria with "virtual" "columns" in an array but it's not working. If I search one column at a time it works just fine but when I try to search 8 columns with one select I get the following error: SELECT Error: Unknown column 'achievements' in 'where clause'. When a user selects search in Achievements, I need it to look at all 8 columns that are associated with achievements and bring back the results that match - the same as if the user selects search in Associations, I need it to look at all 5 columns and bring back the results that match. My shortened code is as follows: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Search</title> </head> <body> <form name="search" action="" method="POST"> <p>Search:</p> <p> Achievements/Associations: <input type="text" name="find1" /> in <Select NAME="field1"> <Option VALUE="achievements">Achievements</option> <Option VALUE="associations">Associations</option> </Select> <br><br> Secondary Education: <input type="text" name="find2" /> in <Select NAME="field2"> <Option VALUE="edu1sectype">Highest Certificate Attained</option> <Option VALUE="edu1secname">Highest Grade Passed</option> <Option VALUE="edu1secinst">Name of High School</option> <Option VALUE="edu1secdate">Date Completed</option> <Option VALUE="edu1secinsttyp">Type of Institution</option> <Option VALUE="subjects">Subjects</option> </Select> <br><br> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </p> </form> <?php $searching = $_POST['searching']; $find1 = $_POST['find1']; $field1 = $_POST['field1']; $find2 = $_POST['find2']; $field2 = $_POST['field2']; if ($searching =="yes") { echo "<br><b>Searched For:</b> $find1 $find2<br>"; echo "<br><h2>Results</h2><p>"; //If they did not enter a search term we give them an error // Otherwise we connect to our Database include_once "connect_to_mysql.php"; mysql_select_db("table_name") or die(mysql_error()); // We preform a bit of filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim($find); $find = mysql_real_escape_string($find); $field = mysql_real_escape_string($field); $data = mysql_query("SELECT * FROM table_name WHERE upper(".$field1.") LIKE '%$find1%' AND upper(".$field2.") LIKE '%$find2%' ") or die("SELECT Error: ".mysql_error()); $result = mysql_query("SELECT * FROM table_name WHERE upper($field1) LIKE '%$find1%' AND upper($field2) LIKE '%$find2%' ") or die("SELECT Error: ".mysql_error()); $num_rows = mysql_num_rows($result); echo "There are $num_rows records:<br>"; echo '<center>'; echo "<table border='1' cellpadding='5' width='990'>"; // set table headers echo "<tr><th>Reference</th> <th>First Name</th> <th>Last Name</th> </tr>"; //get images and names in two arrays $name= $row["name"]; $surname= $row["surname"]; $achieve1 = $row["achieve1"]; $achieve2 = $row["achieve2"]; $achieve3 = $row["achieve3"]; $achieve4 = $row["achieve4"]; $achieve5 = $row["achieve5"]; $achieve6 = $row["achieve6"]; $achieve7 = $row["achieve7"]; $achieve8 = $row["achieve8"]; $assoc1 = $row["assoc1"]; $assoc2 = $row["assoc2"]; $assoc3 = $row["assoc3"]; $assoc4 = $row["assoc4"]; $assoc5 = $row["assoc5"]; $edu1sectype = $row["edu1sectype"]; $edu1secinst = $row["edu1secinst"]; $edu1secname = $row["edu1secname"]; $edu1secdate = $row["edu1secdate"]; $edu1secinsttyp = $row["edu1secinsttyp"]; $subject1 = $row["subject1"]; $subject2 = $row["subject2"]; $subject3 = $row["subject3"]; $subject4 = $row["subject4"]; $subject5 = $row["subject5"]; $subject6 = $row["subject6"]; $subject7 = $row["subject7"]; $subject8 = $row["subject8"]; $compsoft1name = $row["compsoft1name"]; $compsoft2name = $row["compsoft2name"]; $compsoft3name = $row["compsoft3name"]; $compsoft4name = $row["compsoft4name"]; $compsoft5name = $row["compsoft5name"]; $compsoft6name = $row["compsoft6name"]; $achievements = array('achieve1', 'achieve2', 'achieve3', 'achieve4', 'achieve5', 'achieve6', 'achieve7', 'achieve8'); $associations = array('assoc1', 'assoc2', 'assoc3', 'assoc4', 'assoc5'); $subjects = array('subject1', 'subject2', 'subject3', 'subject4', 'subject5', 'subject6', 'subject7', 'subject8' ); $compsoft = array('compsoft1name', 'compsoft2name', 'compsoft3name', 'compsoft4name', 'compsoft5name', 'compsoft6name'); while ($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td ALIGN=LEFT>" . $row['id'] . "</td>"; echo "<td ALIGN=LEFT>" . $row['name'] . "</td>"; echo "<td ALIGN=LEFT>" . $row['surname'] . "</td>"; echo "</tr>"; } echo "</table>"; //This counts the number or results - and if there wasn't any it gives them a little message explaining that $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query"; } } ?> </body> </html> Any assistance will be greatly appreciated as I have been working on this website for the past 4 months which has totalled over 150 pages and this is one of the last pages left to program and it's taken 6 days to get to this search page to this point.
  6. You truly are the coding GURU!!! Thank you so very much for this very cool and excellent code! I really liked the debug to see what the array returns. THANK YOU!!!!!
  7. UPDATED CODE: but still showing 0% (no errors) <?php $result = mysql_query("SELECT title,name,surname,identityno,gender FROM cic_candidates WHERE id='{$id}' LIMIT 1"); if (!$result) { echo "Could not successfully run query " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit; } while($row = mysql_fetch_assoc($result)) $maximumPoints = 100; $point = 0; { if($row['title'] != '') $point+=20; if($row['name'] != '') $point+=20; if($row['surname'] != '') $point+=20; if($row['identityno'] != '') $point+=20; if($row['gender'] != '') $point+=20; } $percentage = ($point*$maximumPoints)/100; echo $percentage."%"; ?>
  8. I'm trying to show a profile completeness bar on the users account and the progress bar is showing but it's not adding the number values in order to calculate the percentage of completed fields ie: if($row['title'] != '') $completedTitle = 20; My shortened code is as follows: <?php $result = mysql_query("SELECT title,name,surname,identityno,gender FROM cic_candidates WHERE id='$id' LIMIT 1"); while($row = mysql_fetch_assoc($result)) $maximumPoints = 100; { if($row['title'] != '') $completedTitle = 20; if($row['name'] != '') $completedName = 20; if($row['surname'] != '') $completedSurname = 20; if($row['identityno'] != '') $dcompletedIdentityno = 20; if($row['gender'] != '') $completedGender = 20; } $percentage = ($completedTitle+$completedName+$completedSurname+$completedIdentityno+$completedGender)*$maximumPoints/100; echo "".$percentage."%"; ?> The percentage shows in the echo but the total is wrong - it's not taking the values of 20 points for each field that is completed and including them in the "addition" part of the percentage calculation. Please can you tell me where I'm going wrong - I've been trying to figure this out for 4 days and have googled this and read over 2000 forums but can't find the answer. Any help would be greatly appreciated.
  9. The above coding is all in one page and the start session coding is above the update coding: The start session coding: <?php session_start(); $toplinks = ""; if (isset($_SESSION['id'])) { // Put stored session variables into local php variable $userid = $_SESSION['id']; $email = $_SESSION['email']; $toplinks = '<a href="member_account.php?id=' . $userid . '">Enter CV step-by-step</a> | < a href="view_personal_details.php?id=' . $userid . '">View Personal Details</a> | < a href="view_your_cv.php?id=' . $userid . '">View CV</a> | < a href="edit_your_cv.php?id=' . $userid . '">Edit CV</a> | < a href="change_password.php?id=' . $userid . '">Change Password</a> | < a href="logout.php">Log Out</a>'; } else { echo 'Please <a href="login.php">log in</a> to access your account'; exit(); } ?> Thanks for your help....
  10. Registration and login work fine. Update also updates the information to the database. However if 2 people with the same first name register on the database it automatically defaults both those accounts to the last person who has the same first name that registered on the database instead of updating and showing the information for that particular user. So if Joe - joe@xxx.co.za registers and then another Joe - joe@sss.co.za then when Joe (sss) logins in he can see all Joe(xxx) information and when he updates his details it updates Joe (xxx) account instead of showing and updating Joe (sss) account. I think there is a problem with the session "id" and the update "id" that's causing this problem but I just can't see where it is.... can anyone assist with this? It's not using the email address as the "id" but is using the "name"..... Here's the code: The start session coding: <?php session_start(); $toplinks = ""; if (isset($_SESSION['id'])) { // Put stored session variables into local php variable $userid = $_SESSION['id']; $email = $_SESSION['email']; $toplinks = '<a href="member_account.php?id=' . $userid . '">Enter CV step-by-step</a> | <a href="view_personal_details.php?id=' . $userid . '">View Personal Details</a> | <a href="view_your_cv.php?id=' . $userid . '">View CV</a> | <a href="edit_your_cv.php?id=' . $userid . '">Edit CV</a> | <a href="change_password.php?id=' . $userid . '">Change Password</a> | <a href="logout.php">Log Out</a>'; } else { echo 'Please <a href="login.php">log in</a> to access your account'; exit(); } ?> And the update coding is: <?php include_once "connect_to_mysql.php"; echo print_r($_POST); $id = $_SESSION['id']; if (isset($_POST['email'])){ $update=''; if(isset($_POST['title']) and trim($_POST['title']) <> '') $update .= "title = '" . mysql_real_escape_string($_POST['title']) . "',"; if(isset($_POST['name']) and trim($_POST['name']) <> '') $update .= "name = '" . mysql_real_escape_string($_POST['name']) . "',"; if(isset($_POST['surname']) and trim($_POST['surname']) <> '') $update .= "surname = '" . mysql_real_escape_string($_POST['surname']) . "',"; if(isset($_POST['identityno']) and trim($_POST['identityno']) <> '') $update .= "identityno = '" . mysql_real_escape_string($_POST['identityno']) . "',"; if(isset($_POST['gender']) and trim($_POST['gender']) <> '') $update .= "gender = '" . mysql_real_escape_string($_POST['gender']) . "',"; if(isset($_POST['birthdate']) and trim($_POST['birthdate']) <> '') $update .= "birthdate = '" . mysql_real_escape_string($_POST['birthdate']) . "',"; if(isset($_POST['ethnicity']) and trim($_POST['ethnicity']) <> '') $update .= "ethnicity = '" . mysql_real_escape_string($_POST['ethnicity']) . "',"; if(isset($_POST['nationality']) and trim($_POST['nationality']) <> '') $update .= "nationality = '" . mysql_real_escape_string($_POST['nationality']) . "',"; if(isset($_POST['email']) and trim($_POST['email']) <> '') $update .= "email = '" . mysql_real_escape_string($_POST['email']) . "',"; if(isset($_POST['homeaddress']) and trim($_POST['homeaddress']) <> '') $update .= "homeaddress = '" . mysql_real_escape_string($_POST['homeaddress']) . "',"; if(isset($_POST['province']) and trim($_POST['province']) <> '') $update .= "province = '" . mysql_real_escape_string($_POST['province']) . "',"; if(isset($_POST['suburb']) and trim($_POST['suburb']) <> '') $update .= "suburb = '" . mysql_real_escape_string($_POST['suburb']) . "',"; if(isset($_POST['hometele']) and trim($_POST['hometele']) <> '') $update .= "hometele = '" . mysql_real_escape_string($_POST['hometele']) . "',"; if(isset($_POST['celltele']) and trim($_POST['celltele']) <> '') $update .= "celltele = '" . mysql_real_escape_string($_POST['celltele']) . "',"; if(isset($_POST['creditclear']) and trim($_POST['creditclear']) <> '') $update .= "creditclear = '" . mysql_real_escape_string($_POST['creditclear']) . "',"; if(isset($_POST['criminalrecord']) and trim($_POST['criminalrecord']) <> '') $update .= "criminalrecord = '" . mysql_real_escape_string($_POST['criminalrecord']) . "',"; if(isset($_POST['driverslicense']) and trim($_POST['driverslicense']) <> '') $update .= "driverslicense = '" . mysql_real_escape_string($_POST['driverslicense']) . "',"; if(isset($_POST['owntransport']) and trim($_POST['owntransport']) <> '') $update .= "owntransport = '" . mysql_real_escape_string($_POST['owntransport']) . "',"; if(isset($_POST['medicalconditions']) and trim($_POST['medicalconditions']) <> '') $update .= "medicalconditions = '" . mysql_real_escape_string($_POST['medicalconditions']) . "',"; $update=substr($update,0,-1); $sql = "UPDATE cic_candidates set $update WHERE id = '" . mysql_real_escape_string($id) . "'"; mysql_query($sql); echo $sql; echo '<center>'; echo '<strong><font color=black family=tahoma size=5><br /><br /><br /><br />Successful!<br /><br /><br /> Your account info has been updated...<br /><br /><br /> To view your updated information at <font color=blue>View Personal Details</font> - <a href="view_personal_details.php?id=' . $userid . '">click here<br /></a><br /><br />To return to your <font color=blue>Edit Personal Details</font> page - <a href="edit_personal_details.php?id=' . $userid . '">click here</a><br /><br /></font></strong>'; mysql_close(); exit(); } ?>
  11. Okay....I have checked many online options and now have the following code with the following error: Fatal error: Function name must be a string....this refers to this line of my code: $query("UPDATE cic_candidates SET title='$title' Code: <?php include_once "connect_to_mysql.php"; $id = $_SESSION['id']; $title=$_POST['title']; $username=$_POST['username']; $surname=$_POST['surname']; $identityno=$_POST['identityno']; $gender=$_POST['gender']; $birthdate=$_POST['birthdate']; $ethnicity=$_POST['ethnicity']; $nationality=$_POST['nationality']; $homeaddress=$_POST['homeaddress']; $province=$_POST['province']; $suburb=$_POST['suburb']; $hometele=$_POST['hometele']; $celltele=$_POST['celltele']; $creditclear=$_POST['creditclear']; $criminalrecord=$_POST['criminalrecord']; $driverslicense=$_POST['driverslicense']; $owntransport=$_POST['owntransport']; $medicalconditions=$_POST['medicalconditions']; $query("UPDATE cic_candidates SET title='$title', username='$username', surname='$surname', identityno='$identityno', gender='$gender', birthdate='$birthdate', ethnicity='$ethnicity', nationality='$nationality', homeaddress='$homeaddress', province='$province', suburb='$suburb', hometele='$hometele', celltele='$celltele', creditclear='$creditclear', criminalrecord='$criminalrecord', driverslicense='$driverslicense', owntransport='$owntransport', medicalconditions='$medicalconditions' WHERE id='$id'"); mysql_query($query); echo 'Your account info has been updated, you will now see the new info.<br /><br /> To return to your profile edit area, <a href="edit_personal_details.php">click here</a>'; exit(); mysql_close(); ?>
  12. <?php include_once "connect_to_mysql.php"; $id = $_SESSION['id']; if ($_POST['username']) { $title = $row["title"]; $username = $row["username"]; $surname = $row["surname"]; $identityno = $row["identityno"]; $gender = $row["gender"]; $birthdate = strftime("%d %b %Y", strtotime($row["birthdate"])); $ethnicity = $row["ethnicity"]; $nationality = $row["nationality"]; $homeaddress = $row["homeaddress"]; $province = $row["province"]; $suburb = $row["suburb"]; $hometele = $row["hometele"]; $celltele = $row["celltele"]; $creditclear = $row["creditclear"]; $criminalrecord = $row["criminalrecord"]; $driverslicense = $row["driverslicense"]; $owntransport = $row["owntransport"]; $medicalconditions = $row["medicalconditions"]; $sql = mysql_query("UPDATE cic_candidates SET title='$title', username='$username', surname='$surname', identityno='$identityno', gender='$gender', birthdate='$birthdate', ethnicity='$ethnicity', nationality='$nationality', homeaddress='$homeaddress', province='$province', suburb='$suburb', hometele='$hometele', celltele='$celltele', creditclear='$creditclear', criminalrecord='$criminalrecord', driverslicense='$driverslicense', owntransport='$owntransport', medicalconditions='$medicalconditions' WHERE id='$id'"); echo 'Your account info has been updated, you will now see the new info.<br /><br /> To return to your profile edit area, <a href="edit_personal_details.php">click here</a>'; exit(); } ?>
  13. I have searched over 1500 posts over the last 2 weeks and have not found the solution to make my code work. My registration and login forms work correctly but when the user logins to add or edit information the sql database does not update with the users input and the error/updated message does not echo. My users register with name, surname, email and password but once they login they need to add to their personal information and later be able to edit the personal information. But nothing I've tried has worked... my code is as follows: <?php include_once "connect_to_mysql.php"; $id = $_SESSION['id']; if ($_POST['username']) { $title = $row["title"]; $username = $row["username"]; $surname = $row["surname"]; $identityno = $row["identityno"]; $gender = $row["gender"]; $birthdate = strftime("%d %b %Y", strtotime($row["birthdate"])); $ethnicity = $row["ethnicity"]; $nationality = $row["nationality"]; $homeaddress = $row["homeaddress"]; $province = $row["province"]; $suburb = $row["suburb"]; $hometele = $row["hometele"]; $celltele = $row["celltele"]; $creditclear = $row["creditclear"]; $criminalrecord = $row["criminalrecord"]; $driverslicense = $row["driverslicense"]; $owntransport = $row["owntransport"]; $medicalconditions = $row["medicalconditions"]; $sql = mysql_query("UPDATE cic_candidates SET title='$title', username='$username', surname='$surname', identityno='$identityno', gender='$gender', birthdate='$birthdate', ethnicity='$ethnicity', nationality='$nationality', homeaddress='$homeaddress', province='$province', suburb='$suburb', hometele='$hometele', celltele='$celltele', creditclear='$creditclear', criminalrecord='$criminalrecord', driverslicense='$driverslicense', owntransport='$owntransport', medicalconditions='$medicalconditions' WHERE id='$id'"); echo 'Your account info has been updated, you will now see the new info.<br /><br /> To return to your profile edit area, <a href="edit_personal_details.php">click here</a>'; exit(); } ?>
×
×
  • 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.