332 Reusable Code Snippet Topics
Remove Filter ![]() | |
![]() | # As of 4/4/2013 # This class has now been updated and posted here: http://www.daniweb.com/web-development/php/code/451674/all-in-one-daniweb-api-class# # ORIGINAL POST # This code can be used to retrieve a forum list with various options with regard to display. This class could be extended for articles, posts, etc etc. The retrieval methods include … Web Development api daniweb-api json php ![]() |
## RSS Class ## The code snippet is a PHP class for retrieving RSS feeds from the DaniWeb website. There are two exposed methods, one for retrieving the list of predefined article types, and another to get a specific RSS feed. If you pass parameters to this method, there is … Web Development daniweb-api php xml | |
## API Mashup ## This example is a mashup of [diafol's class](http://www.daniweb.com/web-development/php/code/451428/daniweb-api-class-for-getting-forums), [Dani's parsing code](http://www.daniweb.com/api/documentation) and [my class](http://www.daniweb.com/web-development/php/code/451390/daniweb-api-rss-class). It uses diafol's dwAPI class to retrieve a list of all forums, loops through them, and uses my Rss class to get the respective RSS feeds. It will show each forum in … Web Development api daniweb-api php ![]() | |
Hello Community, I have been looking for a facebook news feed api, i couldn't find one. All i could find is bits of script for construct my own news feed api. So thats what i did and i thought i might share the script with you it's a bit messy … Web Development api display php social-media | |
Here is my first attempt at creating a simple slideshow. Contributions to making this more efficient are welcomed! #jsFiddle --> [Demo](http://jsfiddle.net/wGnEm/1/) Web Development javascript | |
#Web app state management# The current state of the user interface determines which application actions are enabled and thus which html elements are enabled for the user to invoke them. Classes are used in the html to indicate elements that need to be managed. Then jQuery is used to configure … Web Development javascript javascript-jquery user-interface ![]() | |
This snippet will allow you to easily work with session variables in your applications. This example is using a string type but it works the same for any data type, you would just need to change the default return value from string.Empty to something more appropriate. ![]() | |
The following snippet will show, how you can pass a data array to a function, and generate a table with N columns. `$data` contains some dummy data, which can come from any data source. Then you call `createHtmlTable` passing the data, the number of columns you want, and a function, … Web Development php ![]() | |
Hello Everyone, Please accept my simple and humble contribution. This script will validate if the user or visitor is a suspected spammer, by utilizing the stopforumspam API. Example implementation ## example usage. These items can be from database or from form input. The choice of implementation is all up to … ![]() | |
Here is a fully working PHP page viewer, set the variables $pages[] = "ANY URL HERE"; to suit your needs, and change the variable $max = 10; to however many views you want for each $page. -Echo Web Development php | |
This is one of the fastest ways to get data submitted by a HTML form, make it readable and send it by e-mail. Fast and easy. From the raw example to some basic functionality. Web Development php | |
I was struggling long for proper image resize function for maintaining image ratio. Finally i end end up with merging and changing all codes and it works ! function resizeImage($sourceFile,$destFile,$width,$height) sourceFile => Full path along with filename destinationFile => Full path along with filename I hope this will help coders.. ![]() | |
I got bored and started some scripting the other day in PHP, this is just a sample that i wrote, just uncomment the part of script that you would like to see. IE remove the /* and */ around a certain area. i know its not great, but some beginners … Web Development php ![]() | |
Below is a documented code example showing how to use the SQLite3 class to connect and query your database (and check for errors). IMHO using PDO is a better alternative, as this extension uses mixed technology in a non-standard way (objects, arrays and exceptions). If there are any questions let … | |
Below is a documented code example showing how to use the SQLite functions to connect and query your database (and check for errors). Please note that using the SQLite extension is NOT RECOMMENDED. This extension is no longer available in PHP 5.4.0. If you want your scripts to be future … | |
This demo will show a PHP script using a Smarty template. It assumes basic installation. In the folder where you copy the script, there should be a smarty folder containing the Smarty files. You should create a writable `cache` and `templates_c` folder, and a folder called `templates` where the `.tpl` … | |
A simple way for using templates in php new pages can run server side code or pretty much do anything you would normally want to do on a web page First create your template. cleary there is way more that can be done with this, I've kept it simple for … Web Development php | |
to create a new comboBox when you post your form checkbox_name will contain the selected value $(document).ready(function() { var cb = "checkbox_name"; comboBox(document.getElementById(cb+"CB"), cb); var sel = myForm.elements[cb+"_hold"]; sel.length = 0; //add options sel.options[sel.options.length] = new Option("text", "value"); }); <div id="checkbox_name"></div> Web Development javascript | |
Tablesorter (currently v2.0.5) includes an "update" method. This method keeps a Tablesorter object up to date with dynamic changes made to its table(s). Like other Tablesorter methods "update" is implemented in the form of a custom event. A typical method call would be $table.trigger("update"); , where $table is a jQuery … Web Development javascript javascript-jquery | |
Below is a documented code example showing how to use the [PDO](http://php.net/pdo) classes/objects to connect and query your database (and check for errors). If there are any questions, or you want to see different features, let me know. UPDATE: I've encountered a problem with PDO and bit fields (MySQL). If … Web Development php | |
Below is a documented code example showing how to use the [MySQLi](http://php.net/manual/en/book.mysqli.php) (MySQL improved) classes/objects to connect and query your database (and check for errors). If there are any questions, or you want to see different features, let me know. | |
Below is a documented code example showing how to use the [MySQL functions](http://php.net/manual/en/book.mysql.php) to connect and query your database (and check for errors). Please note that using the MySQL extension is **NOT RECOMMENDED**. This extension is no longer maintained and will be deprecated soon. If you want your scripts to … | |
# This is a simple HTML String Sanitizing tool. # ## It allows a highly rich,- but safe - html content input to be published on your pages. ## **The script code is very light and to some degree customizable.** * This function takes care of blacklisted tags, which are … Web Development html-css javascript | |
JavaScript doesn't actually have a sleep() function corresponding to what is available in other languages. We can easily implement one though. The following code uses afunc as an example function where we want to be able to have the code sleep for a number of milliseconds between sections of code. … Web Development javascript | |
| |
With this *Spartan*, we can destructively disable all the links on the page. (Or whatever link collection we feed the Fn.arg.) Web Development javascript seo ![]() | |
In addition to [my post in this thread](http://www.daniweb.com/web-development/php/threads/429740/php-best-practice#post1841569) I've decided to post an extended example, which also implements functions for inserts and updates. I hope the code is straightforward enough. If not, reply and let me know. The table structure I've used for my test is the following: CREATE TABLE … Web Development data-structure php | |
Hey everybody, Lately I have written the game Hangman in many different languages (C, JavaScript, Java and PHP so far). Here is the code snippet for JavaScript! It uses a words file, on the bottom of this post you will see a small example of a few words. The source … Web Development javascript politics puzzle | |
This is a very simple statistics script that provides for services on/offline, memory info, server load averages and uptime and lastly drive info. Its easily customised and i have usef <font> alot where you could have set come css and have it all done easily and look a bit more … Web Development php | |
//$time in the second php code hold the time stored in the database in the same format as above(ie TIMESTAMP Format) //Save the first php code as timeago.php //include first php code u saved in the second php code as i have done.. //Use the Second Php code Wherever You … Web Development php | |
If you ever go to [URL="http://www.hostip.info/"]http://www.hostip.info/[/URL], you will find a Community Geotarget IP Project. The great thing about it is that it is free to use. :) Now, this is just a snippet of code to begin working in the world of GeoIPs. There's a lot more info to be … | |
Hi! *Minimize HTTP requests*. One of the suggestion I always read is to combine files, so I made a little Class that merges files on the fly, the supported formats are CSS and Javascript. With little efforts, I think, it can work fine also with JSON and CSV. Usage is … Web Development html-css http-protocol javascript php | |
In these three functions, you can filter to a url to just the domain name. There are three main methods of doing so which are all shown in the example and the usage of each function is shown in the example. Web Development php ![]() | |
I have developed a contact us page and also PHP code that works perfect. Know the only problem is that after submitting the form it shows only "Message sent" on a new page. I want that after submitting the form page will redirect back to home page. It is only … | |
Hi! Im a noob to PHP but had to use it instead of ASP because I couldn't retrieve images from database using ASP + MS Access... Anyways.. I have couple questions: Number 1: How to retrieve and displaymultiple(!) images(jpg) from mysql DB? NUmber 2: I have a main page that … Web Development http-protocol php seo web-browser | |
Hello, Many guys have been asking for this sort of sms scripts! Any way i have created one for personal use but i am sharing here :) Things you need [LIST] [*]An Account in tm4b.com and PHP 5. [*]cURL or allow_url_fopen enabled in php.ini [/LIST] - [URL="http://jhbalaji.com"]Balaji J H[/URL] Web Development php | |
We know we already have built-in [I]Trim methods[/I], but trimming doesn't get rid of internal, (and unwanted) extra spaces. -So this is where Normalize method comes to play. It trims left, it trims right, but most importantly it also trims on the inside, one could say: "it trims inside-out". In … Web Development algorithm javascript | |
Simply enough: Call the function, get the returned filename. Function Variables: $file : The input file (source/background) $destination : Where you want the new watermarked image to go $overlay : The overlay image (foreground), this is default set (if not passed in) to "images/watermark.png" $X : X-Position of overlay (default … Web Development php | |
[I][COLOR="Green"]!below is the code snippet [/COLOR][/I] This is a multi-use property toggler. In the given example we are toggling a sub property of an element. e -is the property owner to be targeted; p - is the property name to be set; v - is the property value; henceforward changing … Web Development javascript | |
All the webpage data will be converted into PDF file, You can also add details such as ur name etc by using Chunk chunk1 = new Chunk("By Vishal RAne, [email]vishalrane50@example.com[/email] \n",FontFactory.GetFont("Verdana", 8)); The pdf will be saved on desktop.... u can change location by using PdfWriter.GetInstance(Doc, new FileStream(Environment.GetFolderPath (Environment.SpecialFolder.Desktop)+ "\\VishalRane.pdf", … | |
here is my code i want update the two fields without refreshing whole page.... Web Development asp.net | |
I hate websites that timeout and don't let you know about it this script pops up a message when you timeout and allows you to re-login in place Web Development javascript | |
Hi, This code checks the availability of username from the database. | |
It performs the toggle function to change the class of the paragraph tags and reverts back to the default class name when user rollout of it. You can embed the CSS style code inside the Head section of your page using HTML style tag. Code is as follows : Web Development html-css javascript | |
This is CURL Ready function , to use it just call do post if the page you are calling has post variables , or get if it has get variables :) Web Development php | |
To make some operations on XML elements you have to know their types. This snippet is about getting the types of these elements. | |
What this script does is take in an image and export a thumbnailed version. Function Arguments: $file : Desired image to create a thumbnail of $destination : End location for the thumbnail $zoom : Setting type, explained later (default: false) $t_width : Thumbnail width (default: 150) $t_height : Thumbnail height … Web Development php | |
Create the HTML we will be using. I will show the whole code and then break it down so you can see what each thing does. Let's start. Create a new html file called [B]index.html[/B]. HTML Code: [COLOR=#000080]<html>[/COLOR] [COLOR=#000080]<head>[/COLOR] [COLOR=#000080]<title>[/COLOR]AJAX Demo[COLOR=#000080]</title>[/COLOR] [COLOR=#800000]<script src='getnv.js'>[/COLOR][COLOR=#800000]</script>[/COLOR] [COLOR=#000080]</head>[/COLOR] [COLOR=#000080]<body>[/COLOR] [COLOR=#000080]<div id='menu'>[/COLOR] [COLOR=#000080]<ul>[/COLOR] [COLOR=#000080]<li>[/COLOR][COLOR=#008000]<a onClick='check_content("page.php?id=index")'>[/COLOR]Home[COLOR=#008000]</a>[/COLOR][COLOR=#000080]</li>[/COLOR] … Web Development php |
The End.