PHP - 3 Days Old To Php And Need A Little Help Pls. (output Table And Search Question)
Hello All,
Iam completely new (3days old) to sql, php, html, so could do with a little help. Ok so I just found out about this wonderfull world and thought i would give it a try and I like it. But as I have no real idea of what Iam doing Iam finding it abit tricky to change some of the code I found at. http://www.phpfreaks.com/tutorial/simple-sql-search By the way thanks for this. So far I have setup a wamp server and got it all working fine and tweeked the above details in the url. This works great (well chuffed). But I could do with changing two things for now. 1). I could do with beeing able to search multiple things in the one text box for example. If I inputed "hello world" or "hel wor" it would search through the 19,000 lines in my database and find all instances of "hello" and "world" or "hel" "wor" in the same line's, it dosent matter what column they are in and output those lines. The code has the option to search all feilds "matchall" but not multiple words or parts of words.(hope that made sense I dont know all the terminology) It could be like using wild cards I suppose??. Is this possible or would I need multiple search boxes and if so how would I do that? 2). I would like the results to be returned in a table with headings for each column. If any one can help this would be great and thanks in advance for checking the long post out. Nick. Sorry if this is out there already but not to sure what I need to search for!??!?!? Ill include what Iam using so far. <?php $dbHost = 'localhost'; // localhost will be used in most cases // set these to your mysql database username and password. $dbUser = 'root'; $dbPass = ''; $dbDatabase = 'Stk_search'; // 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 id, Stock_Code, SV_Part_Number, SV_Description, SV_Search_Key FROM stkdb1 WHERE "; // grab the search types. $types = array(); $types[] = isset($_GET['Stock_Code'])?"`Stock_Code` LIKE '%{$searchTermDB}%'":''; $types[] = isset($_GET['SV_Part_Number'])?"`SV_Part_Number` LIKE '%{$searchTermDB}%'":''; $types[] = isset($_GET['SV_Description'])?"`SV_Description` LIKE '%{$searchTermDB}%'":''; $types[] = isset($_GET['SV_Search_Key'])?"`SV_Search_Key` LIKE '%{$searchTermDB}%'":''; $types = array_filter($types, "removeEmpty"); // removes any item that was empty (not checked) if (count($types) < 1) $types[] = "`Stock_Code` LIKE '%{$searchTermDB}%'"; // use the body as a default search if none are checked $andOr = isset($_GET['matchall'])?'AND':'OR'; $searchSQL .= implode(" {$andOr} ", $types) . " ORDER BY `Stock_Code`"; // order by title. $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[] = "{$i}: {$row['Stock_Code']}<br />{$row['SV_Part_Number']}<br />{$row['SV_Description']}<br />{$row['SV_Search_Key']}<br /><br />"; $i++; } } } } function removeEmpty($var) { return (!empty($var)); } ?> <html> <title>My Simple Search Form</title> <style type="text/css"> #error { color: red; } </style> <body> <?php echo (count($error) > 0)?"The following had errors:<br /><span id=\"error\">" . implode("<br />", $error) . "</span><br /><br />":""; ?> <form method="GET" action="<?php echo $_SERVER['PHP_SELF'];?>" name="searchForm"> Search For: <input type="text" name="search" value="<?php echo isset($searchTerms)?htmlspecialchars($searchTerms):''; ?>" /><br /> Search In:<br /> Stock_Code: <input type="checkbox" name="Stock_Code" value="on" <?php echo isset($_GET['Stock_Code'])?"checked":''; ?> /> | SV_Part_Number: <input type="checkbox" name="SV_Part_Number" value="on" <?php echo isset($_GET['SV_Part_Number'])?"checked":''; ?> /> | SV_Description: <input type="checkbox" name="SV_Description" value="on" <?php echo isset($_GET['SV_Description'])?"checked":''; ?> /> | SV_Search_Key: <input type="checkbox" name="SV_Search_Key" value="on" <?php echo isset($_GET['SV_Search_Key'])?"checked":''; ?> /><br /> Match All Selected Fields? <input type="checkbox" name="matchall" value="on" <?php echo isset($_GET['matchall'])?"checked":''; ?><br /><br /> <input type="submit" name="submit" value="Search!" /> </form> <?php echo (count($results) > 0)?"Your search term: {$searchTerms} returned:<br /><br />" . implode("", $results):""; ?> </body> </html> Similar TutorialsHi all. I have an issue and don't know how to go about it. I have a table that contains user orders. I want to move only orders that will be due in 10 days time to another table. How can I achieve that? thanks Hello, I am trying to display rainfall totals for the year so far in a table with months going across and days going down. Like so: -- Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 1 2 3 4 5 6 7 8 etc And then have the rainfall totals for each day in the table, I am quite experienced with PHP however I cant work out how I would do this The data is stored in a mysql table called "wx_daily", and the rainfall column is called" RainTotal". The dates are stored in the "Date" column in mysql Date format. Im using the following mysql query: SELECT * FROM wx_daily WHERE YEAR(Date) = '2011' ORDER BY Date Asc Thanks, Mark Hello everyone. I need help with the following PHP APP. I am running on (Version PHP 7.2.10) I am trying to have a page table form on table.php pass the input variable of “5-Numbers” to another page called table_results.php I want that variable string of “5-Numbers” to be compared against 4 arrays and output any duplicates found within each of those 4 lists. If nothing is found, I still want some visual output that reads “None found”.
Lets pretend I have the following example .. On table.php, I typed inside my table form the 5-Numbers .. INPUT: 2,15,37,13,28 On table_results.php, the 4 arrays to be compared against my input numbers “ 2,15,37,13,28” are ..
$array_A = array(2,6,8,11,14,18,24); $array_B = array(1,2,9,10,13,14,25,28,); $array_C = array(1,3,7,9,13,15,20,21,24); $array_D = array(4,5,12,22,23,27,28,29);
So my output should read as follows below .. OUTPUT:
TABLE COLUMN 1 COLUMN 2 ROW 1 Matches Found Results .. ROW 2 GROUP A: 2 ROW 3 GROUP B: 2,13,28 ROW 4 GROUP ? 13,15 ROW 5 GROUP ? 28 ROW 6 5#s Input: 2,15,37,13,28
Please let me know if anyone has any suggestions on how to go about it. Thanks. Edited January 1, 2019 by Jayfromsandiego Wanted to include image example Trying to do something that I think should be very simple. Let's assume that I have an array populated with the numbers 1 to 24 for this example. I need to output these items in 4 columns to accomodate my CSS layout but still have them read from left to right, top to bottom. I also want this to be somewhat dynamic - I'm okay hardcoding it to split into 4 columns, but need it to handle any number of items in the array. I'm not sure if the best way to do this would be to split the original array into an array for each of the 4 columns, or to loop through the original array 4 times and output items 1+4, 2+4, and so on. Or maybe I should be using array_filter with some custom callback functions. I'm fine with any solution. The end result is echoing the array in the following groupings so I can surround each column with the appropriate column HTML for layout (in this case the array actually contains IMG urls): Column 1: 1, 5, 9, 13, 17, 21 Column 2: 2, 6, 10, 14, 18, 22 Column 3: 3, 7, 11, 15, 19, 23 Column 4: 4, 8, 12, 16, 20, 24 Any help would be appreciated! This one is driving me nuts and I know it should be relatively easier. Guess I should stick to HTML + CSS. Hi, I need a quick tip. I want this script to produce an output of "Table created" if it succesfully creates a table. <?php $con = mysql_connect("localhost","****","****"); if (!$con) { die('Could not connect: ' . mysql_error()); } // Create table mysql_select_db("my_db", $con); $sql = "CREATE TABLE People ( FirstName varchar(15), LastName varchar(15), Age int )"; // Execute query mysql_query($sql,$con); mysql_close($con); ?> I tried to do it on my own, but I guess I'm still completely new to php I tried: <?php $con = mysql_connect("localhost","****","****"); if (!$con) { die('Could not connect: ' . mysql_error()); } // Create table if (mysql_select_db("my_db", $con)) { echo "Table created"; } else { echo "Error creating Table: " . mysql_error(); } $sql = "CREATE TABLE People ( FirstName varchar(15), LastName varchar(15), Age int )" // Execute query mysql_query($sql,$con); mysql_close($con); ?> It gave me an error with the last two lines mysql_query($sql,$con); mysql_close($con); I removed them and it really did give the output "Table created" yet it didn't create the table in the database. I'm having a feeling that I need to add an "if" statement, something of the sort. if (sql(CREATE TABLE Persons)) But I'm also getting the feeling something there is wrong, I still haven't tried it. Help? Hi Guys, I have a query and a while loop output that I am sending to a webpage in a table format but I need some help in how best to do this so that the table columns line up with each other. Right now the column width seems to change depending on the data in the row. The code is quite simple: <?php include("lib/config.php"); $query = "SELECT * FROM staff_member"; $result = mysql_query($query); ?> <html> <style type="text/css"> <!-- @import url(style/style.css); --> </style> <head> </head> <body> <h2 align="center"> Full Staff list with Dependants</font></h2> <?php while($row = mysql_fetch_object($result)) { echo "<table id=sample> <th>Title</th> <th>First Name</th> <th>Initial</th> <th>Last</th> <th>Agency</th> <th>Street</th> <th>Address</th> <th>Parish</th> <th>Country</th> <th>Office Tel#</th> <th>Home Tel#</th> <th>Office Mobile#</th> <th>Personal Mobile#</th> <th>Zone</th> <th>Status</th> <th>Location</th> <th>Updated by</th> <tr> <td>" .$row->title ."</td> <td>" .$row->first ."</td> <td>" .$row->initial ."</td> <td>" .$row->last ."</td> <td>" .$row->agency ."</td> <td>" .$row->street ."</td> <td>" .$row->adress ."</td> <td>" .$row->parish ."</td> <td>" .$row->country ."</td> <td>" .$row->officetel ."</td> <td>" .$row->hometel ."</td> <td>" .$row->officemobile ."</td> <td>" .$row->personalmobile ."</td> <td>" .$row->zone ."</td> <td>" .$row->status ."</td> <td>" .$row->location ."</td> <td>" .$row->updater ."</td> </tr>"; echo "</table> </br>"; }//close $row while ?> </body> </html> Any help appreciated! Hi, Stuck again with the Joomla/K2 coding. Trying to output this field in a 2 column table but failing badly. Any help or ideas would be greatly appreciated. <?php if($this->item->params->get('catItemExtraFields') && count($this->item->extra_fields)): ?> <!-- Item extra fields --> <div class="catItemExtraFields"> <h4><?php echo JText::_('K2_ADDITIONAL_INFO'); ?></h4> <ul> <?php foreach ($this->item->extra_fields as $key=>$extraField): ?> <?php if($extraField->value): ?> <li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>"> <?php if ($extraField->name =='Closing date') : ?> <span class="catItemExtraFieldsLabel"><?php echo $extraField->name; ?></span> <span class="catItemDateCreated"><?php echo JHTML::_('date', $this->item->publish_down ); ?></span> <?php else :?> <span class="catItemExtraFieldsLabel"><?php echo $extraField->name; ?></span> <span class="catItemExtraFieldsValue"><?php echo $extraField->value; ?></span> <?php endif; ?> </li> <?php endif; ?> <?php endforeach; ?> </ul> <div class="clr"></div> </div> <?php endif; ?> Ok, I know this is a really simple one, but I haven't done any coding for a couple of month and i'm a bit rusty. I'm trying to add a field from a MySQL query to a Google calendar add button link so I can create a dynamic 'add to calendar' button from my gig list. So on the gig list page that echo's all the dates from the database, I want to add the venue name to the 'text' section of the google URL - Code: [Select] <a href=\"http://www.google.com/calendar/event?action=TEMPLATE&text=VENUE HERE&dates=20060101T000000Z/20060101T000000Z&details=gig%20text&location=gig%20town&trp=false&sprop=www.the-guards.co.uk&sprop=name:The%20Guards\" target=\"_blank\"><img src=\"http://www.google.com/calendar/images/ext/gc_button6.gif\" border=0></a> if I echo the field like so - Code: [Select] echo"{$row['gl_venue']}"; I get the correct result - I just can remember how to embed the php within the html, everything i've tried has failed so far. Once i've got this sorted i can go ahead and add the date, location fields etc. Hi guys I am new here I have had a search around and can't really find out how to do this. Its quite difficult for me to explain and I am really new to PHP / mySQL - just starting out really. I hope to learn from doing small projects like this and seeing how it gets done. So I have a mySQL DB with two different tables - one is called "notesnew" the other is called "users". I have modified a common tutorial on how to make a "to do list" for what I am doing here. Basically users can login and post messages on this list as them self. Each user's post appears as a list item, showing their username, the time they posted the message and the message content. The message content, time and owner of the message is stored in the "notesnew" table. The list of user's, their passwords and their "avatar/profile" image URL location is stored in the "users" table. Now I am having trouble getting each user's avatar image from being output next to each of their posts. The part that is confusing me is being able to match up the username's post with their content that is display - because I am posting the user's name along with their post, based on the logged in "session name" as their username. So basically, all the content being listed is being displayed from the "notesnew" table. I need to somehow figure out what each user's profile image is based on what is stored against their entry in the "users" table. Here is the code I have so far. It is not working properly - it displays all content etc, but displays the avatar / image of the last user that has registered. Can anyone help me out here with some code that works, or pointers to try follow? I know the $finduserprofile part is incorrect in the way it goes through all user's and finds their profileimg, and that the image displayed next to each post is therefore incorrect (as it displays the last member to have registered's avatar, but its just that I don't know how else to do what I am trying to do. Code: [Select] <?php //Connect to the database $connection = mysql_connect('localhost', 'zzzz' , 'zzzzzzz'); $selection = mysql_select_db('zzzzz', $connection); $username = $_COOKIE['ID_my_site']; //Was the form submitted? if($_POST['submit']){ //Map the content that was sent by the form a variable. Not necessary but it keeps things tidy. $content = $_POST['content']; //Insert the content into database $ins = mysql_query("INSERT INTO `notesnew` (content, owner, dp_time) VALUES ('$content', '$username', NOW())"); //Redirect the user back to the members or index page header("Location:index.php"); } /*Doesn't matter if the form has been posted or not, show the latest posts*/ //Find all the notes in the database and order them in a descending order (latest post first). $find = mysql_query("SELECT * FROM `notesnew` ORDER BY id DESC"); $finduserprofile = mysql_query("SELECT * FROM `users` ORDER BY id DESC"); //Setup the un-ordered list echo '<ul>'; while($row = mysql_fetch_array($finduserprofile)) { $imagelocation = $row['profileimg']; //Continue looping through all of them while($row = mysql_fetch_array($find)) { $owner = $row['owner']; //For each one, echo a list item giving a link to the delete page with it's id. echo '<li>' . '<img src ="' . $imagelocation . '">' . $row['owner'] . ' said at ' . $row['dp_time'] . ': ' . $row['content'] . ' <a id="' . $row['id'] . '" href="delete.php?id=' . $row['id'] . '"><img src="delete.png" alt="Delete?" /></a></li>'; } } //End the un-ordered list echo '</ul>'; ?> Hello, I seem to have some problem with my script that has a goal of outputting data about the file size when a filename is queried.
The sql table name is file
The table columns are as followed: id | name | mime | size
The file name is stored in name. The script that i have that gets the file name is:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <meta name="generator" content="Adobe GoLive" /> <title>File Select</title> <!--The following script tag downloads a font from the Adobe Edge Web Fonts server for use within the web page. We recommend that you do not modify it.--><script>var __adobewebfontsappname__="dreamweaver"</script><script src="http://use.edgefonts.net/aguafina-script:n4:default.js" type="text/javascript"></script> </head> <body> <div id="title"> <h3 align="center">File Upload</h3> </div> <form action="result.php" method="post" name="fileID" target="_self" class="inp" AUTOCOMPLETE="ON"> <h1> <!--Input file name--> <label for="fileID">File Name: </label> <input type="text" name='file1' id='sampleID' list="samp"> </input><br> <datalist id="samp"> <?php $connect = mysql_connect('localhost', 'root', ''); mysql_select_db("test_db"); $query = mysql_query("SELECT * FROM `file` ORDER BY `file`.`name` ASC LIMIT 0 , 30"); WHILE ($rows = mysql_fetch_array($query)): $File_name = $rows['name']; echo "<option value=$File_name>$File_name/option> <br>"; endwhile; ?> </datalist> <input type="submit" class="button" > </form> </body> </html> I have a function which finds a list of companies associated with a country from a custom taxonomy. It finds their logo and creates an output which is all logos associated with a country, and the logo has a href to link to a company page. The code for this is: function countryCompanies(){ global $post;
$echo = f_print(array(
The f_print function finds the logos, and their sizes. So the 'mainlogo' type is a pull down of the thumbnail at 200px size.
What I need to do is write CSS and PHP which will display these results in a grid, 4 colums across, and as many down as results from the array. At the moment all I can get is all the results in one column. What tutorials would I need to write appropriate CSS to create this, and then is it as simple as adding the div prior to the echo of the $echo variable? Thanks I'm having some trouble with displaying my white space between words. I have a table that holds records for resumes, and the administrator can access each record and edit them. I have the record displayed in text boxes for editing, but the white space between words is not showing up. Only the first word will show up. I have tried changing the field type in the table to text or blob instead of varchar, and I have tried using the nl2br function when displaying the records, but that isn't working either. What am I doing wrong? Here is my edit page: Code: [Select] <?php $applicant = "SELECT * FROM applicants WHERE id = '$_GET[id]'"; $applicant_res = mysql_query($applicant, $conn) or die(mysql_error()); $display_block = "<h3>Edit Entry</h3> <p>To edit the entry, change any relevant information below:</p> <form method=post action=update_U3IP.php><table>"; while ($applicants_list = mysql_fetch_array($applicant_res)){ $id = $applicants_list['id']; $firstname = $applicants_list['firstname']; $lastname = $applicants_list['lastname']; $address = $applicants_list['address']; $city = $applicants_list['city']; $state = $applicants_list['state']; $zip = $applicants_list['zip']; $phone = $applicants_list['phone']; $position = nl2br($applicants_list['position']); $file = $applicants_list['resume']; $display_block .= " <table> <tr> <td><label for=id><b>ID:</b></label></td> <td><input name=id type=text size=2 id=id value=$id /></td> </tr> <tr> <td><label for=firstname><b>First Name:</b></label></td> <td><input name=firstname type=text size=20 id=firstname value=$firstname /></td> </tr> <tr> <td><label for=lastname><b>Last Name:</b></label></td> <td><input name=lastname type=text size=20 id=lastname value=$lastname /></td> </tr> <tr> <td><label for=address><b>Address:</b></label></td> <td><input name=address type=text size=20 id=address value=$address /></td> </tr> <tr> <td><label for=city><b>City:</b></label></td> <td><input name=city type=text size=20 id=city value=$city /></td> </tr> <tr> <td><label for=state><b>State:</b></label></td> <td><input name=state type=text size=20 id=state value=$state /></td> </tr> <tr> <td><label for=zip><b>Zip:</b></label></td> <td><input name=zip type=text size=20 id=zip value=$zip /></td> </tr> <tr> <td><label for=phone><b>Phone:</b></label></td> <td><input name=phone type=text size=20 id=phone value=$phone /></td> </tr> <tr> <td><label for=position><b>Position:</b></label></td> <td><input name=position type=text size=20 id=position value=$position /></td> </tr> <tr> <td><b>Uploaded Resume:</b></td> <td><input type=text name=file id=file value=$file /></td> </tr> <tr> <td colspan=2> </td> </tr> <tr> <td colspan=2 align=center> <input type=hidden name=hidden_id id=hidden_id value=$id /> <input type=submit value=Submit /> <a href=admin_U3IP.php><input type=button name=back id=back value=Back /></a></td> </tr>"; } $display_block .= "</table></form>"; ?> <!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>KulaE_WDP4451_U3IP</title> </head> <body> <?php echo $display_block; ?> </body> </html> if I'm outputting from mysql with this: Code: [Select] // Connects to your Database mysql_connect("localhost", "root", "") or die(mysql_error()) ; mysql_select_db("test") or die(mysql_error()) ; //Retrieves data from MySQL $data = mysql_query("SELECT * FROM tickets") or die(mysql_error()); //Puts it into an array while($info = mysql_fetch_array( $data )) { //Outputs the image and other data Echo "<b>asset number:</b> ".$info['AssetNumber'] . "<br> "; Echo "<b>subject:</b> ".$info['subject'] . " <br>"; Echo "<b>notes:</b> ".$info['Notes'] . " <hr>"; } can I base the record it outputs somehow on this: Code: [Select] $value=""; $value = ProcessLargeText(GetData($data,"Asset Number", ""),"","",MODE_VIEW); if($mainTableOwnerID=="Asset Number") $ownerIdValue=$value; $xt->assign("Asset_Number_value",$value); if(!$pageObject->isAppearOnTabs("Asset Number")) $xt->assign("Asset_Number_fieldblock",true); else $xt->assign("Asset_Number_tabfieldblock",true); It's kind of like a job history so its getting records of job history from one table while the second piece of code is getting the asset details from a main table In this output table, I would like to be able to click on any number in the ama row, add .html to that value and then execute the link. Example: If the ama number in row 3 is 890543, add .html to the number = 890543.html, then click on it to link to that web page. <?php // Connect to database ========================================= include("connect_db.php"); $table1='passwords'; $table2='airplanes'; // send query =================================================== $result = mysql_query("SELECT * FROM $table2") or die(mysql_error()); if (!$result) { die("Query to show fields from table failed"); } echo "<table border='10' cellpadding='3' cellspacing='2'>"; echo "<p>View All Airplanes</p>"; echo "<tr> <th>ID</th> <th>AMA #</th> <th>Model Name</th> <th>Model MFG</th><th>Wingspan</th><th>Engine</th><th>Decibels</th></tr>"; // keeps getting the next row until there are no more to get ================ while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table ========================== echo "<tr><td>"; echo $row['id']; echo "</td><td>"; echo $row['ama']; // Append .html to this number echo "</td><td>"; echo $row['model_name']; echo "</td><td>"; echo $row['model_mfg']; echo "</td><td>"; echo $row['wingspan']; echo "</td><td>"; echo $row['engine']; echo "</td><td>"; echo $row['decibels']; echo "</td></tr>"; } echo "</table>"; ?> Hello I have three tables User diysmps usergroup usergroupid is common in the three tables. diysmps is joined on usergroup, so running this sql SELECT diysmps.name, diysmps.email, diysmps.sumbit, diysmps.message, diysmps.ID, usergroup.title FROM diysmps INNER JOIN usergroup ON diysmps.usergroupid = usergroup.usergroupid ORDER BY diysmps.ID DESC see results i get in picture attached. the result (PENDIN REGISTRATION) is what i need to be updated WHEN the user register to the forums. when the user register to the forums, an account with his EMAIL will be created into the (USER) table. So, I need to look out for the email FROM (diysmps TABLE) into the user table _search user table for email from diysmps table_ and if found to update the USERGROUPID in (diysmps TABLE) withe the USERGROUPID from (USER) table (related to the email searched) so, when user registers, status from PENDING REGISTRATION to REGISTERED will be shown I know it looks complex for me, but thats how i can describe Thanks all Hi guys, is there anyway to process this $result from a mysql query inside PHP so that the data below will be formatted to a pivot-like table? The number of rows and columns of the output 'table' will be indefinite. Thanks so much! Data: ID Row Col Name 1 1 A A1 2 2 A A2 3 3 A A3 4 1 B B1 5 2 B B2 6 3 B B3 7 1 C C1 8 2 C C2 9 3 C C3 Results: A1(1) A2(2) A3(3) B1(4) B2(5) B3(6) C1(7) C2( C3(9) 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. Hey all, I have a quick question and I know the answer is probably pretty easy but i've been working on it a while now and can't figure out how to get this done. SOO the situation is. I am looping through an RSS feed and with each entry I want to search for a brand name within the title, and add a company logo beside the entry. I was playing with something like this but it doesn't work real well.. // Find Kokatat $find = "Kokatat"; if(strstr($string, $find)) { $icon = "koksm.jpg"; } else { $icon = ""; } I appreciate any input! Hi Everyone,
I have a question about pagination. I have this code that I would like to incorporate into my php file.
This is said code that will be incorporated:
try { // Find out how many items are in the table $totalItems = $databaseHandle->query(' select count(*) from tableName ')->fetchColumn(); // Set how many items per page to display $limit = 10; // find how many pages are needed $totalPages = ceil($totalItems / $limit); // Find out which page we are on $currentPage = min($totalPages, filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT, array( 'options' => array( 'default' => 1, 'min_range' => 1, ), ))); // Calculate the offset for the query $offset = ($page - 1) * $limit; // Some information to display to the user $start = $offset + 1; $end = min(($offset + $limit), $total); // "back" link $prevlink = ($page > 1) ? '<a href="?page=1" title="First page">«</a> <a href="?page=' . ($currentPage - 1) . '" title="Previous page">‹</a>' : '<span class="disabled">«</span> <span class="disabled">‹</span>'; // "forward" link $nextlink = ($page < $pages) ? '<a href="?page=' . ($page + 1) . '" title="Next page">›</a> <a href="?page=' . $totalPages . '" title="Last page">»</a>' : '<span class="disabled">›</span> <span class="disabled">»</span>'; // Display the paging information echo '<div id="paging"><p>', $prevlink, ' Page ', $currentPage, ' of ', $totalPages, ' pages, displaying ', $start, '-', $end, ' of ', $totalItems, ' results ', $nextlink, ' </p></div>'; // Get the results. Paged query $stmt = $databaseHandle->prepare(' select * from tableName order by name limit :limit offset :offset '); // Bind the query params $stmt->bindParam(':limit', $limit, PDO:: PARAM_INT); $stmt->bindParam(':offset', $offset, PDO:: PARAM_INT); $stmt->execute(); // Results? if ($stmt->rowCount() > 0) { $stmt->setFetchMode(PDO::FETCH_ASSOC); $iterator = new IteratorIterator($stmt); // Display the results foreach ($iterator as $row) { echo '<p>', $row['name'], '</p>'; } } else { echo '<p>No results could be displayed.</p>'; } } catch (Exception $e) { echo '<p>', $e->getMessage(), '</p>'; }and this is what is in my php file: <html> <head></head> <body> <?php if (!isset($_POST['q'])) { ?> <img src="/wvb-logo-slogen.png" border="0" /> <h2>Search</h2> <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> <input type="text" name="q" size="30" /> </form> <?php } else { ?> <img src="/wvb-logo-slogen.png" border="0" /> <h2>Search Results</h2> <?php try { // create object // $swish = new Swish('/usr/local/apache/htdocs/swish/index.swish-e'); $swish = new Swish('/var/www/html/pdf2/index.swish-e'); // get and run query from command-line $queryStr = htmlentities($_POST['q']); $result = $swish->query($queryStr); ?> Found <?php echo $result->hits; ?> match(es) for '<?php echo $queryStr; ?>'. <?php // iterate over result set // print details for each match while($r = $result->nextResult()) { ?> <p> <?php echo $r->swishreccount; ?> <strong> <a href="<?php echo '/pdf2', ltrim($r->swishdocpath, '.') ; ?>"> <?php echo $r->swishdocpath; ?> </a> </strong> (sco <?php echo $r->swishrank; ?>) <br/> <?php echo $r->swishdocpath; ?><br /> <?php $file = '/var/www/html/active_colist.csv'; $fh = fopen($file, 'r'); $companies = array(); $row = fgetcsv($fh, 1024); // ignore header while ($row = fgetcsv($fh, 1024)) { $companies[$row[0]] = array('company' => $row[1], 'country' => $row[3]); //changed line } fclose($fh); //Split a filename by . $filenames = explode(".", $r->swishdocpath); //get 3 chars from $filenames to $country $wvb_number = substr($filenames[1],1,12); $country = substr($filenames[1],1,3); echo 'Country: '.$companies[$wvb_number]['country']."<br />"; //echo 'Country Name: '.$country."<br />"; //$filenames[2] = explode(".", $r->swishdocpath); $year = substr($filenames[2],0,4); echo 'Year: '.$year."<br />"; //$filenames = explode(".", $r->swishdocpath); //$wvb_number = substr($filenames[1],1,12); echo 'WVB Number: '.$wvb_number."<br />"; echo 'Company Name: '.$companies[$wvb_number]['company']; //echo 'Country: '.$companies[$wvb_number]['country']; ?> </p> <?php } } catch (Exception $e) { die('ERROR: ' . $e->getMessage()); } } ?> </body> </html>My question is what would be the best way incorporate this into my php file so that I am able to display a limit number link by page so that not all of the results are listed on the same page? If that is even possible. I'm trying to search the 'ad' column where 'ad' = 1 or 3 I'm having problems doing this. Here is what I currently have, but it is not bringing back 'ad' where ='1' (for obvious reasons) Quote $query = "SELECT * FROM users WHERE ad='3' AND state='$state1'"; Here is what I thought would work, but it displays every listing in my database when I do it this way. Quote $query = "SELECT * FROM users WHERE ad='3' OR ad='1' AND state='$state1'"; Thank you in advance for your answers, google is not being so kind to me right now. |