Jump to content

carterlangley

New Members
  • Posts

    9
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

carterlangley's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hey there guys, Here is the full code for the page. <?php session_start(); include("db_connect.php"); if(($_SESSION['user_id']) && ($_SESSION['access_level'] == 1 )) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <head> <title>Teaching Int Limited - Edit Database</title> <meta name="title" content="Teaching Int Limited"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="description" content="Providing Quality English Teachers to Schools and Organisations"> <meta name="Abstract" content="Providing Quality English Teachers to Schools and Organisations"> <meta name="keywords" content="TEFL,english,teacher"> <meta name="Robots" content="index, follow"> <meta name="Distribution" content="Global"> <meta name="Revisit-After" content="30 days"> <meta name="Rating" content="General"> <meta name="Reply-to" content="info@teaching-int.com"> <meta name="Owner" content="Teaching Int Limited"> <meta name="Author" content="Carter Langley"> <meta name="copyright" content="Teaching Int Limited - 2013"> <link rel="shortcut icon" href="images/favicon.ico"> <link href='http://fonts.googleapis.com/css?family=Great+Vibes' rel='stylesheet' type='text/css'> <link rel="stylesheet" type="text/css" href="form.css"> <link rel="stylesheet" type="text/css" href="header.css"> <link rel="stylesheet" type="text/css" href="site.css"> </head> <body> <?php include("header.php"); ?><br> <form class="semantic" method="post" action=""> <fieldset> <ul> <li> <legend>View and/or Edit Person</legend> <?php $ops = ''; $sql_select = "select person_id, first_name, middle_name, last_name from `person` order by `last_name` asc "; $retval_selectperson = mysql_query( $sql_select, $conn ); if(! $retval_selectperson ) { die('Could not select data: ' . mysql_error()); } while($row = mysql_fetch_assoc($retval_selectperson)) { $ops .= "<option value='{$row['person_id']}'>{$row['first_name']} {$row['middle_name']} {$row['last_name']}</option>"; } ?> <div> <label for="person_id">Select a Person</label> <select name="person_id" id="person_id"> <option value="">--- Select a Person ---</option> <?php echo $ops;?> </select> </div> <div class="button-row"> <input type="button" value="Edit Person" id="edit_person" onClick="window.open('edit_person.php')"> </div> </li> <li> <legend>View and/or Edit Company</legend> <?php $ops = ''; $sql_select = "select * from `company` order by `company_name` asc "; $retval_selectcompany = mysql_query( $sql_select, $conn ); if(! $retval_selectcompany ) { die('Could not select data: ' . mysql_error()); } while($row = mysql_fetch_assoc($retval_selectcompany)) { $ops .= "<option value='{$row['company_id']}'>{$row['company_name']}</option>"; } ?> <div> <label for="company_id">Select a Company</label> <select name="company_id" id="company_id"> <option value="">--- Select a Company ---</option> <?php echo $ops;?> </select> </div> <div class="button-row"> <input type="button" value="Edit Company" onClick="window.open('edit_company.php')"> </div> </li> <li> <legend>View and/or Edit Category</legend> <?php $ops = ''; $sql_select = "select * from `category` order by `category` asc "; $retval_selectcategory = mysql_query( $sql_select, $conn ); if(! $retval_selectcategory ) { die('Could not select data: ' . mysql_error()); } while($row = mysql_fetch_assoc($retval_selectcategory)) { $ops .= "<option value='{$row['category_id']}'>{$row['category']}</option>"; } ?> <div> <label for="category_id">Select a Category</label> <select name="category_id" id="category_id"> <option value="">--- Select a Category ---</option> <?php echo $ops;?> </select> </div> <div class="button-row"> <?php $_SESSION['edit_category'] = $_POST['category_id'] ?> <input type="button" value="Edit Category" onClick="window.open('edit_category.php')"> </div> </li> <li> <legend>View and/or Edit Campus</legend> <?php $ops = ''; $sql_select = "select * from `campus` order by `campus_name` asc "; $retval_selectcampus = mysql_query( $sql_select, $conn ); if(! $retval_selectcampus ) { die('Could not select data: ' . mysql_error()); } while($row = mysql_fetch_assoc($retval_selectcampus)) { $ops .= "<option value='{$row['campus_id']}'>{$row['campus_name']}</option>"; } ?> <div> <label for="campus_id">Select a Campus</label> <select name="campus_id" id="campus_id"> <option value="">--- Select a Campus ---</option> <?php echo $ops;?> </select> </div> <div class="button-row"> <?php $_SESSION['edit_campus'] = $_POST['campus_id'] ?> <input type="button" value="Edit Campus" onClick="window.open('edit_campus.php')"> </div> </li> <li> <legend>View and/or Edit Documents for a Person</legend> <?php $ops = ''; $sql_select = "select person_id, first_name, middle_name, last_name from `person` order by `last_name` asc "; $retval_selectperson = mysql_query( $sql_select, $conn ); if(! $retval_selectperson ) { die('Could not select data: ' . mysql_error()); } while($row = mysql_fetch_assoc($retval_selectperson)) { $ops .= "<option value='{$row['person_id']}'>{$row['first_name']} {$row['middle_name']} {$row['last_name']}</option>"; } ?> <div> <label for="person_id">Select a Person</label> <select name="person_id" id="person_id"> <option value="">--- Select a Person ---</option> <?php echo $ops;?> </select> </div> <div class="button-row"> <?php $_SESSION['edit_documents'] = $_POST['person_id'] ?> <input type="button" value="Edit Documents" onClick="window.open('edit_documents.php')"> </div> </li> <li> <legend>View and/or Edit Education for a Person</legend> <?php $ops = ''; $sql_select = "select person_id, first_name, middle_name, last_name from `person` order by `last_name` asc "; $retval_selectperson = mysql_query( $sql_select, $conn ); if(! $retval_selectperson ) { die('Could not select data: ' . mysql_error()); } while($row = mysql_fetch_assoc($retval_selectperson)) { $ops .= "<option value='{$row['person_id']}'>{$row['first_name']} {$row['middle_name']} {$row['last_name']}</option>"; } ?> <div> <label for="person_id">Select a Person</label> <select name="person_id" id="person_id"> <option value="">--- Select a Person ---</option> <?php echo $ops;?> </select> </div> <div class="button-row"> <?php $_SESSION['edit_education'] = $_POST['person_id'] ?> <input type="button" value="Edit Education" onClick="window.open('edit_education.php')"> </div> </li> <li> <legend>View and/or Edit Employment for a Person</legend> <?php $ops = ''; $sql_select = "select person_id, first_name, middle_name, last_name from `person` order by `last_name` asc "; $retval_selectperson = mysql_query( $sql_select, $conn ); if(! $retval_selectperson ) { die('Could not select data: ' . mysql_error()); } while($row = mysql_fetch_assoc($retval_selectperson)) { $ops .= "<option value='{$row['person_id']}'>{$row['first_name']} {$row['middle_name']} {$row['last_name']}</option>"; } ?> <div> <label for="person_id">Select a Person</label> <select name="person_id" id="person_id"> <option value="">--- Select a Person ---</option> <?php echo $ops;?> </select> </div> <div class="button-row"> <?php $_SESSION['edit_employment'] = $_POST['person_id'] ?> <input type="button" value="Edit Employment" onClick="window.open('edit_employment.php')"> </div> </li> <li> <legend>View and/or Edit Intake for a Person</legend> <?php $ops = ''; $sql_select = "select person_id, first_name, middle_name, last_name from `person` order by `last_name` asc "; $retval_selectperson = mysql_query( $sql_select, $conn ); if(! $retval_selectperson ) { die('Could not select data: ' . mysql_error()); } while($row = mysql_fetch_assoc($retval_selectperson)) { $ops .= "<option value='{$row['person_id']}'>{$row['first_name']} {$row['middle_name']} {$row['last_name']}</option>"; } ?> <div> <label for="person_id">Select a Person</label> <select name="person_id" id="person_id"> <option value="">--- Select a Person ---</option> <?php echo $ops;?> </select> </div> <div class="button-row"> <?php $_SESSION['edit_intake'] = $_POST['person_id'] ?> <input type="button" value="Edit Intake" onClick="window.open('edit_intake.php')"> </div> </li> </ul> </fieldset> </form> </body> </html> <?php } else { echo "<script type=\"text/javascript\"> alert(\"You don't belong here!\"); window.location=\"index.php\"</script>"; } Now, when a button is pressed after a selection is made I need the value of that selectbox to be transfered over to the new page so I can use it in a sql statement to display the record relating to the selection made. I am using sessions anyway, so thought that including a session variable will work, but I can't get it right. Please help!
  2. And to everyone who has been helping me with this problem............It is now working!! You cannot believe how relieved and grateful I am for the help guys! Thank you so much. A decent book on php and mysql and html is definitely on my list of things to buy next!
  3. I added this to the top of the page <?php error_reporting(E_ALL); ini_set('display_errors', 1); ?> Still a blank page. What is php.ini? So all I have to do is change mysql to mysqli in the code? I tried to make sense of the documentation but I have no idea what they are talking about. This has been a copy and paste exercise for me as I have absolutely no idea what I am doing. What worries me is how on earth do I protect all the private information that is being displayed from snooping eyes? And what is OOP and procedural functions? How do I restart a webserver? Is Apache a webserver or LAMP or WAMP or something? Hell, sorry if I am asking stupid questions but I am really battling to get my head around this!
  4. Hi mac_gyver I tried changing the variable to what you suggested. No go. I moved the connection information to above the if statement. No go. I tried the error class you gave. No go. I am getting a blank page now. Nothing happening at all.
  5. Hi mac_gyver Nope, this is not part of a class/course. This is something I am trying to develop for a business I have just started. Can't afford professional developers at this stage so have to go it alone for now! My poor brain is overheating trying to figure this whole lot out. I come from an oil and gas background doing rope access work so this is something that is totally alien to me. 1) I tried that previously as advised and it did absolutely nothing at all. Got a blank page. But, saying that, I have managed to get the page to display at least. So there is some progress there...... 2) Query errors. I did a check on the connection to the database by supplying an incorrect password and I got the necessary error. So the connection is working and correct. I have been able to submit information to the database as well, so no problem with the connection. The database name is part of the connection statement and not selected seperately. Apparently this is an acceptable manner to connect as well? I had no idea that the self variable was incorrect. On my other pages that just submit info that variable seems to be working fine? When it comes to the mysqli functions, I am at a total loss. All I can hope for is that the company starts to make money in the next two years so that I can afford to hire a professional developer to redo everything. Otherwise it is back to LibreOffice Calc which is not the ideal solution at all. But, you have managed to bring some possibilities to mind that I am going to be checking out. I will revert back to you with the results once I have tried them out and let you know the outcomes. Thank you so much for your detailed response. It is nice to know in this day and age that there are still people out there who are prepared to actually sit down and take the time to try and help others!
  6. Hi all, I really need some help here please. I am going to include my code that I have. Problem is the select box is not loading from the database. The connection is there, that I have established. But the select box is just not populating. I have now been trying for the last 3 days and just cannot get this to work. I really need some help here please! I am sorry if this is a topic that has been thrashed to death, but I am at my wits end and just cannot get this to work no matter how hard I Google!! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Teaching Int Limited - Home</title> <meta name="title" content="Teaching Int Limited"> <link rel="shortcut icon" href="home/images/favicon.ico"> <meta http-equiv="Window-target" content="_top"> <meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> <meta http-equiv="Content-Language" content="en-gb"> <meta name="MSSmartTagsPreventParsing" content="TRUE"><!--Providing Quality English Teachers to Schools and Organisations--> <meta name="description" content="Providing Quality English Teachers to Schools and Organisations"> <meta name="Abstract" content="Providing Quality English Teachers to Schools and Organisations"> <meta name="keywords" content="TEFL,english,teacher"> <meta name="Robots" content="index, follow"> <meta name="Distribution" content="Global"> <meta name="Revisit-After" content="30 days"> <meta name="Rating" content="General"> <meta name="Reply-to" content="info@teaching-int.com"> <meta name="Owner" content="Teaching Int Limited"> <meta name="Author" content="Carter Langley"> <meta name="copyright" content="Teaching Int Limited - 2013"> <link href='http://fonts.googleapis.com/css?family=Great+Vibes' rel='stylesheet' type='text/css'> <link rel="stylesheet" type="text/css" href="form.css"> <link rel="stylesheet" type="text/css" href="header.css"> <link rel="stylesheet" type="text/css" href="site.css"> </head> <body> <?php include("header.php"); ?> <?php if(isset($_POST['add'])) { $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'password'; $dbbase = 'database'; $conn = mysql_connect($dbhost, $dbuser, $dbpass, $dbbase); if(! $conn ) { die('Could not connect: ' . mysql_error()); } $campus_id = $_POST['campus_id']; $company_id = $_POST['company_id']; $campus_name = $_POST['campus_name']; $address_street = $_POST['address_street']; $address_city = $_POST['address_city']; $address_province = $_POST['address_province']; $address_postalcode = $_POST['address_postalcode']; $address_country = $_POST['address_country']; $main_tel = $_POST['main_tel']; $second_tel = $_POST['second_tel']; $main_email = $_POST['main_email']; $second_email = $_POST['second_email']; $sql = "INSERT INTO `teaching`.`campus` (`campus_id`, `company_id`,'campus_name','address_street','address_city','address_province','address_postalcode','address_country','main_tel','second_tel','main_email','second_email') VALUES ('NULL', '$company_id','$campus_name','$address_street','$address_city','$address_province','$address_postalcode','$address_country','$main_tel','$second_tel','$main_email','$second_email')"; $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('Could not enter data: ' . mysql_error()); } echo "Entered data successfully. Redirecting in 2 seconds.\n"; mysql_close($conn); header('Refresh: 2; URL=edit.php'); } else { ?> <form method="post" action="<?php $_PHP_SELF ?>"> <table width="100%" align="left" border="0" cellspacing="1" cellpadding="2"> <tr> <td><label for="company_id">Company</label></td> <td> <select name="company_name"> <option value="">--- Select a Company ---</option> <?php $sql_select = "SELECT * FROM `company`"; $retval_selectcompany = mysql_query( $sql_select, $conn ); while($row = mysql_fetch_assoc($retval_selectcompany)) { echo '<option value='.$row["company_name"].'>'.$row["company_name"].'</option>'; } ?> </select> </td> </tr> <tr> <td><label for="campus_name">Campus Name</label></td> <td><input name="campus_name" type="text" id="campus_name"></td> </tr> <tr> <td><label for="address_street">Street Address</label></td> <td><input name="address_street" type="text" id="address_street"></td> </tr> <tr> <td><label for="address_city">City</label></td> <td><input name="address_city" type="text" id="address_city"></td> </tr> <tr> <td><label for="address_province">Province</label></td> <td><input name="address_province" type="text" id="address_province"></td> </tr> <tr> <td><label for="address_postalcode">Postal Code</label></td> <td><input name="address_postalcode" type="text" id="address_postalcode"></td> </tr> <tr> <td><label for="address_country">Country</label></td> <td><input name="address_country" type="text" id="address_country"></td> </tr> <tr> <td><label for="main_tel">Main Tel</label></td> <td><input name="main_tel" type="text" id="main_tel"></td> </tr> <tr> <td><label for="second_tel">Alt Tel</label></td> <td><input name="second_tel" type="text" id="second_tel"></td> </tr> <tr> <td><label for="main_email">Main Email</label></td> <td><input name="main_email" type="text" id="main_email"></td> </tr> <tr> <td><label for="second_email">Second Email</label></td> <td><input name="second_email" type="text" id="second_email"></td> </tr> <tr> <td></td> <td> <input name="add" type="submit" id="add" value="Add Campus"> </td> </tr> </table> </form> <?php } ?> </body> </html>
  7. Hi Samshel That worked exactly how I wanted it to. Go have a look. Thank you! I adjusted the location of the files and all works fine. I have added that little snippet of code to my ever growing code base for future use. Thanks again. Carter
  8. OK, here is the code I have. It is populating the table but I need the last two colums to be hyperlinks to a file and not just the file location. If you go to the site, http://www.highland4x4response.co.uk/incident_log.php you will see what it currently looks like. Here is the code. $quey1="select * from incident_log"; $result=mysql_query($quey1) or die(mysql_error()); echo "<div align=\"center\">"; echo "<table class=\"hovertable\" width=\"100%\">"; echo "<tr>"; echo "<th>event type</th>"; echo "<th>call out by</th>"; echo "<th>call out date</th>"; echo "<th>responders</th>"; echo "<th>location</th>"; echo "<th>report in word</th>"; echo "<th>report in pdf</th>"; echo "</tr>"; while($row=mysql_fetch_array($result)){ echo "</td><td>"; echo $row['event_type']; echo "</td><td>"; echo $row['client']; echo "</td><td>"; echo $row['incident_date']; echo "</td><td>"; echo $row['responders']; echo "</td><td>"; echo $row['location']; echo "</td><td>"; echo $row['word_document']; echo "</td><td>"; echo $row['pdf_document']; echo "</td></tr>"; } echo "</table>"; ?> Hope this helps?
  9. Hi guys, I have a file location stored in mysql. when i populate the table i need this file location to be a hyperlink to the file itself, so the visitors can click like a normal link and open the file in word and pdf (both formats stored). example of file location as in db "_private/Incident_Reports/Incident%20-%20Applecross%20-%2017%20December%202010%20-%20Website.doc" example of php code echo $row['word_document']; any ideas would be really appreciated.
×
×
  • 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.