Everything posted by Mike101
-
Remove all strings after certain word in php
Well I'm looking into editing the data before it gets entered now anyway, either way something like trim, htmlentities, strip_tags will help there or some str_replace. But they are trusted sources. I'm still figuring it all out and its far from done.
-
Remove all strings after certain word in php
The parser is a seperate app that access to the web to ping defined sources added by myself to get the info for the db, and the site that access the db only has read functions.
-
Remove all strings after certain word in php
I thought it'd be easier to edit it by leaving all the tags intact (slightly bigger db but I could live with that), but I'll have a look at my parser script to see if it'd be better to edit from the other end before it even gets entered. Thanks for the input.
-
Remove all strings after certain word in php
It's automaticaly grabbed by a parser, but either way I'd still have the same problem, removing the stuff I dont want parsed/removing the stuff I dont want to output.
-
Remove all strings after certain word in php
It's things like links and adverts, so I need to remove the whole thing. eg in: <div style="background-color: #eee"> <p>Bla bla bla text1 bla bla bla</p> <div style="background-color: #"> <a href="http://www.test.com/test/test.html">Bla bla bla text2 bla bla bla</a> Bla bla bla text3 bla bla bla </div> </div> I'd need to remove this part: <div style="background-color: #"> <a href="http://www.test.com/test/test.html">Bla bla bla text2 bla bla bla</a> Bla bla bla text3 bla bla bla </div> Simply by using text2 or text3 as an anchor. Actually the data in the $row I'm pulling from mysql would be formated in maybe 50 different ways, BUT I could know beforehand because I have a column numbering where it cam from, so I could make a preg_replace function with if statements, eg if format_id 15 do this and so on.. But I can't even get my head around the example above and why my code wont work. Any other ideas? Or just stick with it?
-
Remove all strings after certain word in php
Hey, sorry your right I should have been more specific. I'm pulling rows from a MySql database using php with a lot of junk at the bottom which I need to remove, trouble is its all formated differently, but they do have things in common: 1. Its html 2. Junk is always at the bottom 3. Words or phrases exist in the part I want to remove that do not exist in the part I want to keep So I thought preg_replace would be the best solution for this but I'm having trouble getting my head around regular expressions (I'm getting there though, I know more that I did last week!), unless someone can think of a better idea?
-
Remove all strings after certain word in php
Can anyone tell me why on the following code: <div style="background-color: #eee"> <p>Bla bla bla text1 bla bla bla</p> <div style="background-color: #"> <a href="http://www.test.com/test/test.html">Bla bla bla text2 bla bla bla</a> Bla bla bla text3 bla bla bla </div> </div> "#<a.*text2.*/a>#i" Works to remove the link with empty code in preg_replace, but the following both do nothing. "#<div.*text3.*/div>#i" "#<div.*<a.*a>.*text3.*/div>#i" Tryed with differnet modifiers /s and /m. Just can't see what I'm doing wrong.
-
Remove all strings after certain word in php
Yea I've been reading stuff like that all week.
-
Remove all strings after certain word in php
Ok I've sort of got it working, but only to remove the string the keyword is on: $string = preg_replace("/<(a|div|b|p)[^>]*>(.*)(wordtosearchfor|orthisone)(.*)<\/(a|div|b|p)>/iU", '',$string);
-
Remove all strings after certain word in php
I need to remove all the code after a certain word or phrase shows up in a string, including the string it was found in, possibly within the tag itself or between tags AND it could show up in multiple different tags like <p> <b>... Would preg_replace be best for this? To find it and just replace everything after and including it with empty code "". eg.. Say the word shows up in a <a href..etc tag, or between <p> and </p>, I dont want any of that code or any other code after it to display. I'm terrible at regex so if anyone could help me here or point me in the right direction that would be great.
-
How to count clicks of links in a mysql row
It's was just a working version to test it. I've got a redirect incase someone enters the page directly, and amongst other things, I'm trimming the $_GET['id'] with: $id = trim(htmlentities(strip_tags($id)));
-
How to count clicks of links in a mysql row
I managed to fix the $id problem, just needed to add $_GET['id']; to get it from the header.. Thanks for your help.
-
How to count clicks of links in a mysql row
Yea ^ doesn't work because of the $id bit, I'll look into this; tonight when I get more time. Thanks.
-
How to count clicks of links in a mysql row
I think this may work. Can you see any problems with this? <?php // Connect to db mysql_connect("host", "user", "pass"); mysql_select_db("db_name"); // Add 1 to the click field for the link mysql_query("UPDATE table_name SET clicks = clicks + 1 WHERE ID = $id"); // And then get the link $data = mysql_query("SELECT * FROM link WHERE ID = $id"); $info = mysql_fetch_array($data); // Redirect to the link the user clicked header( "Location:" .$info['URL'] ); ?> The link will look something like this: <a href="http://www.mysite.com/out.php?id=1www.fake.com/fake">www.fake.com/fake</a> I was going to tackle the jquery click listener later.
-
How to count clicks of links in a mysql row
Thanks for your help, but I cant realy see how that article would help here.
-
How to count clicks of links in a mysql row
I think I should have been a bit clearer. My webpage will have a bunch of articles, title, brief decsription and a link to follow to read the rest of the article. When a user follows the link I also want 1 to be added to the clicks row. Its bacically for (internal) search ranking, ie rank by most recent (by date, not relevent to this) or number of clicks.
-
How to count clicks of links in a mysql row
I want to count the number of clicks on links stored in mysql. Say I have a table that looks like this: id| clicks| link 1 | 1| fake.com/fake 2 | 26| fake.com/morefake 3 | 9| fake.com/evenmorefake There will be more rows in the db but its irrelevant for now, also the info in the db will be updated regualy so using some sort of script that relies on adding the links to it manualy will not be suitable. I was thinking of some sort of function to increment the clicks row, somehow embedded in the $row['link'] call, would that work? What would be the best way of achieving this? Thanks.
-
Javascript zIndex help
Yea, I've just been looking at (this) which make things much easier and various things in the jscript api. I heard nth-child() was quite slow, but .eq() looks good. Getting sidetracked playing with the jquery api now haha. Thanks for your help.
-
Javascript zIndex help
I'm not sure that would work. In the end all the container divs will just be called 'container', they wont be numbered as ultimatly php is going to spew them out and fill them with data from mysql.. I think I'd still have the same id problem with nth-child, wouldnt it still effect the contents of all divs called container? Unless when php spews them out I get it to label the containers with i++ I'll put something together to test it.
-
Javascript zIndex help
Hi, I'm trying to change the layers of three different divs with onClick onMouseOver and OnMouseOut by changing the zIndexs. I need it to work like this: |-(onMouseOut)-> div1(top) div1(top)-(onMouseOver)-> div2(top)-|-(onClick)-> div3(top)-|-(onClick)-> div2(top) |-(onMouseOut)-> div1(top) Hope that makes sense.. Lets call the whole of that thing a layer box. I'm going to need a few of these on a page. I've got it working in the example below, but unfortutaly I'm new to javascript and the way I have the div id's setup is effecting other 'layer boxs' (in the code the layerbox on the left works with no problems untill a second layerbox is added, which effects the left because of the divs id's). Is there a better way to do this with some sort of javascript switch or toggle? <html> <head> <title>Div Layer Test</title> <script language="JavaScript"> function mover() { document.getElementById("div1").style.zIndex = '-3'; document.getElementById("div2").style.zIndex = '5'; } function mout() { document.getElementById("div1").style.zIndex = '5'; document.getElementById("div2").style.zIndex = '-1'; } function mclick() { document.getElementById("div3").style.zIndex = '5'; document.getElementById("div2").style.zIndex = '-1'; } function mclick2() { document.getElementById("div3").style.zIndex = '-2'; document.getElementById("div2").style.zIndex = '5'; } function mout2() { document.getElementById("div3").style.zIndex = '-2'; document.getElementById("div1").style.zIndex = '5'; } </script> <style type="text/css"> #container { position: absolute; left:0; height: 250px; width: 250px; } #container2 { position: absolute; left:260px; height: 250px; width: 250px; } #div1 { position: absolute; height: 50%; width: 100%; font-size: 100%; color: yellow; background-color: black; z-index: 5; } #white { position: absolute; height: 100%; width: 100%; background-color: white; z-index: 1; } #div2 { position: absolute; height: 50%; width: 100%; color: orange; background-color: black; z-index: -1; } #div3 { position: absolute; height: 100%; width: 100%; color: red; background-color: black; z-index: -2; } </style> </head> <body> <div id="container"> <div id="div1" onmouseover="mover()">div1</div> <div id="div2" onmouseout="mout()" onclick="mclick()">div2</div> <div id="div3" onmouseout="mout2()" onclick="mclick2()">div3</div> <div id="white"></div> </div> <div id="container2"> <div id="div1" onmouseover="mover()">div1</div> <div id="div2" onmouseout="mout()" onclick="mclick()">div2</div> <div id="div3" onmouseout="mout2()" onclick="mclick2()">div3</div> <div id="white"></div> </div> </body> </html>
-
Returing sphinx mysql results
Fixed, the problem was: SELECT * FROM items WHERE id = '$ids' Should have been: SELECT * FROM items WHERE id IN ($ids)
-
Returing sphinx mysql results
Hi, I've got Sphinx search installed and running properly in linux, but I'm having trouble with the mysql coding. The folowing php code is only returning the first result in the array: ----- $ids=implode(',', array_keys($res['matches'])); $result=mysql_query("SELECT * FROM items WHERE id = '$ids'"); while($row=mysql_fetch_array($result)) { echo $row['ItemTitle'] . "<br>"; echo $row['ItemDescription'] . "<br>"; } ----- $res is the array returned from sphinx with 'matches' being the list of ids I want to use. Does anyone have any experiance with sphinx/mysql that could help me out?