Category: guide per il web

Aggiungere record a una coda con jQuery

CODICE HTML

 
< !DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<title>jQuery Add to Queue</title>
</head>
<body>
<h1>jQuery Add to Queue</h1>
<form id="form" method="post" action="process.php">
  <label for="input">Add to queue:</label>
<input type="text" name="input" id="input"/>
<input type="submit" name="Submit" id="submit" value="Add!"/>
</form>
<h2>Queue: </h2>
<div id="queue"></div>
 
</body>
 

CODICE CSS

 
#queue {
	background-color: #CCCCCC;
	padding: 6px;
	border: 1px solid #000000;
}
#queue > div {
	background-color: #66CC66;
	border: 1px solid #FFFFFF;
	margin: 4px;
	padding: 4px;
	display: none;
}
 

CODICE JAVASCRIPT

 
$(document).ready(function

Motore di ricerca PHP/MySQL

 
< ?php
DEFINE ('DB_USER', 'myname'); // Insert your database username into the quotes.
DEFINE ('DB_PASSWORD', 'mypassword'); // Insert your database password into the quotes.
DEFINE ('DB_HOST', 'localhost'); // This will most likely stay the same.
DEFINE ('DB_NAME', 'news'); //Insert your actual database name in the quotes.
$dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error()); //@ is to o not show errors on the page
@mysql_select_db (DB_NAME) OR die('Could not select the database: 

[MySQL] Selezionare 5 righe random

//Seleziona 5 righe random dalla tabella "your_table_name"
SELECT * FROM 'your_table_name' ORDER BY RAND() LIMIT 5

Convertire gli smiles in immagini.

 
< ?php
function smilies($text, $url_address_to_images_folder) // with '/' at the end
{
$array = array(':-)' => 'smile001.gif', // happy
':)' => 'smile001.gif', // happy
':-D' => 'smile002.gif', // very happy
':D' => 'smile002.gif', // very happy
':-O' => 'smile008.gif', // surprised / o, no
':-P' => 'smile007.gif', // tongue sticking out
':P' => 'smile007.gif', // tongue sticking out
';-)' => 'smile009.gif', // wink
';)' => 'smile009.gif', // wink
':-(' => 'smile003.gif', // sad
':(' => 'smile003.gif', // sad
'8o|' => 'smile011.gif', // angry grin
':-@' => 'smile010.gif', // angry
'8-)'

Creare una funzione array_isearch

funzione BBCode

 
< ?php
function BBCode($text)
{
    /**
     * The following array has the structure Key => Value. The key is the item that will be typed e.g [b] the value will be the html equivilant.
     */
    $BBCode = array("&" => "&amp;", "< " => "&lt;", ">" => "&gt;", "[b]" => "<b>",
        "[/b]" => "</b>", "[i]" => "<i>", "[/i]" => "</i>", "[u]" => "<u>", "[/u]" =>
        "</u>", "[img]" => "<img src='", "[/img]" =/> "'>"); // Comment Above
    $parsedtext = str_replace(array_keys($BBCode), array_values($BBCode), $text); …

[PHP] Come utilizzare la funzione explode

Numeri random in PHP

Cufon, qualsiasi font sulle vostre pagine web!

Estrarre i numeri all’interno di una stringa!

 
function extract_numbers($string)
{
preg_match_all('/([\d]+)/', $string, $match);
 
return $match[0];
}
 
$string = 'Lorem ipsum dolor sit 45 40 amet, consectetuer adipiscing elit. 35 65675 Suspendisse sed nibh non diam consectetuer pharetra. Morbi ultricies 235 536pede et pede. 9432 3536 Nunc eu risus eget quam lacinia feugiat. In sapien sem, fringilla quis, 34 24 8762condimentum id, bibendum ut, nibh. Quisque 2367 784 elementum massa 350 235 vel nulla.';
 
$numbers_array = extract_numbers($string);
 
echo '<span>'; print_r($numbers_array); echo "</span>";
 

Output

 
Array
(

Convertire un indirizzo e-mail da una stringa in un link

 
< ?php
function convert_emails_to_clickable_links($text)
{
$regex = "([a-z0-9_\-\.]+)". # name
 
"@". # at
 
"([a-z0-9-]{1,64})". # domain
 
"\.". # period
 
"([a-z]{2,10})"; # domain extension 
 
$text = eregi_replace($regex, '<a href="mailto:\\1@\\2.\\3">\\1@\\2.\\3', $text);
 
return $text;
}
 
$text = 'You can contact me at: example-name@mysite.com. My alternative address is other-username@domain.com.';
 
echo convert_emails_to_clickable_links($text);
 
/*
You can contact me at: <a href="mailto:example-name@mysite.com">example-name@mysite.com</a>. My alternative address is <a href="mailto:other-username@domain.com">other-username@domain.com</a>.
?>
*/

Condividi





Booking online




Categorie