PHP - Searching In A String ?
<?php
$string = "aStringwith SomeSpecialChars+^$%"; // want to check if there is "+" in it if( ????? ($string,'+') { echo "yes string has plus sign"; } ?> Which function should I use to search in a string ? Similar Tutorialshey guys im trying to find a string inside a string which could be made up of different things eg... {$test}, {$test1}, {$test2} etc (but the varable inside could be called anything hence maybe using regex im not sure?) is this possible?...i hope you guys understand....thanks I want to identify strings with AT&T in them. Can't seem to find the right way to do this due to the &. I am using the strpos function in this manner: if (strpos(($string), 'AT&T')) > 0) I don't need to input or display using http. This is just a php script that I'll run from the command prompt. Thanks. Hi, I am trying to make some adjustments to uploadify.php which comes with the latest version of uploadify (3.0 beta), so that it works with a session variable that stores the login username and adds it to the path for uploads. Here is uploadify.php as it currently looks: Code: [Select] <?php session_name("MyLogin"); session_start(); $targetFolder = '/songs/' . $_SESSION['name']; // Relative to the root if (!empty($_FILES)) { $tempFile = $_FILES['Filedata']['tmp_name']; $targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder; $targetFile = rtrim($targetPath,'/') .'/'. $_FILES['Filedata']['name']; // Validate the file type $fileTypes = array('m4a','mp3','flac','ogg'); // File extensions $fileParts = pathinfo($_FILES['Filedata']['name']); if (in_array($fileParts['extension'],$fileTypes)) { move_uploaded_file($tempFile,$targetFile); echo '1'; } else { echo 'Invalid file type.'; } } echo $targetFolder; ?> I added Code: [Select] echo $targetFolder; at the bottom so that I could make sure that the string returned was correct, and it is, i.e. '/songs/nick'. For some reason though, uploads are not going to the correct folder, i.e. the username folder, but instead are going to the parent folder 'songs'. The folder for username exists, with correct permissions, and when I manually enter Code: [Select] $targetFolder = '/songs/nick';all works fine. Which strikes me as rather strange. I have limited experience of using php, but wonder how if the correct string is returned by the session variable, the upload works differently than with the manually entered string. Any help would be much appreciated. It's the last issue with a website that was due to go live 2 days ago! Thanks, Nick Hey there, Thanks for taking the time to read my thread. My issue is that I can't think of a way to edit a XML file using PHP's XML functionality and then assign the edited contents to a string instead of saving the file. Because my issue is that I have to edit the XML file based upon a string brought from a remote location then give it back to that remote location using a string again, to be exact I am doing it via Linux command line utilizing SSH2. This is what I managed to complete on my own. function CheckIVMPConfig($ServerID) { global $Panel; if(is_numeric($ServerID) && $this->IsValidServer($ServerID)) { // We select the game server that the FTP account was created for. $Servers = mysql_query("SELECT * FROM control_servers WHERE server_id = '".mysql_real_escape_string($FTPAccount['ftp_server'])."'"); $Server = mysql_fetch_array($Servers); // Here we select the Box ID that the game server is on. $Boxs = mysql_query("SELECT * FROM control_machines WHERE machine_id = '".$Server['server_machine']."'"); $Box = mysql_fetch_array($Boxs); // Now we select the required package for the box. $Packages = mysql_query("SELECT * FROM control_packages WHERE package_id = '".$Server['server_package']."'"); $Package = mysql_fetch_array($Packages); // Retrive the file. $Config = $CProtocol->exec("cat /home/{$Server['server_id']}/{$Package['package_config']}"); $Parse = SimpleXMLElement($Config); foreach($Parse as $Entry) // loop through our books { if($Entry->port != $Server['server_port']) { // edit the value } else if($Entry->maxplayers > $Server['server_slots']) { // edit the value } } } } Hello all, I'm trying to change the end of a javascript call based on the end of the url string. The common part of all the url strings is sobi2Id=, I'm trying to do this with strstr but am having no luck. I'm new to php so my syntax knowledge is terrible! at the moment i've got Code: [Select] <?php $url = $_SERVER['REQUEST_URI']; $tag = strstr ($url, 'sobi2Id='); echo $tag; ?> but this returns an unexpected T_STRING, expecting ',' or ';' Can anyone debug this? I may well be being really silly! This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=326004.0 Hi, I want to create a search which uses the 'title' of my 'product' table and matches the terms the user has submitted. At the moment, my products are displaying one by one. For example, I have an apple and apricot in my table. The user searches 'a' and the search results show 'apple' but not apricot. Here's my code: Code: [Select] <?php require_once('inc/global.inc.php'); # search.inc.php /* * This is the search content module. * This page is included by index.php. * This page expects to receive $_GET['terms']. */ // Redirect if this page was accessed directly: if (!defined('BASE_URL')) { // Need the BASE_URL, defined in the config file: require_once ('../includes/config.inc.php'); // Redirect to the index page: $url = BASE_URL . 'index.php?p=search'; // Pass along search terms? if (isset($_GET['terms'])) { $url .= '&terms=' . urlencode($_GET['terms']); } header ("Location: $url"); exit; } // End of defined() IF. // Print a caption: echo '<h2>Search Results</h2>'; // Display the search results if the form // has been submitted. if (isset($_GET['terms']) && ($_GET['terms'] != 'Search...') ) { $terms = $_GET['terms']; $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die *('Error connecting to MySQL server'); // Query the database. $query = "SELECT * FROM product WHERE title LIKE '%$terms%'"; $result = mysqli_query($dbc, $query); // Fetch the results. $row = mysqli_fetch_array($result); // Print the results: $output[] = '<ul>'; $output[] = '<li>'.$row['title'] .': £'.$row['price'].'<br /><img src="'.$row['img'].'" alt="'.$row['title'].'" /></li>'; $output[] = '</ul>'; echo join('',$output); } else { // Tell them to use the search form. echo '<p class="error">Please use the search form at the top of the window to search this site.</p>'; } ?> A friend told me I need to use a for-each loop but I can't figure it out. Any help is appreciated, thanks for reading. I'm having some trouble with a GET search code; everything works until the stringresult but then it dies to Error Querying Database Code: [Select] <html> <body> <?php //Get sort setting and search terms from URL with GET $usersearch = $_GET['usersearch']; echo 'Search word: ' . $usersearch; echo '<br>'; require_once("dbvars.php"); //Connect to Database $dbc = mysqli_connect (DB_HOST, DB_USER, DB_PW, DB_NAME) or die ("Error connecting to database."); //Build the Query $query = "SELECT * FROM customers" . 'WHERE customers.given_name=\'' . $usersearch . '\''; echo $query; //Execute the Query $result = mysqli_query($dbc, $query) or die ("Error querying database."); //Create the Table Headings echo '<table border="1"><tr>'; echo '<td><b>First Name</b></td>'; echo '<td><b>Last Name</b></td>'; echo '<td><b>Address</b></td>'; echo '<td><b>City</b></td>'; echo '<td><b>Province</b></td>'; echo '<td><b>Postal Code</b></td>'; echo '<td><b>Phone Number</b></td>'; echo '</tr>'; //Display Results through Array Loop While ($row = mysqli_fetch_array($result)) { echo '<tr><td>' . $row['given_name'] . '</td>'; echo '<td>' . $row['surname'] . '</td>'; echo '<td>' . $row['address'] . '</td>'; echo '<td>' . $row['city'] . '</td>'; echo '<td>' . $row['province'] . '</td>'; echo '<td>' . $row['postal_code'] . '</td>'; echo '<td>' . $row['phone_number'] . '</td></tr>'; } '</table>'; // Close the database connection mysqli_close($dbc); ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get"> <input name="usersearch" type="text" size="30" /> <input name="submit" type="submit" value="go" /> </form> </body> </html> Hi im really confused and annoyed Im making a real estate website and im stuck ont eh searching for a house part. Im trying to set up some searches on the different parts of the house usign text boxes for area and postcode and drop boxes for type and bedrooms and bathrooms i now you have to set up a form with input type text and then call it a name use get/post on a php side and then $_POST['search']; But i dnt seem to be able to make a search was hoping someone was kind enough to knock me up some quick code so it is functional and makbe i can work from it A;so any help towards searching using dropboxes would be awsume and if i have 2 boxes for price upper and lower how would this work Much appreciated So I've full text indexed the columns I want searchable: I have some rows inserted: Yet when I run a match() against(), I get 0 results: If I do: Code: [Select] SELECT * FROM video WHERE MATCH (name) AGAINST ('test') I get 2 results. Why does that work, yet keywords don't? Ok I have a set of PDF files that i need to be searchable. My question how do i go about doing this. Can this be achieved with php or do a need to do something else? I've been reading a few tutorials on how the best way to search key words in a database and at the moment im trying to get this query to work but its coming back with a error:
#1191 - Can't find FULLTEXT index matching the column listquery: SELECT title, description FROM items WHERE MATCH(title, description) AGAINST('xbox')any help or advise on how the best way to search 2 columns on matching words...thank you I have the following function, which takes a string with commas in it and attempts remove those commas. The way I have it here is that I use explode to take out the commas, which makes an array, and then iterate through that array to put a string back together without the commas. function tags_to_sort_by( $sortMeta ) { $sortByArray = explode(",", $sortMeta); $sortByCount = count($sortByArray); for ($i = 0; $i < $sortByCount; $i++) { $sortByString += $sortByArray[$i]; } return $sortByString; } What does not work is the following line: $sortByString += $sortByArray[$i]; Somehow that outputs a 0, which I don't understand. It should output something like: arrayItem1 arrayItem2 array3 etc. My question is if there either is an easier way to remove the commas from the original string or what I am doing wrong in this line: $sortByString += $sortByArray[$i]; // I am trying to concatenate each part of the array back into the string. Thanks a lot for help with this! I have a text string and I need to find the value that appears after a certain value: Value that appears after "XXX:" "Test 123 Hello XXX: 1 Test 555"; So the value would be "1" Any ideas? I am working on a poject, where the search functions doesnt work as the user wishes. The coding is technically correct, but the idea behind it is wrong. Basically at the moment, the script receives this: thesite.com/search.php?q=xxxx&Submit=Search The search script then runs a database query to search the tag coloumn, looking for like $q. This would work, however the structure of the coloumn is tag1, tag2, tag3, tag4. So my resolutions is this so far: I explode the $q variable, via the + (if you search more than one term "thesite.com/search.php?q=search+stuff&Submit=Search" I then count the elements in the array and write the database function accordingly Code: [Select] $var = @$_GET['q'] ; $trimmed = trim($var); $searchpieces = explode("+", $trimmed); $dbquery=""; $count = count($searchpieces); for ($i = 0; $i < $count; $i++) { if($i == 0){$dbquery.="tags = $searchpieces[$i]";} elseif($i > 0){$dbquery.=" OR tags = $searchpieces[$i]";} } So my database query is $sql = "select * from gallery where $dbquery order by date DESC " . $limit; so my question is this.. how to i eplode the tags database coloumn, so my datase query an look at each tag fro "tag1, tag2, tag3" as "tag1" "tag2" "tag3" I am not even sure if this is possible, but its the system that is already in place. The problem with the current system, is because the pictures have alot of tags and the database query is $like $q, it just shows all images in the database as the result Hi everyone,
I've got a simple script that is searching for the results of running races in a database.
Searching for a finisher's position works perfectly with this script:
$position = $_POST['position']; $pos_operator = $_POST['pos_operator']; if ($pos_operator == '=' && $position != '' ) { $where .= " AND position='$position'"; } if ($pos_operator == '<' && $position != '' ) { $where .= " AND position<'$position'"; }$position refers to a text field in the form where the user can type in a digit. $pos_operator refers to a text field in the form where a user can select = or < However, when I try to do a similar thing with time, I'm not getting the expected results. $time_stated = strtotime($_POST['time_stated']); if ($time_stated != '' ) { $where .= " AND time < '$time_stated'"; }$time_stated refers to a text field where the user is asked to look for a time less than the time they input in xx:xx:xx format. I tried this with and without the strtotime Any tips? Cheers, Dave I am including my test.php for other to run. I have a very large array of concatenated hash values. I have another array that contains the first 8 hash values of the other array. I have a function to locate them in the larger array. Depending on their index value I then choose the index of the value before or behind them for adding to something else later. This 'computeWalk' method works for small arrays but for larger arrays I notice duplicates or errors with larger ones. For example. The first array returns: Array ( => 1 [1] => 18 [2] => 18 [3] => 35 [4] => 33 [5] => 33 ) The values for i's to get each of these values are I = 0 I = 19 I = 29 I = 34 I = 37 I = 39 Walking through the method by hand, 0%2 = 0 So the first element of the array will be 1. CORRECT. 19%2 = 1 So the next element will be 18. CORRECT. 29%2 = 1 The next element should be 28. It returns 18. 34%2 = 0 The next element will be 35. Correct. 37%2 = 1 The next element should be 36. It returns 33. 39%2 = 1 The next element should be 38. It returns 33. I am not sure why it's doing the above. I also tried array_search and it computed it the same way. Would appreciate any help. <?php $arrayTree = array(); $arrayTree[0] = "9d027b1c4068d81287c9170f4b291387f8327eb7"; $arrayTree[1] = "4c8fabdc24c2d8205db916a22e9459195833a272"; $arrayTree[2] = "209526afab9e85b54e1832a820a7f578b7760af0"; $arrayTree[3] = "59d6926525e941edca99493b2b2a4f0a6efcb757"; $arrayTree[4] = "c8b49b8e414a09ddb693c580ecdfa6793c845f9d"; $arrayTree[5] = "b207bea6c4833d90f6ee4e694ffb148c046b0eb3"; $arrayTree[6] = "6d72a84b3aefbd3766078ed17a19aebb0c4ae026"; $arrayTree[7] = "b00207b8944520ea3817334615a7cdbf8214232a"; $arrayTree[8] = "d934f53af9bee26f35df7206dc06211778996986"; $arrayTree[9] = "de2ecd02fd017b0311dbfe589b5faa7954ced196"; $arrayTree[10] = "7d9752d09d3097fac748b6767472f9b69a65ed2e"; $arrayTree[11] = "62630fe109b42747b4c53065ec96aabf7b14d7b6"; $arrayTree[12] = "d727b5b8ffaeadbac75123801c270fd65f19251c"; $arrayTree[13] = "e39a9141fd9ce9426e88f30b6f245fdbb8f887a5"; $arrayTree[14] = "85fe053baa7ccf469c440a7dd98381228a0c52c3"; $arrayTree[15] = "6199634d410d0c91fd6ff99af9eabd5a1c7911de"; $arrayTree[16] = "af594de7d539519445013b7c87f02edbf3c44653"; $arrayTree[17] = "b6eb6dab75d092f4be345925ccbf87ff1e17fc31"; $arrayTree[18] = "2163ca6b0a608242712af82a81599f1f95c26dee"; $arrayTree[19] = "9d027b1c4068d81287c9170f4b291387f8327eb74c8fabdc24c2d8205db916a22e9459195833a272"; $arrayTree[20] = "209526afab9e85b54e1832a820a7f578b7760af059d6926525e941edca99493b2b2a4f0a6efcb757"; $arrayTree[21] = "c8b49b8e414a09ddb693c580ecdfa6793c845f9db207bea6c4833d90f6ee4e694ffb148c046b0eb3"; $arrayTree[22] = "6d72a84b3aefbd3766078ed17a19aebb0c4ae026b00207b8944520ea3817334615a7cdbf8214232a"; $arrayTree[23] = "d934f53af9bee26f35df7206dc06211778996986de2ecd02fd017b0311dbfe589b5faa7954ced196"; $arrayTree[24] = "7d9752d09d3097fac748b6767472f9b69a65ed2e62630fe109b42747b4c53065ec96aabf7b14d7b6"; $arrayTree[25] = "d727b5b8ffaeadbac75123801c270fd65f19251ce39a9141fd9ce9426e88f30b6f245fdbb8f887a5"; $arrayTree[26] = "85fe053baa7ccf469c440a7dd98381228a0c52c36199634d410d0c91fd6ff99af9eabd5a1c7911de"; $arrayTree[27] = "af594de7d539519445013b7c87f02edbf3c44653b6eb6dab75d092f4be345925ccbf87ff1e17fc31"; $arrayTree[28] = "2163ca6b0a608242712af82a81599f1f95c26dee"; $arrayTree[29] = "9d027b1c4068d81287c9170f4b291387f8327eb74c8fabdc24c2d8205db916a22e9459195833a272209526afab9e85b54e1832a820a7f578b7760af059d6926525e941edca99493b2b2a4f0a6efcb757"; $arrayTree[30] = "c8b49b8e414a09ddb693c580ecdfa6793c845f9db207bea6c4833d90f6ee4e694ffb148c046b0eb36d72a84b3aefbd3766078ed17a19aebb0c4ae026b00207b8944520ea3817334615a7cdbf8214232a"; $arrayTree[31] = "d934f53af9bee26f35df7206dc06211778996986de2ecd02fd017b0311dbfe589b5faa7954ced1967d9752d09d3097fac748b6767472f9b69a65ed2e62630fe109b42747b4c53065ec96aabf7b14d7b6"; $arrayTree[32] = "d727b5b8ffaeadbac75123801c270fd65f19251ce39a9141fd9ce9426e88f30b6f245fdbb8f887a585fe053baa7ccf469c440a7dd98381228a0c52c36199634d410d0c91fd6ff99af9eabd5a1c7911de"; $arrayTree[33] = "af594de7d539519445013b7c87f02edbf3c44653b6eb6dab75d092f4be345925ccbf87ff1e17fc312163ca6b0a608242712af82a81599f1f95c26dee"; $arrayTree[34] = "9d027b1c4068d81287c9170f4b291387f8327eb74c8fabdc24c2d8205db916a22e9459195833a272209526afab9e85b54e1832a820a7f578b7760af059d6926525e941edca99493b2b2a4f0a6efcb757c8b49b8e414a09ddb693c580ecdfa6793c845f9db207bea6c4833d90f6ee4e694ffb148c046b0eb36d72a84b3aefbd3766078ed17a19aebb0c4ae026b00207b8944520ea3817334615a7cdbf8214232a"; $arrayTree[35] = "d934f53af9bee26f35df7206dc06211778996986de2ecd02fd017b0311dbfe589b5faa7954ced1967d9752d09d3097fac748b6767472f9b69a65ed2e62630fe109b42747b4c53065ec96aabf7b14d7b6d727b5b8ffaeadbac75123801c270fd65f19251ce39a9141fd9ce9426e88f30b6f245fdbb8f887a585fe053baa7ccf469c440a7dd98381228a0c52c36199634d410d0c91fd6ff99af9eabd5a1c7911de"; $arrayTree[36] = "af594de7d539519445013b7c87f02edbf3c44653b6eb6dab75d092f4be345925ccbf87ff1e17fc312163ca6b0a608242712af82a81599f1f95c26dee"; $arrayTree[37] = "9d027b1c4068d81287c9170f4b291387f8327eb74c8fabdc24c2d8205db916a22e9459195833a272209526afab9e85b54e1832a820a7f578b7760af059d6926525e941edca99493b2b2a4f0a6efcb757c8b49b8e414a09ddb693c580ecdfa6793c845f9db207bea6c4833d90f6ee4e694ffb148c046b0eb36d72a84b3aefbd3766078ed17a19aebb0c4ae026b00207b8944520ea3817334615a7cdbf8214232ad934f53af9bee26f35df7206dc06211778996986de2ecd02fd017b0311dbfe589b5faa7954ced1967d9752d09d3097fac748b6767472f9b69a65ed2e62630fe109b42747b4c53065ec96aabf7b14d7b6d727b5b8ffaeadbac75123801c270fd65f19251ce39a9141fd9ce9426e88f30b6f245fdbb8f887a585fe053baa7ccf469c440a7dd98381228a0c52c36199634d410d0c91fd6ff99af9eabd5a1c7911de"; $arrayTree[38] = "af594de7d539519445013b7c87f02edbf3c44653b6eb6dab75d092f4be345925ccbf87ff1e17fc312163ca6b0a608242712af82a81599f1f95c26dee"; $arrayTree[39] = "9d027b1c4068d81287c9170f4b291387f8327eb74c8fabdc24c2d8205db916a22e9459195833a272209526afab9e85b54e1832a820a7f578b7760af059d6926525e941edca99493b2b2a4f0a6efcb757c8b49b8e414a09ddb693c580ecdfa6793c845f9db207bea6c4833d90f6ee4e694ffb148c046b0eb36d72a84b3aefbd3766078ed17a19aebb0c4ae026b00207b8944520ea3817334615a7cdbf8214232ad934f53af9bee26f35df7206dc06211778996986de2ecd02fd017b0311dbfe589b5faa7954ced1967d9752d09d3097fac748b6767472f9b69a65ed2e62630fe109b42747b4c53065ec96aabf7b14d7b6d727b5b8ffaeadbac75123801c270fd65f19251ce39a9141fd9ce9426e88f30b6f245fdbb8f887a585fe053baa7ccf469c440a7dd98381228a0c52c36199634d410d0c91fd6ff99af9eabd5a1c7911deaf594de7d539519445013b7c87f02edbf3c44653b6eb6dab75d092f4be345925ccbf87ff1e17fc312163ca6b0a608242712af82a81599f1f95c26dee"; $arrayTree[40] = "54u58rfhfheyrr4gfdtfvgw36tr36"; $arrayTree[41] = "54u58rfhfheyrr4gfdtfvgw36tr369d027b1c4068d81287c9170f4b291387f8327eb74c8fabdc24c2d8205db916a22e9459195833a272209526afab9e85b54e1832a820a7f578b7760af059d6926525e941edca99493b2b2a4f0a6efcb757c8b49b8e414a09ddb693c580ecdfa6793c845f9db207bea6c4833d90f6ee4e694ffb148c046b0eb36d72a84b3aefbd3766078ed17a19aebb0c4ae026b00207b8944520ea3817334615a7cdbf8214232ad934f53af9bee26f35df7206dc06211778996986de2ecd02fd017b0311dbfe589b5faa7954ced1967d9752d09d3097fac748b6767472f9b69a65ed2e62630fe109b42747b4c53065ec96aabf7b14d7b6d727b5b8ffaeadbac75123801c270fd65f19251ce39a9141fd9ce9426e88f30b6f245fdbb8f887a585fe053baa7ccf469c440a7dd98381228a0c52c36199634d410d0c91fd6ff99af9eabd5a1c7911deaf594de7d539519445013b7c87f02edbf3c44653b6eb6dab75d092f4be345925ccbf87ff1e17fc312163ca6b0a608242712af82a81599f1f95c26dee"; $arrayDocs = array(); $arrayDocs[0] = "9d027b1c4068d81287c9170f4b291387f8327eb7"; $arrayDocs[1] = "4c8fabdc24c2d8205db916a22e9459195833a272"; $arrayDocs[2] = "209526afab9e85b54e1832a820a7f578b7760af0"; $arrayDocs[3] = "59d6926525e941edca99493b2b2a4f0a6efcb757"; $arrayDocs[4] = "c8b49b8e414a09ddb693c580ecdfa6793c845f9d"; $arrayDocs[5] = "b207bea6c4833d90f6ee4e694ffb148c046b0eb3"; $arrayDocs[6] = "6d72a84b3aefbd3766078ed17a19aebb0c4ae026"; $arrayDocs[7] = "b00207b8944520ea3817334615a7cdbf8214232a"; $arrayDocs[8] = "d934f53af9bee26f35df7206dc06211778996986"; $arrayDocs[9] = "de2ecd02fd017b0311dbfe589b5faa7954ced196"; $arrayDocs[10] = "7d9752d09d3097fac748b6767472f9b69a65ed2e"; $arrayDocs[11] = "62630fe109b42747b4c53065ec96aabf7b14d7b6"; $arrayDocs[12] = "d727b5b8ffaeadbac75123801c270fd65f19251c"; $arrayDocs[13] = "e39a9141fd9ce9426e88f30b6f245fdbb8f887a5"; $arrayDocs[14] = "85fe053baa7ccf469c440a7dd98381228a0c52c3"; $arrayDocs[15] = "6199634d410d0c91fd6ff99af9eabd5a1c7911de"; $arrayDocs[16] = "af594de7d539519445013b7c87f02edbf3c44653"; $arrayDocs[17] = "b6eb6dab75d092f4be345925ccbf87ff1e17fc31"; $arrayDocs[18] = "2163ca6b0a608242712af82a81599f1f95c26dee"; foreach($arrayDocs as $doc) { $bitIndex = computeWalk($arrayTree, $doc); echo "<br/>"; print_r($bitIndex); echo "<br/>"; } function computeWalk($array, $needle) { $result = array(); for ($i = 0; $i < count($array) - 1; $i++) { if (false !== strpos($array[$i], $needle)) { echo " I = ".$i; if ($i % 2 == 0) { $result[] = getItemIndex($array[$i + 1], $array); } else { $result[] = getItemIndex($array[$i - 1], $array); } } } return $result; } function getItemIndex($item, $array) { $myPosition=-1; for ($i = 0; $i<count($array)-1; $i++) { if($array[$i]==$item) { $myPosition = $i; break; } } return $myPosition; } ?> Dear All, Greetings! I am a student and have a final semester project of making a php based form to search a database. Database is already created: Username: test password: test1 Details: DB Name: resume_bank, Table Name: Candidate Table contents: Name, Phone, Address, DOB, Gender, Designation, experience_yrs, experience_months, Employment_Status I need the code which would give the user an option to search using AND, OR, ALL functions. Friends please help. The form should look like: Enter the Designation you are looking for: Enter the experience: Yrs___ Months___ Select Gender: The result must come in another webpage which has numbered display results, like page-1, page-2, page3... PLEASE HELP URGENTLY!!!!!!! ANY BODY HAS READY MADE CODE PLEASE SEND IT!!!!!! Thanks. Hey, Looking to find a solution to something. I have been experimenting making a template engine for a website I am building. How can I search a variable for all occurrences of {VARIABLE} eg. {Username} {Title} {Content} so I can str_replace them. Thank you |