Jump to content

timcclayton

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

timcclayton's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Really? Would I be better just doing this in javascript (which I think I will find easier) or does AJAX have advantages over JS
  2. Hello all. I have a form with 6 text fields in it. When a user enters information in the second text field, I want PHP to "check" a table on my MySQL database for a corresponding record. If it finds a match, then it populates the final 4 text fields with the relevant information from that record (I imagine this "check" needs to be called every time anything is changed in the second text field?). Can anybody help me (I am fairly new to PHP and MySQL) ? Many thanks in advance, Tim.
  3. Yes that's correct, the first example worked beautifully. Thanks very much Barand (and effigy too for trying to help) - much appreciated!
  4. Hello all. I am using a SELECT query to drag out records sorted by WEEKDAY. The trouble is, they sort themselves alphabetically (naturally) and this looks a bit stupid when Friday is the "first" day. Is there a way to sort by actual weekday order? Code I am using is: [code]"SELECT * FROM FLIGHTS ORDER BY 'intdom', 'day' ASC"[/code] where "day" is the weekday field.
  5. That's wonderful - thankyou! I am still getting used to this whole "embedded PHP" idea!
  6. Hello all. I have a single PHP page (called "routes.php") which contains a form with 3 dropdown lost boxes and a Submit button. Depending on what the user selects in the boxes, when they click Submit, the script runs off to a MySQL database and pulls down the appropriate data and builds a table in the "routes.php" page. My problem is this: How can I get the selections in the dropdown boxes to remain in place as, when the "routes.php" page is refreshed to build the table, the boxes are all reset to their default value? The form/MySQL code is below: [CODE]<form action="routes.php" method="post"> <select name="cbointdom" size="1"> <option value="%e%">All</option> <option value="International">International</option> <option value="Domestic">Domestic</option> </select>&nbsp;&nbsp; <select name="cboday" size="1"> <option value="%day%">All</option> <option value="Monday">Monday</option> <option value="Tuesday">Tuesday</option> <option value="Wednesday">Wednesday</option> <option value="Thursday">Thursday</option> <option value="Friday">Friday</option> <option value="Saturday">Saturday</option> <option value="Sunday">Sunday</option> </select>&nbsp;&nbsp; <select name="cboaircraft" size="1"> <option value="%B%">All</option> <option value="Beechcraft Baron">Beechcraft Baron</option> <option value="Beechcraft King Air">Beechcraft King Air</option> <option value="Boeing 737-400">Boeing 737-400</option> <option value="Boeing 747-400">Boeing 747-400</option> <option value="Boeing 777-300">Boeing 777-300</option> </select>&nbsp;&nbsp; <input type="submit" value="Search" /> </form>   <p style="word-spacing: 0; text-indent: 0; line-height: 120%; margin: 0">&nbsp;</p>   <p style="word-spacing: 0; text-indent: 0; line-height: 120%; margin: 0">&nbsp;</p> <?php include("dbinfo.inc.php"); mysql_connect("127.0.0.1",$username,$password); @mysql_select_db($database) or die("Unable to select database"); $cintdom = $_POST["cbointdom"]; $cday = $_POST["cboday"]; $caircraft = $_POST["cboaircraft"]; $result = mysql_query("SELECT * FROM FLIGHTS WHERE intdom LIKE \"$cintdom\" AND day LIKE \"$cday\" AND aircraft LIKE \"$caircraft\" ORDER BY 'flightid' ASC") or die(mysql_error()); echo "<table border='1' bordercolor='black' cellspacing='0' cellpadding='2' width=\"900\">"; echo "<tr bgcolor=\"#99CCFF\"> <th align=\"left\" width=\"80\"><font face=\"Arial Unicode MS\" size=\"1\">FLIGHT TYPE</th> <th align=\"left\" width=\"60\"><font face=\"Arial Unicode MS\" size=\"1\">DAY OF FLIGHT</th> <th align=\"left\" width=\"60\"><font face=\"Arial Unicode MS\" size=\"1\">FLIGHT NUMBER</th> <th align=\"left\" width=\"140\"><font face=\"Arial Unicode MS\" size=\"1\">DEPARTURE AIRPORT</th> <th align=\"left\" width=\"90\"><font face=\"Arial Unicode MS\" size=\"1\">DEPARTURE TIME</th> <th align=\"left\" width=\"140\"><font face=\"Arial Unicode MS\" size=\"1\">ARRIVAL AIRPORT</th> <th align=\"left\" width=\"90\"><font face=\"Arial Unicode MS\" size=\"1\">ARRIVAL TIME</th> <th align=\"left\" width=\"100\"><font face=\"Arial Unicode MS\" size=\"1\">FLIGHT DISTANCE</th> <th align=\"left\" width=\"100\"><font face=\"Arial Unicode MS\" size=\"1\">FLIGHT DURATION</th> <th align=\"left\" width=\"130\"><font face=\"Arial Unicode MS\" size=\"1\">TYPE OF AIRCRAFT</th> </tr>"; while($row = mysql_fetch_array( $result )) {     echo "<tr><td width=\"80\"><font face=\"Arial Unicode MS\" size=\"1\">";     echo $row['intdom'];     echo "</td><td width=\"60\"><font face=\"Arial Unicode MS\" size=\"1\">";     echo $row['day'];     echo "</td><td width=\"60\"><font face=\"Arial Unicode MS\" size=\"1\">";     echo $row['flightno'];     echo "</td><td width=\"140\"><font face=\"Arial Unicode MS\" size=\"1\">";     echo $row['depairport'];     echo "</td><td width=\"90\"><font face=\"Arial Unicode MS\" size=\"1\">";     echo $row['deptime'];     echo "</td><td width=\"140\"><font face=\"Arial Unicode MS\" size=\"1\">";     echo $row['arrairport'];     echo "</td><td width=\"90\"><font face=\"Arial Unicode MS\" size=\"1\">";     echo $row['arrtime'];     echo "</td><td width=\"100\"><font face=\"Arial Unicode MS\" size=\"1\">";     echo $row['distance'];     echo "</td><td width=\"100\"><font face=\"Arial Unicode MS\" size=\"1\">";     echo $row['duration'];     echo "</td><td width=\"130\"><font face=\"Arial Unicode MS\" size=\"1\">";     echo $row['aircraft'];     echo "</td></tr>"; } echo "</table>"; ?>[/CODE]
  7. Thank you so much [color=red]toplay [/color]- that has cleared a number of issues up for me. I didn't know for example that you could update multiple fields in one go. I also assumed the SELECT would get my field data - didn't realise that you needed the FETCH command to actually produce the data. It really streamlines the script as well. Thanks again - [b]very [/b]much appreciated, Tim.
  8. Can you give me an idea of the syntax of the "fetch" line in the context of the above code, as all I can find is "fetch array", and I only want to get one field of data (or do I have to fetch the whole row and then specify which data field I want?) ? Thanks again, Tim.
  9. Hello all. I am a beginner when it comes to PHP and MySQL but am learning fast. I have a database with 2 tables, one table has a user's information in it ("PILOTS" table) and the other has their filed flight reports ("PIREPS" table). I need to check that when they file a flight report, whether their total hours of flying (i.e. all their total flight reports) has hit a certain mark. This will then change the data in a field in the other table ("PILOTS") to show their progress. The PHP script for filing a flight plan is: [code]<? include("dbinfo.inc.php"); mysql_connect("127.0.0.1",$username,$password); @mysql_select_db($database) or die( "Unable to select database"); mysql_query("INSERT INTO PIREPS (pilot, flightno, aircraft, start, end, duration) VALUES('$pilot','$flightno','$aircraft','$start','$end','$duration' ) ") or die(mysql_error());  mysql_query("UPDATE PILOTS SET pireps=pireps+1 WHERE pilotid = '$pilot'"); mysql_query("UPDATE PILOTS SET hours=hours+'$duration' WHERE pilotid = '$pilot'"); $totalhours = mysql_query("SELECT hours FROM PILOTS WHERE pilotid = '$pilot'") or die(mysql_error()); if ($totalhours > '10') {     mysql_query("UPDATE PILOTS SET ranking = \"Commercial Pilot\" WHERE pilotid='$pilot'"); } elseif ($totalhours >= '5') {     mysql_query("UPDATE PILOTS SET ranking = \"Private Pilot\" WHERE pilotid='$pilot'"); } elseif ($totalhours < '5') {     mysql_query("UPDATE PILOTS SET ranking = \"Student Pilot\" WHERE pilotid='$pilot'"); } mysql_query("UPDATE PILOTS SET lastflightdate=current_date() WHERE pilotid = '$pilot'"); mysql_close(); header("location: /pireps.php"); ?>  [/code] So, for example if, after filing this latest flight plan, their total hours hits 5, they progress from being a "Student Pilot" to being a "Private Pilot" and so on. I just can't get the IF statements to change their ranking. Does anyone know what I am doing wrong? Thanks in advance for your help, Tim.
×
×
  • 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.