PHP - How To Display Identical Or Partially Similar Words To The Search Result
I am building online dictionary with php. The following code allows the user to search a word and display the definition results from the database. The problem is the user has to input the identical words only. If the words are not exactly similar to the database words it returns error message. But in this case I need it to give a suggestion along with the error message based on the few beginning words of the submitted word. eg. if the user type a word "suggestion", and the word "suggestion" is not available in the database .... instead of just the error message to also search and include other stored data closer to the submitted word ... like "TRY the word SUGGEST".
can any one help me on this please. Thank you in advance. here is the code Code: [Select] <?php $script = $_SERVER['PHP_SELF']; if(isset($_POST['sbm']) && isset($_POST['word']) ) { submited(); } else { show_form(); } function show_form() { ?> <p><center> Type <span style='font-weight:bold;'>ENGLISH</span> word Only! <span style='font-weight:bold;'>SPELL IT CORRECTLY!!!.</span></center></P> <p><center>Search</center></p> <center><form name=frm method=POST action="<?php echo $script ?>"> <p><input type=text name="word"><br /></p> <p><input type=submit name="sbm" value="Submit"> </form> </center></p> <?php } function submited() { require("dbconn.inc"); $word=$_POST['word']; $sql="select * from words where eng like '".mysql_real_escape_string($word)."'"; $result=mysql_query($sql,$link); // I assume $link is defined in dbconn.inc if(@mysql_num_rows($result)!=0) { $rows=mysql_fetch_array($result); $am=$rows["am"]; echo("<center>The Word <h1><b>$word</b></h1> in Am is : <h1><b>$am </b></h1><br></center>"); } else { echo("<center><span style='font-weight:bold;color:#FF0000;'>Could not find it! Check the spelling and try again !!</span></center>"); } // The connection will close automatically since // this is near the end of the script. mysql_close($link); show_form(); } ?> Similar TutorialsI am seeking to learn more about the noted subject, how to use PHP to allow a user to enter search terms and search a database. I have experimented with this with little results save for errors. Please see code listed below: search.php <? //// filename = search.php <form method="post" action="result.php3"> <select name="metode" size="1"> <option value="row_name1">metode1</option> <option value="row_name2">metode2</option> </select> <input type="text" name="search" size="25"> <input type="submit" value="Begin Searching!!"> </form> ?> results.php //// filename = result.php3 <? $hostname = "mysql7.000webhost.com"; // Usually localhost. $username = "a4542527_root"; // If you have no username, leave this space empty. $password = "*******"; // The same applies here. $usertable = "people"; // This is the table you made. $dbName = "a4542527_test1"; // This is the main database you connect to. 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["row_name1"]; $variable2=$row["row_name2"]; $variable3=$row["row_name3"]; 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 ?> Upon viewing search.php I receive the error message: Parse error: syntax error, unexpected '<' in /home/a4542527/public_html/search.php on line 3 I believe I may be missing something and am a bit lost. Thank-you in in advance for any help or suggestions. ~Matty Hello. I am working on a php script for searching a database table. I am really new to this, so I used the this tutorial http://www.phpfreaks.com/tutorial/simple-sql-search I managed to get all the things working the way I wanted, except one important and crucial thing. Let me explain. My table consist of three columns, like this: ID(bigint20) title(text) link (varchar255) ============================= ID1 title1 link-1 ID2 title2 link-2 etc... Like I said, I managed to make the script display results for a search query based on the title. Want I want it to do more, but I can't seem to find the right resource to learn how, is to place a "Download" button under each search result with its corresponding link from the table. Here is the code I used. <?php $dbHost = 'localhost'; // localhost will be used in most cases // set these to your mysql database username and password. $dbUser = 'user'; $dbPass = 'pass'; $dbDatabase = 'db'; // the database you put the table into. $con = mysql_connect($dbHost, $dbUser, $dbPass) or trigger_error("Failed to connect to MySQL Server. Error: " . mysql_error()); mysql_select_db($dbDatabase) or trigger_error("Failed to connect to database {$dbDatabase}. Error: " . mysql_error()); // Set up our error check and result check array $error = array(); $results = array(); // First check if a form was submitted. // Since this is a search we will use $_GET if (isset($_GET['search'])) { $searchTerms = trim($_GET['search']); $searchTerms = strip_tags($searchTerms); // remove any html/javascript. if (strlen($searchTerms) < 3) { $error[] = "Search terms must be longer than 3 characters."; }else { $searchTermDB = mysql_real_escape_string($searchTerms); // prevent sql injection. } // If there are no errors, lets get the search going. if (count($error) < 1) { $searchSQL = "SELECT title, link FROM db WHERE title LIKE '%{$searchTermDB}%'"; $searchResult = mysql_query($searchSQL) or trigger_error("There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$searchSQL}"); if (mysql_num_rows($searchResult) < 1) { $error[] = "The search term provided {$searchTerms} yielded no results."; }else { $results = array(); // the result array $i = 1; while ($row = mysql_fetch_assoc($searchResult)) { $results[] = "{$row['title']}<br /> Download - this is the button I want to link to the title results - and maybe other links too - <br /> "; $i++; } } } } function removeEmpty($var) { return (!empty($var)); } ?> <?php echo (count($error) > 0)?"The following had errors:<br /><span id=\"error\">" . implode("<br />", $error) . "</span><br /><br />":""; ?> <form method="GET" action="search?" name="searchForm"> Search for title: <input type="text" name="search" value="<?php echo isset($searchTerms)?htmlspecialchars($searchTerms):''; ?>" /> <input type="submit" name="submit" value="Search" /> </form> <?php echo (count($results) > 0)?"Rezultate lucrari de licenta sau disertatie pentru {$searchTerms} :<br /><br />" . implode("", $results):""; ?> $results = array(); // the result array $i = 1; while ($row = mysql_fetch_assoc($searchResult)) { $results[] = "{$row['title']}<br /> Download - this is the button I want to link to the title results - and maybe other links too - <br /> "; $i++; I would like the results to be displayed like this Results for SearchItem: Result 1 Download | Other link Result 2 Download | Other link etc.... or something like this. So, how do I add the data from the link row into a text(Dowload), within an <a href> tag (well, at least I guess it would go this way) ? My first tries (fueled by my lack of knowledge) where things like $results[] = "{$row['title']}<br /> <a href="{$row['link']}">Download</a> <br /> "; but I keep getting lots of errors, and then I don't know much about arrays and stuff (except basic notions); So there it is. I am really stuck and can't seem to find any workaround for this. Any suggestions? (examples, documentation, anything would do, really) Thanks, Radu The result pages is supposed to have pagination like google help me please
I'm trying to pull in data using a particular word from a mysql db (it's like a search facility). But this code only picks if the db has got the exact same word. E.g. if fincom = "DALLS" it pulls the data only when "searchwords" has DALLS. It ignores if "searchwords" has BARBIE DALLS. How can I fix this. I need to pick all records which contains the search word 'fincom' anywhere in searchwords. Hope this makes scene. $SomeVar = $_POST['fincom']; $query = "SELECT * FROM news_home WHERE searchwords = '".$SomeVar."' ORDER BY timestamp DESC"; $results = mysql_query($query); Hi, I am currently using this code as part of my search module: Code: [Select] $sql_res = mysql_query("SELECT * from test_user_data WHERE streng like '%$q%' or beskrivelse like '%$q%' or sku like '%$q%' ORDER BY streng LIMIT 5"); Simple code that works if my client searches for a string (or part of) that is contained in test_user_data table. If he searches "Dell Inspiron 6000", he will get a hit. However, if he searches for "Inspiron Dell 6000", he will not. Is it a simple way to make the client/enduser search for multiple words contained in a single cell? Thank you! This forum is awesome! Hello, i need some help/info about searching words in files (txt or xml) and saving them to db or another file.
For example ive got an xml file like below:
<families>
<family>
<name>brown</name>
<city>denver</city>
<members>12</members>
</family>
<family>
<name>jackson</name>
<city>new york</city>
<members>6</members>
</family>
</families>
i want to search for: <family> then save the lines till it comes to the word </family> and then goes to the next group. did some reading about array, preg_match, strpos functions but dont know where to start. what is the best way to do this?
can you guys give me some advise... or links to good tutorials?
thanks in advance!
Hello, I am EXTREMELY new to PHP, and coding in general. I have attempted to search for an answer to this already, but I'm not sure I'm using terminology that will lead me to an solution, as I haven't come up with much. I'm hoping that someone can provide some assistance, or at least point me in the right direction for some reading. What I am trying to do it search a string for a match to any of 12 words. I'm wondering if there is a smarter way to do this than coding 12 different lines, each one looking for a specific word. If you can point me in the right direction, then thank you very much =) Could anyone please help about making a search result with links. To be specific, I have a list of names in my database. I want to create a search that will list names with links. Its been 5 hours and cant still figure out how it goes. Thank you hello, i have made the fallowing code that searches through my mysql database in oder to find something looks like the query that the user is looking for. i was just wondering what should i do in order to make a second page if the results are more than 25. in other words, if there are more than 25 row i want to have a second page and if its more than 50 i want a third page and so on. $searchquery=$_POST['searchquery']; $sql = "SELECT * FROM users WHERE title ILKE '%" . $letter . "%'"; $result = mysql_query($sql); $numrows=mysql_num_rows($result); echo "<p align="center">" .$numrows . " results found for " . $letter . "</p>"; if ($numrows != 0) { ?> <table border="1" style="border-bottom-style:inherit"> <tr> <td bgcolor="#CCCCCC" style="width: 95px"><strong>image</strong></td> <td width="450" bgcolor="#CCCCCC"><strong>Description</strong></td> <td width="100" bgcolor="#CCCCCC"><strong>Book Price</strong></td> <td width="100" bgcolor="#CCCCCC"><strong>Asked Price</strong></td> </tr> <? while($row=mysql_fetch_array($result)){ ?> <tr> <td style="width: 95px"> <img src="CardsPictures/<? echo $row['cardid']; ?>.jpg" width="71" height="96" alt="Front Picture"/></td> <td><a href="http://www.SportsCardMovers.com/show_card.php?cardid=<? echo $row['cardid']; ?>"><? echo $row['title']; ?></a></td> <td><? echo $row['bookprice']?></td> <td><? echo $row['price']?></td> <? } ?> </tr> </table> <? } else echo "Please Use another Query and Search Again"; ?> thank you I have more than 1000 records in my database and while displaying i use Pagination with search criteria. Actually When i give search criteria, its displays defined number of records from database, defined in the same file thru pagination. It shows 2,3,4... number with links. But when i click on 2nd page , it goes to 2nd page but again we need to provide search criteria.
I wan this to display without search criteria.
My code is like this
<?php if(isset($_GET['page'])){ $page=$_GET['page']; } else { $page=1; } $start_page=($page-1)*20; if(isset($_POST['search'])) { $stud_id=$_POST['stud_id']; $stud_name=$_POST['stud_name']; $class=$_POST['class']; $section=$_POST['section']; $session=$_POST['session']; if(isset($_POST['search']) && ($_POST['stud_id']!='')) { $sql="select * from student where enroll_no LIKE '".$stud_id."%' "; } elseif(isset($_POST['search']) && ($_POST['stud_name']!='')) { $sql="select * from student where stud_name LIKE '".$stud_name."%' "; } elseif(isset($_POST['search']) && ($_POST['class']!='') && ($_POST['section']!='')) { $sql="select * from student where class LIKE '".$class."%' AND section LIKE '".$section."%' "; } elseif(isset($_POST['search']) && ($_POST['class']!=='')) { echo "Please select section along with class"; } elseif(isset($_POST['search'])) { $sql="select * from student limit $start_page,20"; } } $query=mysql_query($sql); ?> <div class="container"> <div class="row-fluid"> <div class="span12"> <div class="w-box"> <div class="w-box-header"> <h4>Student List</h4> </div> <div class="w-box-content"> <form method="post" action="" > <div class="formSep"><input type="text" name="stud_id" id="stud_id" value="" placeholder="Enroll No" /> <input type="text" name="stud_name" id="stud_name" value="" placeholder="Student Name"/> <select name="class" id="class"> <option value=""> CLASS </option> <option value="Nursery">Nursery</option> <option value="LKG">LKG</option> <option value="UKG">UKG</option> <option value="I">I</option> <option value="II">II</option> <option value="III">III</option> <option value="IV">IV</option> <option value="V">V</option> <option value="VI">VI</option> <option value="VII">VII</option> <option value="VIII">VIII</option> <option value="IX">IX</option> <option value="X">X</option> <option value="XI">XI</option> <option value="XII">XII</option> </select> <select name="section" id="section"><option value=""> SECTION </option> <option value="A">A</option> <option value="B">B</option> <option value="C">C</option> <option value="D">D</option> </select> <input type="submit" name="search" id="search" value="Search" class="btn btn-info" /> </div> </form> </div> </div> <div class="w-box w-box-blue"> <div class="w-box-header"> <h4>Student List</h4> </div> <div class="w-box-content"> <?php $count=mysql_num_rows($query); if($count==0) { echo "<h2>SORRY NONE OF THE RECORD FOUND IN TABLE</h2>"; } else { echo "<table id='dt_hScroll' class='table table-striped'>"; echo "<thead><tr><th>Enroll No</th><th>Student Name</th><th>Photo</th><th>Class</th><th>Class Teacher</th><th>Section</th><th>Emergency Contact</th></tr> </thead>"; $i=0; while($row=mysql_fetch_array($query)) { if($i == 1) { echo '<tr class="EvenTableRows">'; $i=0; } else { echo '<tr class="OddTableRows">'; $i = 1; } ?> <td><?php echo $row['enroll_no']; ?></td> <td><a href="edit_student.php?enroll_no=<?php echo $row['enroll_no']; ?>"><?php echo $row['stud_name']; ?></a></td> <td><img src="<?php echo '../'.$row['stud_photo']; ?>" width="50px" height="50px" /></td> <td><?php echo $row['class']; ?></td> <td> <?php } } ?> </tbody></table> </div> </div> <?php $sql1="select COUNT(id) from student"; $rs_result = mysql_query($sql1); $row1 = mysql_fetch_row($rs_result); $total_records = $row1[0]; $total_pages = ceil($total_records / 20); if ($page > $total_pages) { // set current page to last page $page = $total_pages; } // end if // if current page is less than first page... if ($page < 1) { // set current page to first page $page = 1; } // end if $range=4; echo "<div style='float:left; width:200px;text-align:center; margin-left:40%;'>"; // echo "<a href='view_student.php?page=".$i."'>".$i."</a> "; if ($page > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?page=1'>First</a> "; // get previous page num $prevpage = $page - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?page=$prevpage'>Previous</a> "; } // end if // loop to show links to range of pages around current page for ($x = ($page - $range); $x < (($page + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $total_pages)) { // if we're on current page... if ($x == $page) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?page=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($page != $total_pages) { // get next page $nextpage = $page + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?page=$nextpage'>Next</a> "; // echo forward link for lastpage echo " <a href='{$_SERVER['PHP_SELF']}?page=$total_pages'>Last</a> "; } // end if echo "</div>"; ?>how can i make it , please suggest To whom it may concern:
I have PHP code that I am trying to improve upon. I want to fix it so that when I put a dash next to a word, the word that is next to a dash is excluded.
I also want to see if it is possible, what would I have to change in my code so that when I search for words or phrases within PDF documents, that I get exactly what I want.
Whenever I have the Exact Phrase radio button enabled, and I type in the phrase Oil Gas Company, three PDF appear, however when I open the links of those PDF documents to search for that phrase, that exact phrase is not there so since it is not there I want to know what I would have to do to fix it so that the 0 matches found appears on my screen?
also
When it comes to using the dash what I want know is, is it possible to have something like Tax credit -appraisal in the search box and when either the Exact Phrase or the Any Phrase radio is selected it will do the function of both radio buttons but at the same time exclude the word appraisal in its search?
Any Phrase meaning of course it will search for either words in the phrase and bring up PDFs that have either results or both.
I ask these questions because whenever I type into the my search box bank and loans -money while the Exact Phrase radio button is highlighted it is only suppose to return PDF documents that have that exact phrase but without the word money in them. Is this possible with my code.
Is this possible with my code?
attached with this message is my php code. Any help would be greatly appreciated.
Finalsearchcode2.txt 6.63KB
2 downloads
Edited by mike2, 02 July 2014 - 02:53 PM. http://minecraftservers.comyr.com/search.php <?php session_start(); include("includes/mysql.php"); include("includes/config.php"); ?> <title><?php echo $title; ?></title> <?php echo "<a href='../index.php'>Home</a> | <a href='start_upload.php'>Upload</a> | Search & Browse | <a href='/news'>News & Announcements</a> | <a href='logout.php'>Logout</a><hr>"; $search = $_POST['search']; if(!$search) { echo "<form action='search.php' method='POST'>Search: <input type='text' name='search'><input type='submit' value='Search'></form>"; } else { $query = mysql_query("SELECT * FROM mods WHERE name LIKE '%$search%' OR description LIKE '%$search%'"); while ($row = mysql_fetch_assoc($query)) { $x++; echo "#". $x .": ". $row['name'] .".[VIEW]<br/>"; } if($x=="0") { echo "No results found."; } else { echo "<br/>".$x." results."; } } include("includes/footer.php"); ?> Whenever you type in something without spaces, it works perfectly. When you do add a space, it basically goes blank. :/ Hello! I have this code Code: [Select] <?php include_once('../database_connection.php'); $thiskeyword = addslashes($_REQUEST['keyword']); $sqlquery = "Select * from nba_info where player_id like '%$thiskeyword' OR fname like '%$thiskeyword' OR lname like '%$thiskeyword' OR team like '%$thiskeyword' OR email like '%$thiskeyword'"; $result = MYSQL_QUERY($sqlquery); $numberOfRows = MYSQL_NUM_ROWS($result); ?> <!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 Result</title> </head> <body><center><br /><br /> <?php if($numberOfRows==0) { die('You keywords haven\'t much any data from the database'); } else if($numberOfRows>0) { echo $numberOfRows. " Results have been found!"; $i = 0; ?> <table> <tr> <td>player_id</td> <td>fname</td> <td>lname</td> <td>team</td> <td>email</td> </tr> <?php while($i<$numberOfRows) { $player_id = MYSQL_RESULT($result,$i,"player_id"); $fname = MYSQL_RESULT($result,$i,"fname"); $lname = MYSQL_RESULT($result,$i,"lname"); $team = MYSQL_RESULT($result,$i,"team"); $email = MYSQL_RESULT($result,$i,"email"); ?> <tr> <td><? echo $player_id; ?></td> <td><? echo $fname; ?></td> <td><? echo $lname; ?></td> <td><? echo $team; ?></td> <td><? echo $email; ?></td> </tr> <?php $i++; } ?> </table> <?php } ?> <ul> <li><a href="/php/database/ManipulatingDatabase/add_database.php">Add New Player</a></li> <li><a href="/php/database/ManipulatingDatabase/edit_form.php">Edit Player</li> <li><a href="/php/database/ManipulatingDatabase/delete_form.php">Delete Player</li> <li><a href="/php/database/ManipulatingDatabase/search_form.php">Search Player</li> <li><a href="/php/database/ManipulatingDatabase/manipulate_database.php">BACK TO MAIN</a></li> </ul> </center> </body> </html> I have no problem with the sql statement as code Code: [Select] echo $numberOfRows. " Results have been found!"; is giving me a numbers of rows. The problem is the rows that have been found is not showing up in the html row. I wonder what the problem is.. anyone? i have two tables, and i want to display data from the most recent entry of the two(i.e. display just one entry). i'm joining together 2 tables so that i can get this entry.Both tables contain the date, so i'm ordering the results of the query so that the most recent comes first. My tables a TOPIC topic_id topic _name section_sub_id date POST post_id post_name section_sub_id date I'm using the following code to get the last result, but nothing is being echoed $join =mysql_query("SELECT topic.*, post.* FROM topic LEFT JOIN post ON topic.section_sub_id=post.section_sub_id WHERE post.section_sub_id = " .$row2['section_sub_id']. " ORDER BY topic.date") or die("Select Error :" . mysql_error()); $latest= mysql_fetch_row($join); echo $latest['post.date']; i'm not sure if there is something wrong with the sql, or with the php. ANy help would be great Hi i got a search form and when im searhing for result i get nothing. i got 5 search fields : 1. Erea 2. category 3. subcategory 4. from price 5. to price if im not specifieing from price and to price i get blank result ,if i do specify the from price to price ,then i get the results. this is the code im using to get the results. Code: [Select] $sql=mysql_query("select * from posts where erea = '$erea' and category = '$category' and sub_category = '$subcategory' and price >= '$fromprice' and price <= '$toprice'"); what i want is to get the result even if i didnt specify the price from, to . thanx Hello all brilliant minds, I'm a new in all this world of DB and coding and always i tried to avoid it because I think it is very hard (I'm trying to change now). problem: I have a text file (log.txt) have data like below ======================================== > rtrv-ls Command Accepted - Processing OXX 12-02-21 08:44:41 EST EAGLE5 42.0.1-63.38.31 rtrv-ls Command entered at terminal #7. ; OXX 12-02-21 08:44:41 EST EAGLE5 42.0.1-63.38.31 L3T SLT GWS GWS GWS LSN APCI (SS7) SCRN SET SET BEI LST LNKS ACT MES DIS SLSCI NIS gtcen1pls 7-010-4 none 1 2 no D 2 off off off no off gtgdv1pls 7-010-5 none 1 2 no D 2 off off off no off > rtrv-sid Command Accepted - Processing OXX 12-02-21 08:43:43 EST EAGLE5 42.0.1-63.38.31 rtrv-sid Command entered at terminal #7. ; OXX 12-02-21 08:43:43 EST EAGLE5 42.0.1-63.38.31 PCA PCI PCN CLLI PCTYPE 010-010-010 7-055-1 01830 crher1p OTHER ; . . may output like this starting always with > =================================================== Then I have SQL DB that have column with "rtrv-ls" and "rtrv-sid" Requirement : A) Use Php to open the .txt file, I used HTML form so the user can upload the file on the browser then B) Search for the column name as pattern C)Send query to MYSQL to update DB with Data for each column D) Query the Mysql for several possible outputs (I've done this part using HTML form and simple php code as below. <?php // If we got a GET request on the page from HTML part of the code, we will want to store the data in a variable e.g $my_country // So country will be passed via GET and will be stored in $my_country variable. $host="localhost"; $con_usr="aomar"; $con_pass="nokia"; if ($_POST) { $user_input = $_POST['my_log'] ; // We use the request to search in Database and return the result, First step we need to connect to the database // $connect = mysql_connect ($host,$con_usr,$con_pass); // Then we need to select database to run the query and return the result the connection stored in the $connect ressource // if ($connect) { mysql_select_db("eagle",$connect); // We store the query in variable $query becuase is it quite long text; we actually attach our varaiable $my_log passed from HTML // $query = "SELECT `".$user_input."` FROM `ss7`"; //$update="INSERT INTO ss7 ('".$user_input."') VLAUES ('; // SO if user selected Egypt it will be stored in (name=my_country) variable from HTML and will be send via GET // Then we store the query results in a variable called $result $result = mysql_query ($query) ; $arr= mysql_fetch_array($result); echo nl2br ($arr["$user_input"]); //Finally we return what we want from the array. // Print the output as we wish. in case of row data like STP output, use the nl2br to preserve the output as it was written to MYSQL DB // We need to check if the Query return no value (!$arr) , and print corresponding action } //================SECONED PART WHEN I LOAD THE LOG FILE TO BE STORED IN MYSQL================// //close the db mysql_close ($connect); } ?> <html> <body> <form action = "eagle.php?pmode=my_file" method = "POST" enctype="multipart/form-data> <fieldset> <legend> Enter you log file here and click Save: </br> </legend> <label for="my_file"> This Is My Capture File </label> <input type = "file" name ="my_file" style=margin:auto > </input><br/><br/> <input type="submit" value="Upload file"> </fieldset> </form> </body> </html> <html> <body> <title>Eagle Data Base Store</title> <form action = "eagle.php?pmode=my_log" method = "POST"> <fieldset> <legend> Please Select the DB you would like to retrive </legend> <br/><br/> <input type = "radio" name ="my_log" value = "rtrv-serial-num">Serial-Num</input> <input type = "radio" name ="my_log" value = "rtrv-stp">rtrv-stp</input> <input type = "radio" name ="my_log" value = "rtrv-feat">rtrv-feat</input> <input type = "radio" name ="my_log" value = "rtrv-dstn">rtrv-dstn</input> <input type = "radio" name ="my_log" value = "rtrv-rte">rtrv-rte</input> <input type = "radio" name ="my_log" value = "rtrv-trm">rtrv-trm</input> <input type = "radio" name ="my_log" value = "rtrv-slk">rtrv-slk</input><br/> <br/> <input type = "radio" name ="my_log" value = "rtrv-ls">rtrv-ls</input> <input type = "radio" name ="my_log" value = "rtrv-sccpopts">rtrv-sccpopts</input> <input type = "radio" name ="my_log" value = "rtrv-stpopts">rtrv-stpopts</input> <input type = "radio" name ="my_log" value = "rtrv-gsmopts">rtrv-gsmopts</input> <input type = "radio" name ="my_log" value = "rtrv-cmd">rtrv-cmd</input> <input type = "radio" name ="my_log" value = "rtrv-assoc">rtrv-assoc</input><br/> <br/> <input type = "radio" name ="my_log" value = "rtrv-gpl">rtrv-gpl</input> <input type = "radio" name ="my_log" value = "rtrv-ip-host">rtrv-ip-host</input> <input type = "radio" name ="my_log" value = "rtrv-ip-lnk">rtrv-ip-lnk</input> <input type = "radio" name ="my_log" value = "rtrv-secu-trm">rtrv-secu-trm</input> <input type = "radio" name ="my_log" value = "rtrv-secu-user">rtrc-secu-user</input> <input type = "radio" name ="my_log" value = "rept-stat-sys">rept-stat-sys</input><br/><br/> <input type = "radio" name ="my_log" value = "rept-stat-clk">rept-stat-clk</input> <input type = "radio" name ="my_log" value = "rtrv-ctrl-feat">rtrv-ctrl-feat</input> <input type = "radio" name ="my_log" value = "rtrv-tabl-capacity">rtrv-tabl-capacity</input><br/><br/> <input type = "submit" value = "Show Selected Table"/> </fieldset> </form> </body> </html> ==========================================END OF CODE=========================== *** Sorry for the many comments but I want to be sure I remember why I do that . You help is much appreciated (Please note that need to understand more than I need the Code itself) this is only returning one record, when I know there are more, and it's an endless loop crashing my browser, can someone tell me how my brackets are wrong, or what is wrong? Code: [Select] if (isset($_POST['search'])){ $keyword=$_POST['keyword']; } $sql="SELECT id, fname, lname FROM obituaries WHERE lname LIKE '%$keyword%' OR fname LIKE '%$keyword%' ORDER BY id DESC"; $results = mysql_query($sql); $num = mysql_num_rows ($results); if ($num > 0 ) { $i=0; while ($i < $num) { $id = mysql_result($results,$i,"id"); $fname = mysql_result($results,$i,"fname"); $lname = mysql_result($results,$i,"lname"); ?> <a href="view.php?id=<?php echo ($id); ?>"><?php echo($fname); ?> <?php echo($lname); ?></a> <?php } } ?>Thanks in advance I'm writing a highscore board for a game and I can only display one value from a DB... I don't know what I could be doing wrong. I've done this kind of DB work before. <?php $name = $_GET['lvl']; if($_GET['lvl']=="Strength"){ //1/21 $skill = "strlvl"; $exp = "strexp"; } else if($_GET['lvl']=="Attack"){ //2/21 $skill = "atklvl"; $exp = "atkexp"; } else if($_GET['lvl']=="Defence"){ //3/21 $skill = "deflvl"; $exp = "defexp"; } else if($_GET['lvl']=="Hitpoints"){ //4/21 $skill = "hplvl"; $exp = "hpexp"; } else if($_GET['lvl']=="Range"){ //5/21 $skill = "rglvl"; $exp = "rgexp"; } else if($_GET['lvl']=="Magic"){ //6/21 $skill = "mglvl"; $exp = "mgexp"; } else if($_GET['lvl']=="Hitpoints"){ //7/21 $skill = "hplvl"; $exp = "hpexp"; } else if($_GET['lvl']=="Prayer"){ //8/21 $skill = "prlvl"; $exp = "prexp"; } else if($_GET['lvl']=="Runecraft"){ //9/21 $skill = "rclvl"; $exp = "rcexp"; } else if($_GET['lvl']=="Slayer"){ //10/21 $skill = "sllvl"; $exp = "slexp"; } else if($_GET['lvl']=="Thieve"){ //11/21 $skill = "thlvl"; $exp = "thexp"; } else if($_GET['lvl']=="Agility"){ //12/21 $skill = "hplvl"; $exp = "hpexp"; } else if($_GET['lvl']=="Firemaking"){ //13/21 $skill = "fmlvl"; $exp = "fmexp"; } else if($_GET['lvl']=="Woodcut"){ //14/21 $skill = "wclvl"; $exp = "wcexp"; } else if($_GET['lvl']=="Cooking"){ //15/21 $skill = "cklvl"; $exp = "ckexp"; } else if($_GET['lvl']=="Herblore"){ //16/21 $skill = "hblvl"; $exp = "hbexp"; } else if($_GET['lvl']=="Mining"){ //17/21 $skill = "mnlvl"; $exp = "mnexp"; } else if($_GET['lvl']=="Farming"){ //18/21 $skill = "frmlvl"; $exp = "frmexp"; } else if($_GET['lvl']=="Fishing"){ //19/21 $skill = "fshlvl"; $exp = "fshexp"; } else if($_GET['lvl']=="Smithing"){ //20/21 $skill = "smlvl"; $exp = "smexp"; } else if($_GET['lvl']=="Fletching"){ //21/21 $skill = "fltlvl"; $exp = "fltexp"; } else if($_GET['lvl']==""){ //0/21 echo "<center><br /><br />No skill selected!</center><br />"; } mysql_connect("mysql", "15557_test", "**************") or die("Could not connect: " . mysql_error()); mysql_select_db("15557_test"); //STARTS HERE $result = mysql_query("SELECT playerName, $skill, $exp FROM skills ORDER BY $exp ASC LIMIT 5000"); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { echo"Skill: " . $name . "<br />"; printf("Player: %s - Rank: %s - EXP: %s<br />", $row[0],$row[1],$row[2]); mysql_free_result($result //ENDS HERE } ?> I have a classified ad program where I need to export ads (items). This code displays a category, subcategory, ad title, description and price for each ad. I would like to display the category and subcategory followed by the all the ads from within the category and subcategory instead of repeating the category and subcategory for each ad. Any help would be appreciated, thanks in advance! Code: [Select] function getExport() { $this->db->select(" item.id AS item_id, item.title AS item_title, item.description AS item_description, item.price AS item_price, subcategory.subcategory AS subcategory_subcategory, category.category AS category_category, (SELECT IF(item.datestarts IS NULL AND item.dateexpires IS NULL,'PENDING',IF(item.datestarts <= UNIX_TIMESTAMP() AND item.dateexpires >= UNIX_TIMESTAMP(),'ACTIVE',IF(item.dateexpires <= UNIX_TIMESTAMP(),'EXPIRED',''))) FROM item WHERE item.id = item_id) AS item_status"); $this->db->join('subcategory', 'subcategory.id = item.subcategory'); $this->db->join('category','category.id = subcategory.category'); $this->db->join('user','user.id = item.owner'); return($this->db->get($this->table)); |