Skip to content

Tag: html

Can cookie values be set after html has loaded on a page?

I read that cookie values can be set after HTML content has been sent from a PHP script to the web server. However, when working with this, I have not been able to set the cookies as I had hoped. Can someone straighten out my discrepancy? Answer PHP can only set cookies while sending the headers of the page (…

Display special characters returned from mySQL in drop down select box

I am trying to display utf8 characters in a drop down box which is pulled from mySQL (utf8_general_ci) the characters are returning as diamonds with a ? in the middle on. I have tried htmlspecialchars and htmlentities. And it returns a blank string. Site also has the charset set to utf-8. Thank you very much.…

How to get id of submit type button, when button is pressed

I want to print out the id of the button I pressed. The id is set dynamically for each button in a table. This is my HTML code: And I want to print the id of the button here. Answer If you do not wish to use a hidden field, you could set your submit button like this: Then you

how to remember scroll position of page

I am submitting some data to my database then reloading the same page as the user was just on, I was wondering if there is a way to remember the scroll position the user was just on? Answer I realized that I had missed the important part of submitting, so, I decided to tweak the code to store the cookie

Get Year From Date string

I want to check whether the current year is greater than a date string(D-M-Y) here is my code $OldDate = “09-30-2011”; $OldYear = strtok($OldDate, ‘-‘); $NewYear = date(“Y”); if ($OldYear < $…