
mbeals
Members-
Posts
247 -
Joined
-
Last visited
Never
Everything posted by mbeals
-
can you post more of your code.... specifically the echo lines where are attempting to highlight?
-
Basically. The page runs a mysql query and displays all the results in a table. It builds the table recursively, so every time it pulls the values to build the row, I just generate an alert box using the same values. The base page is in php. The only javascript here is to create the alert box, and the ajax code that is loading the dynamic data (the dynamic table is being loaded into a div by ajax). I need to be able to take all the info in a single row and format it so that I can copy it then paste it into a rich text editor without the formating being all screwed up. Here is an example of what I have working now http://bealsm82.googlepages.com/example.html The actual page builds the tables dynamically, and that example does not.
-
close but not quite. What I have is a table consisting of name, address, phone number, ect.... that is dynamically loaded by ajax. So I have something like: Name Address Phone John Foo Bar Which when copy/pasted into a normal text editor is messy and unformated. I just need to display that info in a multiline format like: John Foo Bar Where I can copy it to paste into another program. I'm trying to avoid loading a different page, so that if multiple work orders need to be made, there isn't a lot of shifting back and forth. Having the link open in a new window is another option, but I think that is messy when so little info is actually being presented. The alert box is perfect as it is simple to call and simple to dismiss...if I could only access the text in it. Actually, openeing a new browser window wouldn't be bad, as long as I could constrain the size and eliminate the menu and address bar, ect...and prevent it from opening in a tab.
-
First off, how are you searching now? The stripos() function is case insensitive. Ii searches a target string for a sub string and returns the position where the substring starts. You could easily do something like: $keyword = 'whatever'; for($i=0;$i<count($possible);$i++){ if(stripos($possible[$i],$keyword)) { echo "<a target=_self href=\"".$r['url']."\">".$r['title']."</a><br>...".substr($r['conts'], strpos($r['conts'], $_GET[s])-50, 100); } } or if you are searching a mysql database, use 'like', as it is case insensitive as well. so basically if stripos returns something (it returns false if the search fails), then echo the result To highlight the key word, add <style type="text/css"> <!-- #highlight { background-color: #00FF00; } --> </style> to the head of the results page and then dynamically encase the keyword with <span id='highlight'> </span> when you echo the result
-
I built a site to manage incoming tech support calls. The calls come in, are parsed into a database then dynamic tables are built via php to display the info. Anyway, to make entering work orders easier, I need to be able to reformat data into a plain text friendly format and display it (so it can be copied). The easiest thing for me to do is to create a dynamic link for each row of data that pops a javascript alert box with the formatted text. The issue I'm hitting is that it is impossible to highlight and copy text from an alert box. Is there a way to modify the box or to embed a text field in the box to allow this? Any ideas how to do this or something similar? I thought about floating css layers, but want to avoid that for the sake of simplicity and cross browser support.
-
so you just want to pull all the 'right' values for a particular 'group' ? "Select `$group` from table" That effectively returns an entire column worth of data in your structure. is that what you are getting at?
-
[SOLVED] sql query help. Selectivly using the Match function
mbeals replied to fou2enve's topic in MySQL Help
you mean like: Select * from `foo` where area = 'San Fransisco' AND (`aspect` like $input and `attraction` like $input2) The ( ) are optional, but if you decide to change that inner 'and' to an 'or', you will need them. Since sql has to search the database line by line to pull the subset of rows where area = San Fransisco, just query that row while you are there and see if you really need it. This way you search everything only once. If you absolutely need to search subsets, consider generating individual tables for each 'area' -
try using 'limit' If you have a field that mimics the order you wish (PID maybe?) you can do this simple query: SELECT * FROM table ORDER BY indexfield DESC LIMIT 1 obviously replacing table and indexfield with your values. If you are using 'natural order' which is not a good thing to be in the habit of with relational db's, then you might try something like this: $query ="Select `pid` from 'pyramid' "; $num = mysql_numrows(mysql_query($query)); $offset = $num-1; $end = 10000*10000 $query = "SELECT * FROM pyramid LIMIT $offset,$end"; $result = ......
-
I have two tables that I am using joins to compare. It works great for combining the two and giving me the common values, but I am also interested in what is not matching. Is there a query that I can run that will basically do a left join and only return the entries that did not match or am I going to have to pull the entire results field in and process it line by line with php, looking for empty values?
-
I have a website that is using ajax to dynamically load data from a database (formatted by a php script) into a set of div tags. So when you filter the data or refresh (with a refresh button) the table is updated but the whole page is not reloaded. Anyway, to make this page display a default table, I need to run the ajax script (which executes the php and replaces the contents of the div tag with the results) when the page loads. To take care of this I have the following: function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } addLoadEvent(loadlog()) all within script tags, of course. The loadlog function is the ajax function which works fine when you call it via a button or a link or whatever else. This code works fine in firefox, but will not run the loadlog() function when the page loads in IE7. Is there a trick to IE7 or something I need to add to get it to work?
-
I would, but I don't have control of the form being submitted. The emails are coming from a tech support call center. I've worked with them to standardize as much as I can, and I've built that regex accordingly, but there are a few fields that have to be hand typed. It also needs to be dynamic so when the list of possibilities changes in our system (which it will do on a weekly basis), it will pick up the changes from a central source.
-
I have an email parsing script based in php that rips apart standard formatted email and then writes the results to a database and to a splunk log. One of th issues I'm facing is that one of the fields has about 6 possible values, which users keep misspelling. This is screwing up my stats, as I have occurrences for a single instance spread out over several just because it's spelled wrong. So, before I start writing some crazy regex to match common letter combos, is there an easier way? Is there a way to use something like pspell with a custom wordlist...or better yet...values pulled from a database?
-
What exactly are you trying to output here? First off, you have <? ?> inside existing <? ?> tags. That isn't necessary. if you are trying to echo this? <a href="/weblog/weblogentry.php?=$title"> $title </br>($date)</a>" This construct inside your parent <? ?> tags would be: echo "<a href=\"/weblog/weblogentry.php?=".$title."\"> ".$title." </br>(".$date.")</a>"; notice that the string is broken up into literal strings (between " ") and variable strings ($title) with periods (.). Also notice that the double qoutes in the hyperlink are escaped with a \ to make php treat them as a text character. Also, for the hyperlink to work, you do need to define the variable name in the URL. weblogentry.php?=$title is malformed. weblogentry.php won't know what variable to assign $title and you will have no way of pulling it into weblogentry. If you are trying to pass $title to var title then the full line would be: echo "<a href=\"/weblog/weblogentry.php?title=".$title."\"> ".$title." </br>(".$date.")</a>";
-
I am writing code to strip out and write key data to a database from incoming e-mail. I am using the mailparse functions to handle the incoming mail. My code pulls in the e-mail fine, but the array returned by the mailparse_msg_get_structure() only has one row. The entire contents of the /var/mail/$user file is being put into one row instead of it being broken apart into individual messages. Here is the code I'm using: $filename = "/var/mail/helpdesk"; $mime = mailparse_msg_parse_file($filename); $struct = mailparse_msg_get_structure($mime); echo count($struct); echo "<table>\n"; foreach($struct as $st) { echo "<tr>\n"; echo "<td><a href=\"$PHP_SELF?showpart=$st\">$st</a></td>\n"; $section = mailparse_msg_get_part($mime, $st); $info = mailparse_msg_get_part_data($section); echo "\n"; echo "<td>" . $info["content-type"] . "</td>\n"; echo "<td>" . $info["content-disposition"] . "</td>\n"; echo "<td>" . $info["disposition-filename"] . "</td>\n"; echo "<td>" . $info["charset"] . "</td>\n"; echo "</tr>"; } echo "</table>"; This simply returns: 1 text/plain us-ascii If you extract the contents with mailparse_msg_get_part() and echo it, it just returns all the e-mails lumped together. What do I need to do to get mailparse to recognize the individual messages?
-
that ends up pulling in the entire remainder of the email I think I resolved it. I'm just using /Phone:(.*)/ It does capture the leading space when there is data, but that's not a big deal. thanks for the help
-
I'm sorry, I forgot to use the code tags and consequently a big piece of info was left out. The source file looks like this: Alt Phone:<br /> Name: Foo Bar<br /> Not like: Alt Phone: Name: Foo Bar So I'm attempting to pull out everything between the : and the <
-
I'm using the mailparse extensions, so it opens up the /var/mail/$user mail file then runs a regex search the exact code in question is: preg_match_all('/Phone:\s*(.*)/', $contents, $altphone); preg_match_all('/Name:\s+(.+)/', $contents, $names); I'd prefer not to pull it in line by line and to just let mailparse handle the input side of things.
-
okay....new unforseen issue. When one of the fields has no text, it looks like: Alt Phone:<br /> The regex I'm using us dropping down to the next line and grabbing that full string. So for this text block: Alt Phone:<br /> Name: Foo Bar<br /> The regex is returning: Name: Foo Bar
-
Thanks, that worked perfectly
-
I'm writing a script to strip out data from incoming e-mails that are of a standard format. If I have a line that reads: . Name: Foo Bar<br /> I need to extract just the "Foo Bar" part. I'm using this regex: [Name:\s.+\W], which keys off the "Name" and "<". It works fantastic, except it returns "Name: Foo Bar"..... I don't want the leading "Name: ". How do you structure it so that it searches for but does not return that opening tag? I also suspect it is returning the < character, but it's not showing up in any of the output (CLI or web).
-
Thank you very much. It took about 2 hours of tinkering but I got it up and running. AJAX is awesome
-
I am building a dynamic site for monitoring computer networks. I store the static info (gatewayIP, equipment info, service address, etc) in a mysql database. I also use SNMP to retrieve stats on the individual components of the networks. I have one php script to build a general info (html)table for a single network. The index page runs a looped include statement, so the main page will load as many instances of this table as there are rows in the main database. Anyway... I use SNMP to poll the devices on each network to identify problems. This generates a list of problem devices that is displayed on the index page with each network. I have simplified the polling process as much as I can, having it only do a full walk on a single field, sort out the problem devices, then get the MAC just for those specific ones. This polling process takes around 10 to 15 seconds per network to complete. This means that once I have 10 or so networks built, it will take forever to load the index page and will most likley cause timeout issues. Is there a fancy way to allow the snmp polling script to run in the background while the rest of the page loads, then once it is done, load the results into a CSS layer or some other object on the page? Is this outside of the abilites of php? Do I need to be looking at java? I thought about writing a perl script that would get the info and load it into the db on specific intervals (with cron), but the page really needs to be refreshed every time you view it. Any thoughts?