Something I had been wondering ... does ob save HTML tags? I have a lengthy php/mysql script formatted into a <table> - at some point I need to output the HTML code for use in an XML feed.
Can this be done with something like echo htmlentities(ob_get_clean($str)) ?
Search found 19 matches
- Mon May 17, 2010 11:48 am
- Forum: PHP - Code
- Topic: php code
- Replies: 3
- Views: 388
- Mon May 17, 2010 8:51 am
- Forum: PHP - Code
- Topic: limit amount of text returned from database field
- Replies: 3
- Views: 180
Re: limit amount of text returned from database field
Something along the lines of: $desc = explode(' ', $description); $words = count($desc); if ($words > 250) { $snippet = array_slice($desc,0,250); echo $snippet; } else { echo $desc } That should work, but of course be sure to clean the text before explode(), otherwise it may not count properly.
- Mon May 17, 2010 8:23 am
- Forum: PHP - Code
- Topic: limit amount of text returned from database field
- Replies: 3
- Views: 180
Re: limit amount of text returned from database field
Use substr(): echo substr($description,0,250); Edit: Oops, I just noticed you meant 250 words ... substr counts characters. You'll probably need to do this by counting the number of words using explode(), setting up a conditional that checks whether there are more than 250 words, then grabbing the f...
- Thu Apr 29, 2010 10:24 am
- Forum: PHP - Code
- Topic: Problem while rotating an image in PHP
- Replies: 4
- Views: 164
Re: Problem while rotating an image in PHP
I think the problem is that when you rotate the image at an angle, the overall width and height becomes larger than that of the original image. It's likely that the php rotate function automatically scales the image to preserve the original image dimensions, and that's why your images are shrinking....
- Wed Mar 31, 2010 10:27 am
- Forum: PHP - Code
- Topic: php date() problems ... again
- Replies: 1
- Views: 51
Re: php date() problems ... again
Never mind ... figured it out.
For those wondering, because I included the day (date("d")) in the mktime string, php adds one month from today, which would be April 31 == May 1.
For those wondering, because I included the day (date("d")) in the mktime string, php adds one month from today, which would be April 31 == May 1.
- Wed Mar 31, 2010 9:19 am
- Forum: PHP - Code
- Topic: php date() problems ... again
- Replies: 1
- Views: 51
php date() problems ... again
What is going on here? This was just a quick fix to apply a date label to a document ... it worked fine until today, the last day of the month. I thought php takes the local machine's time zone, so I doubt it's that kind of error. Any explanations? $thismonth = date("m"); $f_thismonth = da...
- Fri Mar 19, 2010 10:40 am
- Forum: PHP - Code
- Topic: Display One Row to Dropdown List?
- Replies: 1
- Views: 300
Re: Display One Row to Dropdown List?
Not sure what you are trying to achieve here ... can you be more descriptive?
The while( ) loop will run through the entire database and repeat the code inside the { } ... and since you have two records in your database, it is generating two <option> lines.
The while( ) loop will run through the entire database and repeat the code inside the { } ... and since you have two records in your database, it is generating two <option> lines.
- Fri Mar 19, 2010 8:17 am
- Forum: PHP - Code
- Topic: Include problem... :(
- Replies: 10
- Views: 4632
Re: Include problem... :(
I saw in your source code that the include says <?php include("poll_wags.html"); ?>. Not sure if this is a mistake or you were trying something else.
I also got a nice malware notification for your IP.
I also got a nice malware notification for your IP.
- Fri Mar 19, 2010 8:05 am
- Forum: PHP - Code
- Topic: question re: comparing dates
- Replies: 8
- Views: 662
Re: question re: comparing dates
I took the first suggestion and converted the date fields to a readable format in another field. I don't know why I didn't think of doing that in the first place. 8O I'd love to redo this entire db, but ... eh just not worth it. Site owner doesn't really care and just wants something functional. Tha...
- Thu Mar 18, 2010 4:29 pm
- Forum: PHP - Code
- Topic: question re: comparing dates
- Replies: 8
- Views: 662
Re: question re: comparing dates
Thanks for the suggestion. As I mentioned, I did initially set up the query like this (for the purpose of creating an example page). The problem I ran into, however, is that the date for each record is entered and recorded as a varchar - i.e. 03 for March. While `month` <= month(now()) works for mos...
- Thu Mar 18, 2010 1:18 pm
- Forum: PHP - Code
- Topic: question re: comparing dates
- Replies: 8
- Views: 662
Re: question re: comparing dates
That's what my dateDiff function does, but I can only run that after I've selected data from the database (right?). What I need to do first is determine if there are any vacancies at the moment. If there are, the script will run the loop I've already written; if not, it will skip the table entirely....
- Thu Mar 18, 2010 8:59 am
- Forum: PHP - Code
- Topic: question re: comparing dates
- Replies: 8
- Views: 662
question re: comparing dates
This feels like an amateur question ... can't quite figure it out though ... appreciate any help from experienced folks out there. I'm working with an existing real estate database that currently stores "Date Available" in three fields (month / day / year) as varchars. I need to produce a ...
- Thu Mar 18, 2010 8:27 am
- Forum: PHP - Code
- Topic: A Question
- Replies: 8
- Views: 515
Re: A Question
In whatever script that updates or inserts your record, include an additional field that sets the current date using the now() function. $sql = "INSERT INTO table (field1, field2, ..., current_date) VALUES ('value1', 'value2', ..., 'now()')"; If you need to save the date/time in a particul...
- Wed Mar 17, 2010 10:22 am
- Forum: PHP - Code
- Topic: Editing,deleating,adding records to a database from PHP
- Replies: 3
- Views: 115
Re: Editing,deleating,adding records to a database from PHP
Google search for "php mysql" and you'll find a number of tutorials to get you started. I followed two of those tutorials and had an events web site up and running in a few hours.
- Fri Mar 05, 2010 3:21 pm
- Forum: PHP - Code
- Topic: count() by different groupings
- Replies: 6
- Views: 410
Re: count() by different groupings
It's supposed to be a table summarizing available units: number of studios, 1BR, 2BR, 3BR, 4BR, as well as Penthouses (which range from 2BR-4BR and are included in the other categories). In the database, each unit has a field listing the number of rooms and another designating penthouse Y/N. In the ...