Jump to content

pure_skill_2000

Members
  • Posts

    29
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

pure_skill_2000's Achievements

Member

Member (2/5)

0

Reputation

  1. Thanks thats solved it, I didnt relise there was a diff in what I had used :s oops
  2. How does this have a syntax error? poss relating to the mysql server version ?!? <?php $query = "SELECT * FROM LFA WHERE LFABrief LIKE ‘%".$keywords[$i]."%’"; " ORDER BY LFABrief"; ?>
  3. Sorry really didnt mean to cause any offence and tbh honestly didnt know where the search etc had gone and how I had manged 2 lose it, sorry again! I didnt mean it like that at all, it was a geniune honest question
  4. This seems to have no lost everything my search box isnt displayed
  5. Hi for some reason the following code works but with one glich, it doesnt return only the records with the search criteria, its returns the whole table - anyone with any ideas? Thanks! //search variable = data in search box or url if(isset($_GET['search'])) { $search = $_GET['search']; } //trim whitespace from variable $search = trim($search); $search = preg_replace('/\s+/', ' ', $search); //seperate multiple keywords into array space delimited $keywords = explode(" ", $search); //Clean empty arrays so they don't get every row as result $keywords = array_diff($keywords, array("")); //Set the MySQL query if ($search == NULL or $search == '%'){ } else { for ($i=0; $i<count($keywords); $i++) { $query = "SELECT * FROM LFA " ; "WHERE column1 LIKE ‘%".$keywords[$i]."%’"; " ORDER BY column1"; } //Store the results in a variable or die if query fails $result = mysql_query($query) or die(mysql_error()); } if ($search == NULL or $search == '%'){ } else { //Count the rows retrived $count = mysql_num_rows($result); } echo "<html>"; echo "<head>"; echo "<title>Low flying areas</title>"; echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" />"; echo "</head>"; echo "<body onLoad=\"self.focus();document.searchform.search.focus()\">"; echo "<center>"; echo "<br /><form name=\"searchform\" method=\"GET\" action=\"findlfa.php\">"; echo "<input type=\"text\" name=\"search\" size=\"20\" TABINDEX=\"1\" />"; echo " <input type=\"submit\" value=\"Search\" />"; echo "</form>"; //If search variable is null do, else print it. if ($search == NULL) { } else { echo "You searched for <b><FONT COLOR=\"blue\">"; foreach($keywords as $value) { print "$value "; } echo "</font></b>"; } echo "<p> </p><br />"; echo "</center>"; //If users doesn't enter anything into search box tell them to. if ($search == NULL){ echo "<center><b><FONT COLOR=\"red\">Please enter a search parameter to continue.</font></b><br /></center>"; //ELSE print the data in a table } else { //Table header echo "<center><table id=\"search\" bgcolor=\"#AAAAAA\">"; echo "<tr>"; echo "<td><b>COLUMN 1:</b></td>"; echo "<td><b>COLUMN 2:</b></td>"; echo "<td><b>COLUMN 3:</b></td>"; echo "<td><b>COLUMN 4:</b></td>"; echo "<td><b>COLUMN 5:</b></td>"; echo "<td><b>COLUMN 6:</b></td>"; echo "<tr>"; echo "</table></center>"; //Colors for alternation of row color on results table $color1 = "#d5d5d5"; $color2 = "#e5e5e5"; //While there are rows, print it. while($row = mysql_fetch_array($result)) { //Row color alternates for each row $row_color = ($row_count % 2) ? $color1 : $color2; //table background color = row_color variable echo "<center><table bgcolor=".$row_color.">"; echo "<tr>"; echo "<td>".$row['LFA']."</td>"; echo "<td>".$row['LFA Brief']."</td>"; echo "<td>".$row['Link']."</td>"; echo "</tr>"; echo "</table></center>"; $row_count++; //end while } //end if } echo "</body>"; echo "</html>"; if ($search == NULL or $search == '%') { } else { //clear memory mysql_free_result($result); } ?>
  6. I have a syntax "<" error on line 3 any suggestions? <?php //// filename = search.php <form name="search" method="post" action="result.php"> <select name="metode" size="1"> <option value="Aircraft Type">Aircraft Type</option> <option value="LFA">LFA</option> </select> <input type="text" name="search" size="25"> <input type="submit" value="Begin Searching!!"> </form> ?>
  7. This seems to really dislike the while($row = mysql_fetch_assoc($result))
  8. Does anyone know the code of a tutorial for populating a drop down list from records in a mysql database using php for example; Field Month With options; Jan Feb March April I want the drop down list to populate with the months in that field of the database. Thanks!
  9. Thanks ive done simple searches like that and gotten them to work fine, I want the choices they can select to search from to populate from the database though, like drop downs
  10. Hi Im having a dumb problem with the code for a search, I want to allow the user to search with different fields, with the options populated from the choices in the database. For example LFA 3 in 2004 but I cannt get it to work Ive never tried this before its probably simple but im lost! <?php //// filename = search.php <form name="search" method="post" action="result.php"> <select name="metode" size="1"> <option value="Aircraft Type">Aircraft Type</option> <option value="LFA">LFA</option> </select> <input type="text" name="search" size="25"> <input type="submit" value="Begin Searching!!"> </form> ?> //// filename = result.php <?php $hostname = $username = $password = $usertable = $dbName = MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to connect to database"); @mysql_select_db( "$dbName") or die( "Unable to select database"); ?> <? //error message (not found message) $XX = "No Record Found"; $query = mysql_query("SELECT * FROM $usertable WHERE $metode LIKE '%$search%' LIMIT 0, 30 "); while ($row = mysql_fetch_array($query)) { $variable1=$row["Aircraft Type"]; $variable2=$row["LFA"]; $variable3=$row["Intensity"]; print ("this is for $variable1, and this print the variable2 end so on..."); } //below this is the function for no record!! if (!$variable1) { print ("$XX"); } //end ?> Ive tried to follow an online tutorial
  11. I think this may be the problem I thought it was just passed, what do I need to add and is it in the second file?
  12. Hi all, This code is the third part of an edit, it is working to pass user name onto this page well I presume it is as when I click submit its going onto the 2nd page. However the second page is just coming up with the header title and no info anyone got any ideas? Ive included the three files incase its in one of the others. Many thanks - its driving me loopy! ps, Merry Christmas! 1st file <form name="updateform" method="post" action="displayform.php"> <table width = "250" border="0" align-"center" cellpadding="3"> <tr> <td colspan="2" bgcolor="#dddddd" height="23"> <center><b>Enter your username</b></center> </td> </tr> <tr bgcolor="#eeeeee"> <td width="100" bgcolor="#eeeeee"> <center>username</center> </td> <td width="150"> <input type="text" name="username" /> </td> </tr> <tr> <td colspan="2" bgcolor="#dddddd"> <center> <Input type="submit" name="Submit" value="Submit" /> </center> </td> </tr> </table> </form> </body> </html> 2nd file $connection=mysql_connect ($host,$uname,$pass) or die ("Database connection failed! <br>"); $result=mysql_select_db ($database) or die ("Database could not be selected"); $query = "SELECT * FROM week9 WHERE username='" . $username . "'"; $result = mysql_query($query); if($row=mysql_fetch_array($result)) { echo " <tr bgcolor=\"#eeeeee\"> "; echo " <td width=\"100\" bgcolor=\"#eeeeee\"> "; echo " <div align=\"right\">password </div>"; echo " </td> "; echo " <td width=\"150\"> "; echo " <input type=\"text\" name=\"password\" value=\"",$row["password"]."\" > " ; echo " </td> "; echo " </tr> " ; echo " <tr bgcolor=\"#eeeeee\"> "; echo " <td width=\"100\" bgcolor=\"#eeeeee\"> " ; echo " <div alighn=\"right\">E-Mail</div>"; echo " </td>"; echo " <td width=\"150\"> "; echo " <input type=\"text\" name=\"email\" value=\"",$row["Email"]."\" > " ; echo " </td>"; echo " </tr>"; echo " <tr bgcolor=\"#eeeeee\"> "; echo " <td width=\"100\" bgcolor=\"#eeeeee\"> " ; echo " <div alighn=\"right\">USername</div>"; echo " </td>"; echo " <td width=\"150\"> "; echo " <input type=\"text\" name=\"username\" value=\"",$row["username"]."\" > " ; echo " </td>"; echo " </tr>"; echo " <tr>"; echo " <td colspan=\"2\" bgcolor=\"#dddddd\"> "; echo " <div align=\"center\"> " ; echo " <input type=\"submit\" name=\"Submit\" value=\"Submit\"> "; echo " </div> " ; echo " </td> " ; echo " </tr>"; } ?> </table> </form> </body> </html> File 3 $connection=mysql_connect ($host,$uname,$pass) or die ("Database connection failed! <br>"); $result=mysql_select_db ($database) or die ("Database could not be selected"); $query = "UPDATE week9 SET password=\"". $password . "\" , Email=\"". $Email . "\" where username=\"".$username. "\""; $result = mysql_query($query); if (!$result) { die(" Query could not be executed. <br>"); } else { echo " <table border=\"0\" align\"center\" cellspacing=\"1\" cellpadding=\"5\" width=\"300\">"; echo " <tr> " ; echo " <td colspan=\"2\" bgcolor=\"#dddddd\"> " ; echo " <center> <b> ".mysql_affected_rows()." record updated successfully </b> </center>" ; echo " </td> " ; echo " </tr> "; echo "<tr bgcolor=\"#eeeeee\"> "; echo " <td width=\"100\" bgcolor=\"#eeeeee\"> "; echo " <div align=\"right\">Name<\div>"; echo " </td> "; echo " <td width=\"200\">".$username. "<\td>"; echo "</tr>"; echo "<tr bgcolor=\"#eeeeee\"> "; echo " <td width=\"100\" bgcolor=\"#eeeeee\"> "; echo " <div align=\"right\">E-mail</div>"; echo " </td> "; echo " <td width=\"200\">".$Email. "</td>"; echo "</tr>"; echo "<tr bgcolor=\"#eeeeee\"> "; echo " <td width=\"100\" bgcolor=\"#eeeeee\"> "; echo " <div align=\"right\">Password</div>"; echo " </td>"; echo " <td width=\"200\">".$password. "</td>"; echo "</tr>"; echo "<tr> "; echo " <td colorspan=\"2\" bgcolor=\"#dddddd\"> </td>"; echo "</tr>"; echo "</table>"; } ?> </body> </html> Thanks again im hoping its something simple ive missed as the code took me awhile!
  13. Hi echo "Welcome " .$myusername ; "<a href="login_success.php">Convert your grade</a>"; That line of code produces an error is it not possible to write links like this using php? Thank u
×
×
  • 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.