![](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
Canman2005
-
Posts
669 -
Joined
-
Last visited
Never
Posts posted by Canman2005
-
-
Hi all
I have the following code
if ($source = file_get_contents("http://help.websiteos.com/websiteos/example_of_a_simple_html_page.htm")) { $search = "<h1>Example of a simple HTML page</h1>"; $newText = substr($source,strpos($source, $search)+strlen($search), 100); echo $newText; } else { print "error"; }
This grabs the first 100 characters of the HTML code from an external source starting from the defined section of code.
Rather than grabbing the first 100 characters, is there a way to define an end tag? So it would grab everything from the start and end tags?
Does that make much sense?
Thanks very much
Dave
-
Hi all
I have a form where I post a number value, such as
$_POST['number'] = '230';
Is it possible to do a IF statement to say if the outputted number is in multiples of 5?
Thanks
-
Managed to sort it with
$maxmindata = mysql_query("SELECT MIN(id) AS idfirst, MAX(id) AS idlast FROM websitecontent"); $maxminrow = mysql_fetch_array($maxmindata); echo $maxminrow[idfirst]; echo "<br>"; echo $maxminrow[idlast];
Thanks guys
-
Well the rows returned are in ORDER of ID, so I just want to print the word "first row" and the word "last row" next to the relevant one.
Such as
if($row['id'] == $firstrowid) { print "first row"; }
Does that make sense?
-
Hi all
I have the following QUERY
$sql = "SELECT * FROM content ORDER BY id ASC"; $show = @mysql_query($sql,$connection) or die(mysql_error()); while ($row = mysql_fetch_array($show)) { print $row['id'].'<br>'; }
Is it possible to grab the ID of the first row in the table and the last row in the table?
Thanks
-
thanks dude
-
both of those seem to give me an error, any ideas?
thanks
-
Hi all
I want to do a
SELECT COUNT(*) as Num FROM log WHERE live = 99
But I only want to perform this on the last 8 rows in the database
Is that possible?
-
So is there no way of automating your suggestion Mikedean?
-
So it could look like
SET checked='0'
SET checked='1'
SET checked='0'
SET checked='0'
SET checked='0'
SET checked='0'
SET checked='0'
SET checked='0'
SET checked='0'
SET checked='1'
SET checked='1'
SET checked='0'
SET checked='0'
SET checked='0'
SET checked='0'
-
That works cool, but it always does
SET checked='1'
on the 5th row inserted.
I'm trying to get it to add it randomly to one of each block of 5 rows that are inserted.
So it might do
SET checked='1'
on the 2nd row inserted or it might do it on the 4th row
but im trying to keep to blocks of 5
-
No rows will be deleted or edited, just inserted
-
Hi all
Wondering if you can help;
I have a simple table called `mydata`, it has the following fields
`id`
`checked`
`date`
I have the following INSERT script
INSERT INTO `mydata` SET `checked`='1', `date`=date('Y-m-d')
What I want to do is for every 5 rows of data INSERTED into my table, 1 of those 5 rows INSERTED to have the field `checked` set to 1 and the other 4 rows set to 0.
A history of INSERTS might look like
INSERT INTO `mydata` SET `checked`='0', `date`=date('Y-m-d') INSERT INTO `mydata` SET `checked`='1', `date`=date('Y-m-d') INSERT INTO `mydata` SET `checked`='0', `date`=date('Y-m-d') INSERT INTO `mydata` SET `checked`='0', `date`=date('Y-m-d') INSERT INTO `mydata` SET `checked`='0', `date`=date('Y-m-d')
INSERT INTO `mydata` SET `checked`='0', `date`=date('Y-m-d') INSERT INTO `mydata` SET `checked`='0', `date`=date('Y-m-d') INSERT INTO `mydata` SET `checked`='0', `date`=date('Y-m-d') INSERT INTO `mydata` SET `checked`='1', `date`=date('Y-m-d') INSERT INTO `mydata` SET `checked`='0', `date`=date('Y-m-d')
INSERT INTO `mydata` SET `checked`='1', `date`=date('Y-m-d') INSERT INTO `mydata` SET `checked`='0', `date`=date('Y-m-d') INSERT INTO `mydata` SET `checked`='0', `date`=date('Y-m-d') INSERT INTO `mydata` SET `checked`='0', `date`=date('Y-m-d') INSERT INTO `mydata` SET `checked`='0', `date`=date('Y-m-d')
As you can see, the INSERTS are split into 5's, because I want 1 out of every 5 rows INSERTED to have its value of the field `checked` to be set to 1, the other 4 rows should have the value set to 0.
This should be a random thing, so it might set the `checked` value of the first row INSERTED to 1 or it might set the last row INSERTED to 1.
Does that make much sense?
Thanks
Dave
-
Hello
We're in need of a freelance coder, you must be able to work for the next week on a project.
We need someone who charges less than 50-60 euro a day and is fast at coding.
We pay on 30 days of the job being complete, so after the job is complete and you have invoiced us, we pay within 30 days of getting the invoice.
We will have lots more work for the person we find.
Email me please
mark.stuart@intelligentbean.com
Thanks
-
Hi all
I have a database field called `date` this stores a datestamp in the following format
YYYY-MM-DD
I have a PHP page which I run everyday, I want to print the word
"process"
If it has been 3 weeks since the value of the field `date`.
So for example, if my `date` value was 2009-02-01, and I loaded the page and it was 3 weeks since that date, it would print "process", if it was 6 weeks since that date it would print "process" and if it was 9 weeks since that date, it would print "process".
So as you can see, im trying to figure out 3 week blocks since the `date` value
Does that make sense? Can anyone help?
Thanks in advance
Ed
-
Thanks guys, worked a treat
-
Hi all
I have the following code
print date('Y-m-d',strtotime("+2 days"));
which works fine.
But if I use
print date($row['date'],strtotime("+4 days"));
It doesn't seem to work.
Would anyone know why?
Thanks
-
We're still looking for someone to do this
-
Can anyone help?
-
Let me try and give an example of what I want to do next
Say todays day was a Thursday and in the `orders` table we had a row which looked like
id startdate
2 2009-01-01
So as you can see, the `startdate` is set to '2009-01-01' which is a Thursday, then every Thursday it should return this row.
Now say the assocated rows returned from the `items` table are the following;
id orderid repeat
32 2 1
33 2 2
34 2 2
35 2 3
36 2 4
37 2 4
So on the '2009-01-01' it would return all of the above, but then a week later on the '2009-01-07' it would just return rows which have a repeat value of 1 (because value 1 means return every week)
Every 2 weeks since the `startdate` is would return rows with a `repeat` value of 1 and 2 (because 1 is every week and 2 is every 2 weeks)
Then a week later it would return rows with a `repeat` value of 1 and 3 (because 1 is every week and 3 is every 3 weeks)
Then a week later it would return rows with a repeat value of 1,2 and 4 (because 1 is every week, 2 is every 2 weeks and 4 is every 4 weeks)
so depending on what repeat value is stored, that is when that row should be returned.
Just to mention, on the 3rd week (or 6th week, or 9th week ....) from the `startdate`, it would return rows with a `repeat` value of 1,2 and 3 (simply because 1 is every week, 2 is every 2 weeks and 3 is every 3 weeks)
As mentioned before
1 = repeat every week
2 = repeat once every 2 weeks
3 = repeat once every 3 weeks
4 = repeat once every 4 week
I know this is a bit of a mess, but hopefully it makes some kind of sense.
Does anyone understand what I am trying to do?
-
We have a script we need writting tonight, please contact us via msn
markystuart@hotmail.com
-
Hi all
I have a code I need to write and wondering if anyone can help;
Basically I have 2 tables, ill explain what they both are;
--orders--
id (auto id number)
startdate (yyyy-mm-dd)
--items--
id (auto id number)
orderid (id number from `orders` table)
repeat (either set to 1,2,3 or 4)
In the `items` table I have several rows and they each have a number under the field `repeat`, the numbers mean the following;
1 = repeat every week
2 = repeat once every 2 weeks
3 = repeat once every 3 weeks
4 = repeat once every 4 week
So what I want to do is grab all rows from the `orders` table which have a start date equal to or later than todays date.
Lets say today was a Tuesday, it would only return rows that the `startdate` is also a Tuesday, so for example it would grab a row if it has a startdate of 2009-01-20 (which is a Tuesday) but would not grab a row which had a `startdate` of 2009-01-21 (which is a Wednesday).
Then what I need to do is look in the `items` table and grab all the rows with the linked `orderid`.
I want to add some more but didnt want to overflow this message with information.
Does what im trying to do make sense so far?
Thanks
Ed
-
Hi all
I have a whole chunk of PHP inserts, updates, selects etc that I need to repeat several times on the page at different places.
Is there a way to mark a block of PHP code and then repeat it?
Thanks
-
Hi all
I have a very simple QUERY which gets a list of products, the list is very long though, about 500 products.
I'm trying to convert it to a PDF file and have tried tons of free PDF converters, my porblem is that when I try and convert this products list I keep getting
Fatal error: Allowed memory size
What can I do to try and fix this and also what is a safe MB limit to use?
Grab chunk of HTML
in Regex Help
Posted
Thank you very much
What would be the best way to grab the following from the external HTML