<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mas que Wordpress &#187; PHP</title>
	<atom:link href="http://www.masquewordpress.com/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.masquewordpress.com</link>
	<description>Tutoriales y recursos web sobre JQuery , PHP, Wordpress , twitter. Aprende diseño web y programación</description>
	<lastBuildDate>Sat, 19 May 2012 17:05:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Comprobar si una url existe con PHP</title>
		<link>http://www.masquewordpress.com/comprobar-si-una-url-existe-con-php/</link>
		<comments>http://www.masquewordpress.com/comprobar-si-una-url-existe-con-php/#comments</comments>
		<pubDate>Wed, 25 Apr 2012 14:35:07 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[get_headers]]></category>

		<guid isPermaLink="false">http://www.masquewordpress.com/?p=1217</guid>
		<description><![CDATA[Si por algún motivo necesitan saber si una URL existe, pueden hacerlo de una manera sencilla con PHP y Curl o mediante la función de get_headers(). Para ello tan solo deben hacer lo siguiente: Mediante curl $url = 'http://masquewordpress.com/portfolio/color-management'; function url_exists&#40;$url&#41; &#123; $ch = @curl_init&#40;$url&#41;; @curl_setopt&#40;$ch, CURLOPT_HEADER, TRUE&#41;; @curl_setopt&#40;$ch, CURLOPT_NOBODY, TRUE&#41;; @curl_setopt&#40;$ch, CURLOPT_FOLLOWLOCATION, FALSE&#41;; @curl_setopt&#40;$ch, [...]]]></description>
			<content:encoded><![CDATA[<p>Si por algún motivo necesitan saber si una URL existe, pueden hacerlo de una manera sencilla con <code>PHP y Curl</code> o mediante la función de <code>get_headers()</code>. Para ello tan solo deben hacer lo siguiente:<br />
<span id="more-1217"></span></p>
<h3>Mediante curl</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://masquewordpress.com/portfolio/color-management'</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">function</span> url_exists<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	    <span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #339933;">@</span><span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_HEADER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #339933;">@</span><span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_NOBODY<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #339933;">@</span><span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_FOLLOWLOCATION<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #339933;">@</span><span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #000088;">$status</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/HTTP\/.* ([0-9]+) .*/'</span><span style="color: #339933;">,</span> <span style="color: #339933;">@</span><span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">,</span> <span style="color: #000088;">$status</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">200</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> url_exists<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span>? <span style="color: #0000ff;">'existe'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'no existe'</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Mediante get_headers()</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://masquewordpress.com/portfolio/color-management'</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> url_exists<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$h</span> <span style="color: #339933;">=</span> <span style="color: #990000;">get_headers</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$status</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/HTTP\/.* ([0-9]+) .*/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$h</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">,</span> <span style="color: #000088;">$status</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">200</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> url_exists<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span>? <span style="color: #0000ff;">'existe'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'no existe'</span><span style="color: #339933;">;</span></pre></div></div>

<p>Espero que les haya servido de ayuda!</p>
<p><div style="float:left; text-align:left;><img alt='' src='http://1.gravatar.com/avatar/516ffa1373c8295d2e5ff5267fc53399?s=100&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D100&amp;r=G' class='avatar avatar-100 photo' height='100' width='100' /></div><h3><a href='http://www.masquewordpress.com/author/Damian/' title='Damian'>Damian</a></h3><p>Programador en tiempos libres , amante de la tecnología, blogger amateur y emprendedor en sueños.</p><p><a href='http://www.masquewordpress.com/author/Damian/' title='M&aacute;s post de Damian'>M&aacute;s Posts de Damian</a>  - <a href='http://www.timersys.com' title='Damian'>Web</a> </p><p class="wpa-nomargin">Sigueme:<br /><a class='wpa-social-icons' href='http://www.twitter.com/chifliiiii'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/twitter.png' alt='Twitter'/></a><a class='wpa-social-icons' href='http://www.facebook.com/pages/Timersys/146687622031640'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/facebook.png' alt='Facebook'/></a><a class='wpa-social-icons' href='http://ar.linkedin.com/pub/damian-logghe/26/173/321'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/linkedin.png' alt='LinkedIn'/></a></p></p>]]></content:encoded>
			<wfw:commentRss>http://www.masquewordpress.com/comprobar-si-una-url-existe-con-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Paginación PHP con clase</title>
		<link>http://www.masquewordpress.com/paginacion-php-con-clase/</link>
		<comments>http://www.masquewordpress.com/paginacion-php-con-clase/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 18:48:23 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[paginacion]]></category>

		<guid isPermaLink="false">http://www.masquewordpress.com/?p=1177</guid>
		<description><![CDATA[Últimamente ando revisando mis posts antiguos y en esta ocasión quería mostrarles una clase de paginación echa en PHP que es más fácil y prolija de usar que el  que publique hace tiempo. Creo que esta forma es la adecuada y aunque no entiendan o manejen clases de PHP , es un buen momento para [...]]]></description>
			<content:encoded><![CDATA[<p>Últimamente ando revisando mis posts antiguos y en esta ocasión quería mostrarles una <a href="http://www.catchmyfame.com/2011/10/23/php-pagination-class-updated-version-2/">clase de paginación echa en PHP</a> que es más fácil y prolija de usar que el <a href="http://www.masquewordpress.com/paginacion-con-php-y-mysql-3-estilos/">código de Paginación PHP</a> que publique hace tiempo. Creo que esta forma es la adecuada y aunque no entiendan o manejen clases de PHP , es un buen momento para salpicarse un poco en este mundillo.<br />
<span id="more-1177"></span><br />
Para empezar les quiero mostrar 2 ejemplos de esta clase:</p>
<ol>
<li><a href="http://www.catchmyfame.com/paginator/example.2.php?page=5&#038;ipp=25">Ejemplo básico</a></li>
<li><a href="http://www.catchmyfame.com/paginator/example-form.2.php?page=3&#038;ipp=25&#038;tb1=Europe">Ejemplo donde se arrastran variables en cada página</a></li>
</ol>
<h2>Métodos de la clase</h2>
<ul>
<li>Paginator. Constructor. Como usar:

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$pages</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Paginator<span style="color: #339933;">;</span></pre></div></div>

</li>
<li>paginate. Calcula las páginas a mostrar. Como usar:

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$pages</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">paginate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>display_items_per_page. Devuelve una cadena HTML para mostrar items por página. Como usar:

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span>  <span style="color: #000088;">$pages</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">display_items_per_page</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>display_jump_menu. Devuelve una cadena HTML para mostrar el salto de página. Como usar:

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #000088;">$pages</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">display_jump_menu</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>display_pages. Devuelve la cadena HTML que muestra lás paginas. Como usar:

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #000088;">$pages</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">display_pages</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
</ul>
<h2>Ahora veamos como usar realmente la clase</h2>
<ol>
<li>Incluimos la clase:

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'paginator.class.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>Creamos el objeto paginator:

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$pages</span><span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Paginator<span style="color: #339933;">;</span></pre></div></div>

</li>
<li>Configuramos el total de resultados de nuestra query. Para ello podemos usar una COUNT(*) que devuelva la cantidad total de resutados:

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$pages</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">items_total</span> <span style="color: #339933;">=</span> X<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// cambiamos X por el total</span></pre></div></div>

</li>
<li>Configuramos el total de links a mostrar. Por ejemplo el valor por defecto es 7 . Si estamos en la pág 50 mostraria : 47 47 49 50 51 52 53

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$pages</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mid_range</span> <span style="color: #339933;">=</span> X<span style="color: #339933;">;</span></pre></div></div>

</li>
<li>Llamamos al método paginate para que cree la paginación (este método no devuelve nada)

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$pages</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">paginate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>Imprimimos las páginas que hemos páginado en el paso anterior:

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #000088;">$pages</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">display_pages</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>Opcionalmente se pueden usar los métodos de display_jump_menu o display_items_per_page</li>
<li>Como ya tenemos la paginación generada ya podemos usar <strong>$pages->limit</strong> en nuestra query para limitar los resultados. Por ej:

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">SELECT id<span style="color: #339933;">,</span> name<span style="color: #339933;">,</span> address FROM table ORDER BY id ASC <span style="color: #000088;">$pages</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">limit</span></pre></div></div>

</li>
</ol>
<p>Con estos pasos ya tendremos funcionando la clase PHP para paginar resultados.</p>
<p>Para darle estilo pueden aplicar el que el desarrollador usa por defecto o pueden probar a adaptar algún otro estilo como los descriptos en <a href="http://www.masquewordpress.com/paginacion-con-php-y-mysql-3-estilos/">este otro post</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">&lt;style type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span><span style="color: #00AA00;">&gt;</span>
<span style="color: #6666ff;">.paginate</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Arial<span style="color: #00AA00;">,</span> Helvetica<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">.7em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
a<span style="color: #6666ff;">.paginate</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#000080</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #933;">6px</span> <span style="color: #933;">2px</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000080</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
a<span style="color: #6666ff;">.paginate</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000080</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#FFF</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
a<span style="color: #6666ff;">.current</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#000080</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span> <span style="color: #933;">.7em</span> Arial<span style="color: #00AA00;">,</span>Helvetica<span style="color: #00AA00;">,</span><span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #933;">6px</span> <span style="color: #933;">2px</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">default</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000080</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#FFF</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
span<span style="color: #6666ff;">.inactive</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#999</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Arial<span style="color: #00AA00;">,</span> Helvetica<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">.7em</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #933;">6px</span> <span style="color: #933;">2px</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#999</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">default</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&lt;/style<span style="color: #00AA00;">&gt;</span></pre></div></div>

<p>Y por último aquí tienen la clase PHP encargada de todo:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/*
 * PHP Pagination Class
 * @author admin@catchmyfame.com - http://www.catchmyfame.com
 * @version 2.0.0
 * @date October 18, 2011
 * @copyright (c) admin@catchmyfame.com (www.catchmyfame.com)
 * @license CC Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) - http://creativecommons.org/licenses/by-sa/3.0/
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> Paginator<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$items_per_page</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$items_total</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$current_page</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$num_pages</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$mid_range</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$low</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$limit</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$return</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$default_ipp</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$querystring</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$ipp_array</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> Paginator<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">current_page</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mid_range</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">7</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ipp_array</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">25</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">50</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">100</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'All'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">items_per_page</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ipp'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ipp'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">:</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_ipp</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> paginate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_ipp</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_ipp</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">25</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ipp'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'All'</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">num_pages</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//			$this-&gt;items_per_page = $this-&gt;default_ipp;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">items_per_page</span><span style="color: #009900;">&#41;</span> OR <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">items_per_page</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">items_per_page</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_ipp</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">num_pages</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ceil</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">items_total</span><span style="color: #339933;">/</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">items_per_page</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">current_page</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'page'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'page'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// must be numeric &gt; 0</span>
		<span style="color: #000088;">$prev_page</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">current_page</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$next_page</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">current_page</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'QUERY_STRING'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$arg</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$keyval</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;=&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$arg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$keyval</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;page&quot;</span> And <span style="color: #000088;">$keyval</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;ipp&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">querystring</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&amp;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$arg</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;page&quot;</span> And <span style="color: #000088;">$key</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;ipp&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">querystring</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&amp;<span style="color: #006699; font-weight: bold;">$key</span>=<span style="color: #006699; font-weight: bold;">$val</span>&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">num_pages</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">return</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">current_page</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span> And <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">items_total</span> <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot;&lt;a class=<span style="color: #000099; font-weight: bold;">\&quot;</span>paginate<span style="color: #000099; font-weight: bold;">\&quot;</span> href=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$_SERVER[PHP_SELF]</span>?page=<span style="color: #006699; font-weight: bold;">$prev_page</span>&amp;ipp=<span style="color: #006699; font-weight: bold;">$this-&gt;items_per_page</span><span style="color: #006699; font-weight: bold;">$this-&gt;querystring</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&amp;laquo; Previous&lt;/a&gt; &quot;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">&quot;&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>inactive<span style="color: #000099; font-weight: bold;">\&quot;</span> href=<span style="color: #000099; font-weight: bold;">\&quot;</span>#<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&amp;laquo; Previous&lt;/span&gt; &quot;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">start_range</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">current_page</span> <span style="color: #339933;">-</span> <span style="color: #990000;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mid_range</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">end_range</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">current_page</span> <span style="color: #339933;">+</span> <span style="color: #990000;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mid_range</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">start_range</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">end_range</span> <span style="color: #339933;">+=</span> <span style="color: #990000;">abs</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">start_range</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">start_range</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">end_range</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">num_pages</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">start_range</span> <span style="color: #339933;">-=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">end_range</span><span style="color: #339933;">-</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">num_pages</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">end_range</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">num_pages</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">range</span> <span style="color: #339933;">=</span> <span style="color: #990000;">range</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">start_range</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">end_range</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;=</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">num_pages</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">range</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">2</span> And <span style="color: #000088;">$i</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">range</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">return</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; ... &quot;</span><span style="color: #339933;">;</span>
				<span style="color: #666666; font-style: italic;">// loop through all pages. if first, last, or in range, display</span>
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">1</span> Or <span style="color: #000088;">$i</span><span style="color: #339933;">==</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">num_pages</span> Or <span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">range</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">return</span> <span style="color: #339933;">.=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">current_page</span> And <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'page'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'All'</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot;&lt;a title=<span style="color: #000099; font-weight: bold;">\&quot;</span>Go to page <span style="color: #006699; font-weight: bold;">$i</span> of <span style="color: #006699; font-weight: bold;">$this-&gt;num_pages</span><span style="color: #000099; font-weight: bold;">\&quot;</span> class=<span style="color: #000099; font-weight: bold;">\&quot;</span>current<span style="color: #000099; font-weight: bold;">\&quot;</span> href=<span style="color: #000099; font-weight: bold;">\&quot;</span>#<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;<span style="color: #006699; font-weight: bold;">$i</span>&lt;/a&gt; &quot;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">&quot;&lt;a class=<span style="color: #000099; font-weight: bold;">\&quot;</span>paginate<span style="color: #000099; font-weight: bold;">\&quot;</span> title=<span style="color: #000099; font-weight: bold;">\&quot;</span>Go to page <span style="color: #006699; font-weight: bold;">$i</span> of <span style="color: #006699; font-weight: bold;">$this-&gt;num_pages</span><span style="color: #000099; font-weight: bold;">\&quot;</span> href=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$_SERVER[PHP_SELF]</span>?page=<span style="color: #006699; font-weight: bold;">$i</span>&amp;ipp=<span style="color: #006699; font-weight: bold;">$this-&gt;items_per_page</span><span style="color: #006699; font-weight: bold;">$this-&gt;querystring</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;<span style="color: #006699; font-weight: bold;">$i</span>&lt;/a&gt; &quot;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">range</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mid_range</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">num_pages</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> And <span style="color: #000088;">$i</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">range</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mid_range</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">return</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; ... &quot;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">return</span> <span style="color: #339933;">.=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">current_page</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">num_pages</span> And <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">items_total</span> <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span> And <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'page'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'All'</span><span style="color: #009900;">&#41;</span> And <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">current_page</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot;&lt;a class=<span style="color: #000099; font-weight: bold;">\&quot;</span>paginate<span style="color: #000099; font-weight: bold;">\&quot;</span> href=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$_SERVER[PHP_SELF]</span>?page=<span style="color: #006699; font-weight: bold;">$next_page</span>&amp;ipp=<span style="color: #006699; font-weight: bold;">$this-&gt;items_per_page</span><span style="color: #006699; font-weight: bold;">$this-&gt;querystring</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;Next &amp;raquo;&lt;/a&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">&quot;&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>inactive<span style="color: #000099; font-weight: bold;">\&quot;</span> href=<span style="color: #000099; font-weight: bold;">\&quot;</span>#<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&amp;raquo; Next&lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">return</span> <span style="color: #339933;">.=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'page'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'All'</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot;&lt;a class=<span style="color: #000099; font-weight: bold;">\&quot;</span>current<span style="color: #000099; font-weight: bold;">\&quot;</span> style=<span style="color: #000099; font-weight: bold;">\&quot;</span>margin-left:10px<span style="color: #000099; font-weight: bold;">\&quot;</span> href=<span style="color: #000099; font-weight: bold;">\&quot;</span>#<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;All&lt;/a&gt; <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">&quot;&lt;a class=<span style="color: #000099; font-weight: bold;">\&quot;</span>paginate<span style="color: #000099; font-weight: bold;">\&quot;</span> style=<span style="color: #000099; font-weight: bold;">\&quot;</span>margin-left:10px<span style="color: #000099; font-weight: bold;">\&quot;</span> href=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$_SERVER[PHP_SELF]</span>?page=1&amp;ipp=All<span style="color: #006699; font-weight: bold;">$this-&gt;querystring</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;All&lt;/a&gt; <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;=</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">num_pages</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">return</span> <span style="color: #339933;">.=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">current_page</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot;&lt;a class=<span style="color: #000099; font-weight: bold;">\&quot;</span>current<span style="color: #000099; font-weight: bold;">\&quot;</span> href=<span style="color: #000099; font-weight: bold;">\&quot;</span>#<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;<span style="color: #006699; font-weight: bold;">$i</span>&lt;/a&gt; &quot;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">&quot;&lt;a class=<span style="color: #000099; font-weight: bold;">\&quot;</span>paginate<span style="color: #000099; font-weight: bold;">\&quot;</span> href=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$_SERVER[PHP_SELF]</span>?page=<span style="color: #006699; font-weight: bold;">$i</span>&amp;ipp=<span style="color: #006699; font-weight: bold;">$this-&gt;items_per_page</span><span style="color: #006699; font-weight: bold;">$this-&gt;querystring</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;<span style="color: #006699; font-weight: bold;">$i</span>&lt;/a&gt; &quot;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">return</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;a class=<span style="color: #000099; font-weight: bold;">\&quot;</span>paginate<span style="color: #000099; font-weight: bold;">\&quot;</span> href=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$_SERVER[PHP_SELF]</span>?page=1&amp;ipp=All<span style="color: #006699; font-weight: bold;">$this-&gt;querystring</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;All&lt;/a&gt; <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">low</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">current_page</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> ? <span style="color: #cc66cc;">0</span><span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">current_page</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">items_per_page</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">current_page</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">items_per_page</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">limit</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ipp'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'All'</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">&quot; LIMIT <span style="color: #006699; font-weight: bold;">$this-&gt;low</span>,<span style="color: #006699; font-weight: bold;">$this-&gt;items_per_page</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">function</span> display_items_per_page<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$items</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span>ipp<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">items_per_page</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_ipp</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ipp_array</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$ipp_opt</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$items</span> <span style="color: #339933;">.=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ipp_opt</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">items_per_page</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot;&lt;option selected value=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$ipp_opt</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;<span style="color: #006699; font-weight: bold;">$ipp_opt</span>&lt;/option&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">&quot;&lt;option value=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$ipp_opt</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;<span style="color: #006699; font-weight: bold;">$ipp_opt</span>&lt;/option&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>paginate<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;Items per page:&lt;/span&gt;&lt;select class=<span style="color: #000099; font-weight: bold;">\&quot;</span>paginate<span style="color: #000099; font-weight: bold;">\&quot;</span> onchange=<span style="color: #000099; font-weight: bold;">\&quot;</span>window.location='<span style="color: #006699; font-weight: bold;">$_SERVER[PHP_SELF]</span>?page=1&amp;ipp='+this[this.selectedIndex].value+'<span style="color: #006699; font-weight: bold;">$this-&gt;querystring</span>';return false<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;<span style="color: #006699; font-weight: bold;">$items</span>&lt;/select&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">function</span> display_jump_menu<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;=</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">num_pages</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$option</span> <span style="color: #339933;">.=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">==</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">current_page</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot;&lt;option value=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$i</span><span style="color: #000099; font-weight: bold;">\&quot;</span> selected&gt;<span style="color: #006699; font-weight: bold;">$i</span>&lt;/option&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">&quot;&lt;option value=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$i</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;<span style="color: #006699; font-weight: bold;">$i</span>&lt;/option&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>paginate<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;Page:&lt;/span&gt;&lt;select class=<span style="color: #000099; font-weight: bold;">\&quot;</span>paginate<span style="color: #000099; font-weight: bold;">\&quot;</span> onchange=<span style="color: #000099; font-weight: bold;">\&quot;</span>window.location='<span style="color: #006699; font-weight: bold;">$_SERVER[PHP_SELF]</span>?page='+this[this.selectedIndex].value+'&amp;ipp=<span style="color: #006699; font-weight: bold;">$this-&gt;items_per_page</span><span style="color: #006699; font-weight: bold;">$this-&gt;querystring</span>';return false<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;<span style="color: #006699; font-weight: bold;">$option</span>&lt;/select&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">function</span> display_pages<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">return</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Pueden ver más información en el post del autor: <a href="http://www.catchmyfame.com/2007/07/28/finally-the-simple-pagination-class/">http://www.catchmyfame.com/2007/07/28/finally-the-simple-pagination-class/</a></p>
<p>Saludos!!!</p>
<p><div style="float:left; text-align:left;><img alt='' src='http://1.gravatar.com/avatar/516ffa1373c8295d2e5ff5267fc53399?s=100&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D100&amp;r=G' class='avatar avatar-100 photo' height='100' width='100' /></div><h3><a href='http://www.masquewordpress.com/author/Damian/' title='Damian'>Damian</a></h3><p>Programador en tiempos libres , amante de la tecnología, blogger amateur y emprendedor en sueños.</p><p><a href='http://www.masquewordpress.com/author/Damian/' title='M&aacute;s post de Damian'>M&aacute;s Posts de Damian</a>  - <a href='http://www.timersys.com' title='Damian'>Web</a> </p><p class="wpa-nomargin">Sigueme:<br /><a class='wpa-social-icons' href='http://www.twitter.com/chifliiiii'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/twitter.png' alt='Twitter'/></a><a class='wpa-social-icons' href='http://www.facebook.com/pages/Timersys/146687622031640'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/facebook.png' alt='Facebook'/></a><a class='wpa-social-icons' href='http://ar.linkedin.com/pub/damian-logghe/26/173/321'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/linkedin.png' alt='LinkedIn'/></a></p></p>]]></content:encoded>
			<wfw:commentRss>http://www.masquewordpress.com/paginacion-php-con-clase/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Detectar pais, provincia y ciudad de procedencia mediante la IP</title>
		<link>http://www.masquewordpress.com/detectar-pais-provincia-y-ciudad-mediante-ip/</link>
		<comments>http://www.masquewordpress.com/detectar-pais-provincia-y-ciudad-mediante-ip/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 19:08:01 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Recursos]]></category>
		<category><![CDATA[Tips de wordpress]]></category>
		<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[geolocation]]></category>
		<category><![CDATA[iplocation]]></category>

		<guid isPermaLink="false">http://www.masquewordpress.com/?p=1154</guid>
		<description><![CDATA[El tip de wordpress de hoy es para poder detectar y mostrar la ubicación de sus visitantes mediante la dirección IP de los mismos. Aunque este tip puede usarse para cualquier otro proyecto, hoy les voy a enseñar como integrarlo en wordpress. Si todo es correcto, tu mi querido usuario deber estar ubicado en: Para [...]]]></description>
			<content:encoded><![CDATA[<p>El tip de wordpress de hoy es para poder detectar y mostrar la ubicación de sus visitantes mediante la dirección IP de los mismos. Aunque este tip puede usarse para cualquier otro proyecto, hoy les voy a enseñar como integrarlo en wordpress.</p>
<p>Si todo es correcto, tu mi querido usuario deber estar ubicado en: -, -</p>
<p><span id="more-1154"></span></p>
<p>Para ello vamos primero a crear un shortcode llamado &#8220;iplocation&#8221; que usaremos para mostrar los datos. Para ello en nuestro functions.php copiamos la siguiente función:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> mqw_iplocation<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$atts</span> <span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> mqw_iplocation_func<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'iplocation'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mqw_iplocation'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Por último la función que devuelve la ubicación mediante IP. Esta función la saque de http://snipplr.com/view/48386/detect-location-by-ip-city-state/ que usa un servicio gratuito llamado http://ipinfodb.com/ aunque existen de pago y mejores (más exactitud de los datos y mayor actualización de las IP).</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> mqw_iplocation_func<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000088;">$default</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Mar del Plata, Bs As, Argentina'</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$ip</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'127.0.0.1'</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$ip</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'localhost'</span><span style="color: #009900;">&#41;</span>
            <span style="color: #000088;">$ip</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'8.8.8.8'</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$curlopt_useragent</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)'</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://ipinfodb.com/ip_locator.php?ip='</span> <span style="color: #339933;">.</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$curl_opt</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            CURLOPT_FOLLOWLOCATION  <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
            CURLOPT_HEADER      <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
            CURLOPT_RETURNTRANSFER  <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
            CURLOPT_USERAGENT   <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$curlopt_useragent</span><span style="color: #339933;">,</span>
            CURLOPT_URL       <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$url</span><span style="color: #339933;">,</span>
            CURLOPT_TIMEOUT         <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
            CURLOPT_REFERER         <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_HOST'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #990000;">curl_setopt_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> <span style="color: #000088;">$curl_opt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_null</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_info</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$curl_info</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_getinfo</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'{&lt;li&gt;City : ([^&lt;]*)&lt;/li&gt;}i'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$regs</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$city</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$regs</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'{&lt;li&gt;State/Province : ([^&lt;]*)&lt;/li&gt;}i'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$regs</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$state</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$regs</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'{&lt;li&gt;Country : ([^&lt;]*)&lt;/li&gt;}i'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$regs</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$country</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$regs</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$city</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">''</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$state</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">''</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$country</span> <span style="color: #339933;">!=</span><span style="color: #0000ff;">''</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
          <span style="color: #000088;">$location</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$city</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">', '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$state</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">', '</span><span style="color: #339933;">.</span> <span style="color: #000088;">$country</span><span style="color: #339933;">;</span>
          <span style="color: #b1b100;">return</span> <span style="color: #000088;">$location</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
          <span style="color: #b1b100;">return</span> <span style="color: #000088;">$default</span><span style="color: #339933;">;</span> 
        <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Espero que les haya gustado. Saludos!!</p>
<p>Ahh me olvidaba, tan solo tienen que usar el shortcode de la siguiente manera:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009900;">&#91;</span>iplocation<span style="color: #009900;">&#93;</span></pre></div></div>

<p><div style="float:left; text-align:left;><img alt='' src='http://1.gravatar.com/avatar/516ffa1373c8295d2e5ff5267fc53399?s=100&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D100&amp;r=G' class='avatar avatar-100 photo' height='100' width='100' /></div><h3><a href='http://www.masquewordpress.com/author/Damian/' title='Damian'>Damian</a></h3><p>Programador en tiempos libres , amante de la tecnología, blogger amateur y emprendedor en sueños.</p><p><a href='http://www.masquewordpress.com/author/Damian/' title='M&aacute;s post de Damian'>M&aacute;s Posts de Damian</a>  - <a href='http://www.timersys.com' title='Damian'>Web</a> </p><p class="wpa-nomargin">Sigueme:<br /><a class='wpa-social-icons' href='http://www.twitter.com/chifliiiii'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/twitter.png' alt='Twitter'/></a><a class='wpa-social-icons' href='http://www.facebook.com/pages/Timersys/146687622031640'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/facebook.png' alt='Facebook'/></a><a class='wpa-social-icons' href='http://ar.linkedin.com/pub/damian-logghe/26/173/321'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/linkedin.png' alt='LinkedIn'/></a></p></p>]]></content:encoded>
			<wfw:commentRss>http://www.masquewordpress.com/detectar-pais-provincia-y-ciudad-mediante-ip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Clase para mostrar fechas al estilo &#8220;hace 1 dia 6 min&#8221; con PHP</title>
		<link>http://www.masquewordpress.com/clase-para-mostrar-fechas-estilo-hace-1dia-6min-con-php/</link>
		<comments>http://www.masquewordpress.com/clase-para-mostrar-fechas-estilo-hace-1dia-6min-con-php/#comments</comments>
		<pubDate>Fri, 18 Nov 2011 18:19:33 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Recursos]]></category>
		<category><![CDATA[Tips de PHP]]></category>
		<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[fechas]]></category>

		<guid isPermaLink="false">http://www.masquewordpress.com/?p=1035</guid>
		<description><![CDATA[La mayoría de redes sociales como Twitter o Facebook en lugar de mostrar las fechas como 2011-11-18 utilizan un formato de &#8220;Hace 2 dias 4 horas 3 minutos&#8220;. Pasa usar ese formato en sus programas se pueden ayudar de la siguiente clase de PHP llamada haceTanto. Esta clase la encontre por internet en formato ingles [...]]]></description>
			<content:encoded><![CDATA[<p>La mayoría de redes sociales como Twitter o Facebook en lugar de mostrar las fechas como 2011-11-18 utilizan un formato de &#8220;<strong>Hace 2 dias 4 horas 3 minutos</strong>&#8220;. Pasa usar ese formato en sus programas se pueden ayudar de la siguiente <strong>clase de PHP llamada haceTanto</strong>.<br />
Esta clase la encontre por internet en formato ingles y la modifique para nuestro idioma y le agregue la opción de elegir una profundidad a la hora de mostrar fechas.</p>
<p><span id="more-1035"></span></p>
<div class="iconbox"><span class="iconbox_icon"><img src='http://www.masquewordpress.com/wp-content/themes/brightbox/images/icons/iconbox/alert.png' alt='' /></span><div class="iconbox_content"><h3 class="iconbox_content_title">Importante</h3><p>Esta clase solo funciona con PHP &gt;= 5.3 ya que la función DateTime::diff() no se encuentra en versiones previas</p>
</div></div>
<p>Para utilizar la clase la llamamos de la siguiente forma:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">date_default_timezone_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Europe/Madrid'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$hace</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> haceTanto<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'2010-02-22 18:42:00'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'s'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Hace'</span><span style="color: #339933;">.</span><span style="color: #000088;">$hace</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<ul>
<li>1. Definimos el Timezone que nos encontramos</li>
<li>2. Creamos la instancia de haceTanto pasando dos valores.
<ul>
<li>Una fecha por ejemplo: &#8220;2011-10-26&#8243;</li>
<li>La profundidad hasta la que queremos mostrar siendo los posibles valores: &#8216;y&#8217; => años ,&#8217;m&#8217; => meses, &#8216;d&#8217; => dias, &#8216;i&#8217; => horas, &#8216;m&#8217; => minutos, &#8216;s&#8217; => segundos</li>
</ul>
</li>
<li>3. Imprimimos la fecha</li>
</ul>
<p>El ejemplo anterior imprime:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">date_default_timezone_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Europe/Madrid'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$hace</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> haceTanto<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'2010-02-22 18:42:00'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'s'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Hace'</span><span style="color: #339933;">.</span><span style="color: #000088;">$hace</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//Hace 1 año 8 meses 27 dias 28 minutos 5 segundos</span></pre></td></tr></table></div>

<p>Y ahora la clase de PHP encargada de esto:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> haceTanto <span style="color: #000000; font-weight: bold;">extends</span> DateTime <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$strings</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'y'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'1 a&amp;ntilde;o'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'%d a&amp;ntilde;os'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'m'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'1 mes'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'%d meses'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'d'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'1 d&amp;iacute;a'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'%d dias'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'h'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'1 hora'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'%d horas'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'i'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'1 min'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'%d minutos'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'s'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'segundos'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'%d segundos'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$profundidad</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$fecha</span><span style="color: #339933;">,</span><span style="color: #000088;">$profundidad</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'i'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        parent<span style="color: #339933;">::</span>__construct<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$fecha</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">profundidad</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$profundidad</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __toString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	     try 
	    <span style="color: #009900;">&#123;</span>  
	     	<span style="color: #000088;">$now</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'now'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	        <span style="color: #000088;">$diff</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">diff</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$now</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	        <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">strings</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
	            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' '</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDiffText</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #339933;">,</span> <span style="color: #000088;">$diff</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
	            <span style="color: #009900;">&#125;</span>
	            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">profundidad</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
	        <span style="color: #009900;">&#125;</span>
	        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$text</span><span style="color: #339933;">;</span>   
	    <span style="color: #009900;">&#125;</span> 
	    catch<span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> 
	    <span style="color: #009900;">&#123;</span>  
	        <span style="color: #990000;">trigger_error</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">E_USER_ERROR</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
	        <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>  
	    <span style="color: #009900;">&#125;</span>  
&nbsp;
&nbsp;
    <span style="color: #009900;">&#125;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> getDiffText<span style="color: #009900;">&#40;</span><span style="color: #000088;">$intervalKey</span><span style="color: #339933;">,</span> <span style="color: #000088;">$diff</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$pluralKey</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$diff</span><span style="color: #339933;">-&gt;</span><span style="color: #000088;">$intervalKey</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$pluralKey</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">strings</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$intervalKey</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$pluralKey</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Espero que les sirva de ayuda en sus proyectos. Saludos!!</p>
<p><div style="float:left; text-align:left;><img alt='' src='http://1.gravatar.com/avatar/516ffa1373c8295d2e5ff5267fc53399?s=100&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D100&amp;r=G' class='avatar avatar-100 photo' height='100' width='100' /></div><h3><a href='http://www.masquewordpress.com/author/Damian/' title='Damian'>Damian</a></h3><p>Programador en tiempos libres , amante de la tecnología, blogger amateur y emprendedor en sueños.</p><p><a href='http://www.masquewordpress.com/author/Damian/' title='M&aacute;s post de Damian'>M&aacute;s Posts de Damian</a>  - <a href='http://www.timersys.com' title='Damian'>Web</a> </p><p class="wpa-nomargin">Sigueme:<br /><a class='wpa-social-icons' href='http://www.twitter.com/chifliiiii'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/twitter.png' alt='Twitter'/></a><a class='wpa-social-icons' href='http://www.facebook.com/pages/Timersys/146687622031640'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/facebook.png' alt='Facebook'/></a><a class='wpa-social-icons' href='http://ar.linkedin.com/pub/damian-logghe/26/173/321'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/linkedin.png' alt='LinkedIn'/></a></p></p>]]></content:encoded>
			<wfw:commentRss>http://www.masquewordpress.com/clase-para-mostrar-fechas-estilo-hace-1dia-6min-con-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tip de PHP: Como eliminar el último caracter de un string o cadena</title>
		<link>http://www.masquewordpress.com/tip-de-php-como-eliminar-el-ultimo-caracter-de-un-string-o-cadena/</link>
		<comments>http://www.masquewordpress.com/tip-de-php-como-eliminar-el-ultimo-caracter-de-un-string-o-cadena/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 14:18:04 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips de PHP]]></category>
		<category><![CDATA[Tutoriales]]></category>

		<guid isPermaLink="false">http://www.masquewordpress.com/?p=1030</guid>
		<description><![CDATA[Hoy les traigo un pequeño tip de PHP que me han preguntado en alguna que otra ocasión. Si por ejemplo tenemos una lista de ids que hemos generados y nos sobra una coma final, con esta pequeña función super conocida se la podemos quitar. Para ello tan solo necesitamos usar la función subtrs() de PHP [...]]]></description>
			<content:encoded><![CDATA[<p>Hoy les traigo un pequeño tip de <a href="http://www.masquewordpress.com/tag/PHP">PHP</a> que me han preguntado en alguna que otra ocasión. Si por ejemplo tenemos una lista de ids que hemos generados y nos sobra una coma final, con esta pequeña función super conocida se la podemos quitar.<br />
<span id="more-1030"></span><br />
Para ello tan solo necesitamos usar la <a href="http://php.net/manual/es/function.substr.php">función subtrs() de PHP</a></p>
<p>Por ejemplo :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span> <span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #339933;">=</span><span style="color: #cc66cc;">10</span> <span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000088;">$ids</span><span style="color: #339933;">.=</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">', '</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$ids</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Imprime &quot;1, 2, 3, 4, 5, 6, 7, 8, 9, 10,&quot;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$ids</span> <span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span> <span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Imprime &quot;1, 2, 3, 4, 5, 6, 7, 8, 9, 10&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h2><span style="color: #ff0000;">ACTUALIZACIÓN</span></h2>
<p><a href="https://twitter.com/#!/vientocero">Nilo Velez</a> ha dejado  en los comentarios una función de PHP específica para esto que la verdad no conocía. La programación es como las matemáticas, hay más de una forma de resolver un problema.  Aquí les dejo la función</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #990000;">rtrim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ids</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">','</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>&nbsp;</p>
<p>Espero que este pequeño tip les sea útil alguna vez. Saludos!!</p>
<p><div style="float:left; text-align:left;><img alt='' src='http://1.gravatar.com/avatar/516ffa1373c8295d2e5ff5267fc53399?s=100&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D100&amp;r=G' class='avatar avatar-100 photo' height='100' width='100' /></div><h3><a href='http://www.masquewordpress.com/author/Damian/' title='Damian'>Damian</a></h3><p>Programador en tiempos libres , amante de la tecnología, blogger amateur y emprendedor en sueños.</p><p><a href='http://www.masquewordpress.com/author/Damian/' title='M&aacute;s post de Damian'>M&aacute;s Posts de Damian</a>  - <a href='http://www.timersys.com' title='Damian'>Web</a> </p><p class="wpa-nomargin">Sigueme:<br /><a class='wpa-social-icons' href='http://www.twitter.com/chifliiiii'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/twitter.png' alt='Twitter'/></a><a class='wpa-social-icons' href='http://www.facebook.com/pages/Timersys/146687622031640'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/facebook.png' alt='Facebook'/></a><a class='wpa-social-icons' href='http://ar.linkedin.com/pub/damian-logghe/26/173/321'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/linkedin.png' alt='LinkedIn'/></a></p></p>]]></content:encoded>
			<wfw:commentRss>http://www.masquewordpress.com/tip-de-php-como-eliminar-el-ultimo-caracter-de-un-string-o-cadena/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Crear filtro de Spam y palabras prohibidas</title>
		<link>http://www.masquewordpress.com/crear-filtro-de-spam-y-palabras-prohibidas/</link>
		<comments>http://www.masquewordpress.com/crear-filtro-de-spam-y-palabras-prohibidas/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 20:22:19 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[palabras prohibidas]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://masquewordpress.com/?p=767</guid>
		<description><![CDATA[Después de varios siglos de inactividad vuelvo a postear algo en el blog. Tras un tiempo recibiendo increíble cantidad de anuncios basura de Iphones y como ganar dinero fácil en mi página web de clasificados naúticos Nautiic decidí crear algún tipo de filtro que pusiese ciertos anuncios en moderación hasta que yo los apruebe. Cuando [...]]]></description>
			<content:encoded><![CDATA[<p>Después de varios siglos de inactividad <img src='http://www.masquewordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  vuelvo a postear algo en el blog.</p>
<p>Tras un tiempo recibiendo increíble cantidad de anuncios basura de Iphones y como ganar dinero fácil en mi página web de clasificados naúticos <a href="http://nautiic.com">Nautiic</a> decidí crear algún tipo de filtro que pusiese ciertos anuncios en moderación hasta que yo los apruebe.</p>
<p>Cuando cree el <a href="http://nautiic.com.ar">directorio náutico</a> tan solo cree como protección contra spam códigos captchas y verificación de email. El problema es que hay gente humana que se dedica a postear cosas donde no van.</p>
<p>He aquí la solución :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$mensaje</span><span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Este es el mensaje donde intento vender un iPhone 4&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$lista_palabras</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;iphone&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;bisagras&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;alacenas&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;bajos mesadas&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;career&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;loan&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;cash&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$lista_palabras</span> <span style="color: #b1b100;">as</span> <span style="color: #339933;">&amp;</span><span style="color: #000088;">$palabra</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$palabra</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_quote</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$palabra</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$spam</span><span style="color: #339933;">=</span> <span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/('</span><span style="color: #339933;">.</span><span style="color: #990000;">join</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'|'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lista_palabras</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">')/i'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$mensaje</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Si dentro del mensaje hay coincidencias con las palabras de la lista, la variable spam sera verdadera. En caso contrario tendra valor 0.</p>
<p>A partir de ahí ya pueden realizar lo que quieran. Yo en mi caso añadi un nuevo campa a la base de datos llamado moderar , donde si es spam es verdadero, activo dicho campo. Si el campo esta activado no se mostrara el anuncio en mi web.<br />
Espero que les haya servido de ayuda. Saludos!!!</p>
<p><div style="float:left; text-align:left;><img alt='' src='http://1.gravatar.com/avatar/516ffa1373c8295d2e5ff5267fc53399?s=100&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D100&amp;r=G' class='avatar avatar-100 photo' height='100' width='100' /></div><h3><a href='http://www.masquewordpress.com/author/Damian/' title='Damian'>Damian</a></h3><p>Programador en tiempos libres , amante de la tecnología, blogger amateur y emprendedor en sueños.</p><p><a href='http://www.masquewordpress.com/author/Damian/' title='M&aacute;s post de Damian'>M&aacute;s Posts de Damian</a>  - <a href='http://www.timersys.com' title='Damian'>Web</a> </p><p class="wpa-nomargin">Sigueme:<br /><a class='wpa-social-icons' href='http://www.twitter.com/chifliiiii'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/twitter.png' alt='Twitter'/></a><a class='wpa-social-icons' href='http://www.facebook.com/pages/Timersys/146687622031640'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/facebook.png' alt='Facebook'/></a><a class='wpa-social-icons' href='http://ar.linkedin.com/pub/damian-logghe/26/173/321'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/linkedin.png' alt='LinkedIn'/></a></p></p>]]></content:encoded>
			<wfw:commentRss>http://www.masquewordpress.com/crear-filtro-de-spam-y-palabras-prohibidas/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Como crear una página de lanzamiento con PHP, AJAX y JQuery &#8211; II Parte</title>
		<link>http://www.masquewordpress.com/como-crear-una-pagina-de-lanzamiento-con-php-ajax-y-jquery-ii-parte/</link>
		<comments>http://www.masquewordpress.com/como-crear-una-pagina-de-lanzamiento-con-php-ajax-y-jquery-ii-parte/#comments</comments>
		<pubDate>Sat, 15 Aug 2009 21:29:49 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[jquery.plugin]]></category>
		<category><![CDATA[pagina lanzamiento]]></category>

		<guid isPermaLink="false">http://masquewordpress.com/?p=222</guid>
		<description><![CDATA[Hoy les voy a explicar como crear un formulario AJAX para nuestra página de lanzamiento y así poder crear una base de datos con los emails de nuestros visitantes que quieren manternerse actualizados con novedades, etc. Siguiendo la estructura básica de una web vamos a necesitar varios archivos para lo que queremos hacer: config/db.php Archivo [...]]]></description>
			<content:encoded><![CDATA[<p>Hoy les voy a explicar como crear <a title="Como crear formulario AJAX" href="http://masquewordpress.com/jquery/como-enviar-un-formulario-via-ajax-con-jquery/">un formulario AJAX</a> para nuestra <a title="Crear una página de lanzamiento con PHP AJAX y JQuery" href="http://masquewordpress.com/jquery/como-crear-una-pagina-de-lanzamiento-con-php-ajax-y-jquery/">página de lanzamiento</a> y así poder crear una base de datos con los emails de nuestros visitantes que quieren manternerse actualizados con novedades, etc.</p>
<p style="text-align: center;"><img class="size-full wp-image-206  aligncenter" title="cuenta-atras" src="http://masquewordpress.com/wp-content/uploads/2009/07/pagina-lanzamiento.png" alt="cuenta-atras" /></p>
<p style="text-align: left;">Siguiendo la <a title="Introducción al diseño web" href="http://masquewordpress.com/tutoriales/introduccion-al-diseno-web-con-php-css-parte-i/">estructura básica </a>de una web vamos a necesitar varios archivos para lo que queremos hacer:</p>
<ul>
<li><a href="http://masquewordpress.com/php/dbphp-como-definir-los-parametros-de-conexion-de-tu-base-de-datos/"><strong>config/db.php</strong></a> Archivo donde configuramos los parametros de conexión a la base de datos</li>
<li><strong>ajax_usuarios.php</strong> Archivo encargado de recibir la petición AJAX e ingresar los emails en la base de datos</li>
<li><strong>index.php </strong>Página de lanzamiento que veran los usuarios</li>
<li><strong>css/estilo.css </strong>Página con código CSS</li>
<li><a href="http://jquery.com/"><strong>js/jquery-latest.js</strong> </a>Última versión de JQuery</li>
<li><a href="http://masquewordpress.com/jquery/como-redondear-las-esquinas-de-un-div-con-jquery-corners/"><strong>js/jquery.corners.js</strong></a> Plugin para redondear esquinas</li>
<li><a href="http://masquewordpress.com/jquery/como-crear-una-pagina-de-lanzamiento-con-php-ajax-y-jquery/"><strong>js/jquery.epiclock.js</strong></a> Plugin para crear cuenta atras</li>
<li><a href="http://masquewordpress.com/jquery/como-enviar-un-formulario-via-ajax-con-jquery/"><strong>js/jquery.form.js</strong></a> Plugin para enviar formulario via AJAX</li>
<li><a href="http://masquewordpress.com/recursos/jqtransform-aplica-estilo-a-tus-formularios-de-una-forma-sencilla/"><strong>js/jquery.jqtransform.js</strong></a> Plugin para dar estilo al formulario.
</ul>
<p>Como ya tenemos definido el archivo db.php tal y como <a href="http://masquewordpress.com/php/dbphp-como-definir-los-parametros-de-conexion-de-tu-base-de-datos/">se explico en su día</a> , pasamos al archivo<strong> ajax_usuarios.php</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// compruena la variable $_POST </span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #666666; font-style: italic;">/* Conectamos a la base de datos */</span>
     <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'config/db.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #000088;">$conn</span><span style="color: #339933;">=</span>get_db_conn<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #666666; font-style: italic;">/* Protejo SQL injection */</span>
     <span style="color: #000088;">$email</span> <span style="color: #339933;">=</span> cleanQuery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #666666; font-style: italic;">/* Realizo consulta SQL */</span>
     <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;INSERT INTO listado_emails (email) VALUES ('<span style="color: #006699; font-weight: bold;">$email</span>')&quot;</span><span style="color: #339933;">;</span>
     <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">,</span><span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// Mensaje de respuesta</span>
     <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$email</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">' fue ingresado a la base de datos correctamente!!!!!!'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> 
     <span style="color: #666666; font-style: italic;">// En caso de q la variable no este iniciado o no tenga caracteres el mensaje de respuesta es el siguiente</span>
 <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Hubo un error, intenta otra ves.'</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>El código de index.php también va a cambiar ya que agregamos nuevos plugins de JQuery y el formulario para ingresar emails<br />
<strong><br />
index.php</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Content-Type&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html; charset=ISO-8859-1&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>Timersys<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;css/estilo.css&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;css/jqtransform.css&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;../jquery.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;js/jquery.epiclock.min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;js/jquery.corners.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;js/jquery.form.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;js/jquery.jqtransform.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
$(document).ready(function(){
	// Cuenta atras					   
	   jQuery('#text').epiclock({mode: EC_COUNTDOWN, format: 'V{<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">sup</span>&gt;</span>dias<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">sup</span>&gt;</span>} x{<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">sup</span>&gt;</span>horas<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">sup</span>&gt;</span>} i{<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">sup</span>&gt;</span>minutos<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">sup</span>&gt;</span>} s{<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">sup</span>&gt;</span>segundos<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">sup</span>&gt;</span>}', target: 'January 1, 2012 00:00:00'}).clocks(EC_RUN);  
&nbsp;
	   //Esquinas redondeadas
	   $('.rounded').corners('transparent');
&nbsp;
	   //Transformar el formulario
	   $(&quot;form.jqtransform&quot;).jqTransform();
&nbsp;
&nbsp;
	   // definimos las opciones del plugin AJAX FORM
            var opciones= {
&nbsp;
                               success: mostrarRespuesta //funcion que se ejecuta una vez enviado el formulario
            };
             //asignamos el plugin ajaxForm al formulario email_list y le pasamos las opciones
            $('#email_list').ajaxForm(opciones) ;
&nbsp;
             //lugar donde defino las funciones que utilizo dentro de &quot;opciones&quot;
&nbsp;
             function mostrarRespuesta (responseText){
                          $(&quot;#update&quot;).fadeOut(&quot;slow&quot;); // Hago desaparecer el formulario
                          $(&quot;#succes&quot;).fadeIn(&quot;slow&quot;).html(responseText); //muestro mensaje 
             };
&nbsp;
&nbsp;
		});
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span> 
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;header&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h3</span>&gt;</span>Como crear una P<span style="color: #ddbb00;">&amp;aacute;</span>gina de lanzamiento. M<span style="color: #ddbb00;">&amp;aacute;</span>s tutoriales en: <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://masquewordpress.com&quot;</span>&gt;</span>http://masquewordpress.com<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span> <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h3</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;wrapper&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cuadro2&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;rounded&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;count_down&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;update&quot;</span>&gt;</span>
&nbsp;
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;email_list&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jqtransform&quot;</span> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ajax_usuarios.php&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;input_text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;email&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Ingresa tu email para recibir actualizaciones&quot;</span> <span style="color: #000066;">onclick</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;this.select();&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ENVIAR&quot;</span>  <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;input_button&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
     <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;succes&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></td></tr></table></div>

<p>Con esto y un poco de código CSS ya tendriamos nuestra página de lanzamiento lista , y ademas podriamos juntar una base de datos con emails de los usuarios para poder enviarles actualizaciones.</p>
<p>Como siempre pueden ver el <a href="http://masquewordpress.com/ejemplos/pagina-de-lanzamiento/">EJEMPLO TERMINADO</a></p>
<p>Y descargar el <a href="http://masquewordpress.com/ejemplos/pagina-de-lanzamiento-II.zip">código fuente</a> .( Recuerden de editar el archivo db.php con los datos de su propia base de datos y crear las tablas necesarias)</p>
<p><div style="float:left; text-align:left;><img alt='' src='http://1.gravatar.com/avatar/516ffa1373c8295d2e5ff5267fc53399?s=100&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D100&amp;r=G' class='avatar avatar-100 photo' height='100' width='100' /></div><h3><a href='http://www.masquewordpress.com/author/Damian/' title='Damian'>Damian</a></h3><p>Programador en tiempos libres , amante de la tecnología, blogger amateur y emprendedor en sueños.</p><p><a href='http://www.masquewordpress.com/author/Damian/' title='M&aacute;s post de Damian'>M&aacute;s Posts de Damian</a>  - <a href='http://www.timersys.com' title='Damian'>Web</a> </p><p class="wpa-nomargin">Sigueme:<br /><a class='wpa-social-icons' href='http://www.twitter.com/chifliiiii'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/twitter.png' alt='Twitter'/></a><a class='wpa-social-icons' href='http://www.facebook.com/pages/Timersys/146687622031640'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/facebook.png' alt='Facebook'/></a><a class='wpa-social-icons' href='http://ar.linkedin.com/pub/damian-logghe/26/173/321'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/linkedin.png' alt='LinkedIn'/></a></p></p>]]></content:encoded>
			<wfw:commentRss>http://www.masquewordpress.com/como-crear-una-pagina-de-lanzamiento-con-php-ajax-y-jquery-ii-parte/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Como crear una página de lanzamiento con PHP, AJAX y JQuery</title>
		<link>http://www.masquewordpress.com/como-crear-una-pagina-de-lanzamiento-con-php-ajax-y-jquery/</link>
		<comments>http://www.masquewordpress.com/como-crear-una-pagina-de-lanzamiento-con-php-ajax-y-jquery/#comments</comments>
		<pubDate>Sun, 26 Jul 2009 00:12:33 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[jquery.plugin]]></category>
		<category><![CDATA[pagina lanzamiento]]></category>

		<guid isPermaLink="false">http://masquewordpress.com/?p=202</guid>
		<description><![CDATA[En este tutorial les voy a enseñar como hacer una página de lanzamiento como la que en ocasiones nos encontramos cuando visitamos una web sin estrenar con su cuenta atras correspondiente. Además de la cuenta atras más adelante vamos a añadir un pequeño formulario de  contácto con AJAX para añadir emails a una base de [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">En este tutorial les voy a enseñar como hacer una página de lanzamiento como la que en ocasiones nos encontramos cuando visitamos una web sin estrenar con su cuenta atras correspondiente. Además de la cuenta atras más adelante vamos a añadir un pequeño <a title="Enviar formulario via AJAX" href="http://masquewordpress.com/jquery/como-enviar-un-formulario-via-ajax-con-jquery/">formulario de  contácto con AJAX</a> para añadir emails a una base de datos y asi poder mantener a los visitantes actualizados.</p>
<p style="text-align: center;">
<img class="size-full wp-image-203  aligncenter" title="cuenta-atras" src="http://masquewordpress.com/wp-content/uploads/2009/07/cuenta-atras1.png" alt="cuenta-atras" width="450px" height="123px"/></p>
<p style="text-align: left;">Para empezar vamos a necesitar un plugin de JQuery muy completo llamado <a title="epiClock Plugin" href="http://eric.garside.name/demo.html?p=epiclock">epiClock</a> que va a ser el encargado de realizar la cuenta atras. La verdad que vale la pena echar una ojeada a la página de epiClock , ya que además de cuentas atras podemos crear todo tipo de relojes, cronometros , etc.</p>
<p style="text-align: left;">
<p style="text-align: left;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;js/jquery-latest.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;js/jquery.epiclock.min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></td></tr></table></div>

<p style="text-align: left;">
<p style="text-align: left;">
<p>Si queremos por ejemplo hacer una cuenta atras hasta el 2012 es tan facil como poner:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">//espero que cargue el DOM y llamo al plugin</span>
  j jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#reloj'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">epiclock</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>mode<span style="color: #339933;">:</span> EC_COUNTDOWN<span style="color: #339933;">,</span> format<span style="color: #339933;">:</span> <span style="color: #3366CC;">'V{&lt;sup&gt;dias&lt;/sup&gt;} x{&lt;sup&gt;horas&lt;/sup&gt;} i{&lt;sup&gt;minutos&lt;/sup&gt;} s{&lt;sup&gt;segundos&lt;/sup&gt;}'</span><span style="color: #339933;">,</span> target<span style="color: #339933;">:</span> <span style="color: #3366CC;">'January 1, 2012 00:00:00'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">clocks</span><span style="color: #009900;">&#40;</span>EC_RUN<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p style="text-align: left;">
<p>Como pueden ver le paso tres parametros a <strong>.epiclock</strong> :</p>
<ul>
<li><strong>mode: </strong> El modo de cuenta atras (countdown).</li>
<li><strong>format:</strong> El formato que quiero que en este caso es &#8216;&lt;sup&gt;dias&lt;/sup&gt;&#8217; para los dias y así susecivamente.</li>
<li><strong>target:</strong> El tiempo final del contador pasado en modo de fecha.
</li>
</ul>
<p style="text-align: left;">
<p style="text-align: left;">
<p>Y por último inicio el contador con <strong>.clocks(EC_RUN)</strong></p>
<p>Una ves que tengo el reloj definido voy a crear el código HTML necesario para que funcione:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;header&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h3</span>&gt;</span>Como crear una P<span style="color: #ddbb00;">&amp;aacute;</span>gina de lanzamiento. M<span style="color: #ddbb00;">&amp;aacute;</span>s tutoriales en: <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://masquewordpress.com&quot;</span>&gt;</span>http://masquewordpress.com<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span> <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h3</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;wrapper&quot;</span>&gt;</span>
           <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cuadro2&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;rounded&quot;</span>&gt;</span>
               <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;reloj&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;count_down&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
           <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></td></tr></table></div>

<p style="text-align: left;">
<p style="text-align: left;">
<p>Y le aplico el siguiente estilo:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">body <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#666666</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span><span style="color: #ff0000;">'Trebuchet MS'</span><span style="color: #00AA00;">,</span><span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">14px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">1.5em</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">justify</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#header</span><span style="color: #00AA00;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">800px</span><span style="color: #00AA00;">;</span>
 <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">80px</span><span style="color: #00AA00;">;</span> 
 <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
 <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
 <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
 <span style="color: #000000; font-weight: bold;">margin-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
 <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
 <span style="color: #00AA00;">&#125;</span> 
<span style="color: #cc00cc;">#cuadro2</span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#EEEEEE</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#CCCCCC</span><span style="color: #00AA00;">;</span>
&nbsp;
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#wrapper</span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">440px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
.count_down<span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">3px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #3333ff;">:Georgia</span><span style="color: #00AA00;">,</span> <span style="color: #ff0000;">&quot;Times New Roman&quot;</span><span style="color: #00AA00;">,</span> Times<span style="color: #00AA00;">,</span> <span style="color: #993333;">serif</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">38px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#222</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.count_down</span> sup<span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span><span style="color: #ff0000;">&quot;Lucida Grande&quot;</span><span style="color: #00AA00;">,</span> <span style="color: #ff0000;">&quot;Lucida Sans Unicode&quot;</span><span style="color: #00AA00;">,</span> Verdana<span style="color: #00AA00;">,</span> Arial<span style="color: #00AA00;">,</span> Helvetica<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#555</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">0px</span> <span style="color: #933;">10px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">normal</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Como toque final voy a redondear las esquinas del DIV contenedor del reloj con jquery.corners como <a href="http://masquewordpress.com/jquery/como-redondear-las-esquinas-de-un-div-con-jquery-corners/">vimos anteriormente</a> en el blog.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"> $<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.rounded'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>corners<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'transparent'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p style="text-align: left;">
<p style="text-align: left;">
<p>Y con eso tendriamos nuestra cuentra atras particular. En el próximo tutorial les explico como crear un formulario con AJAX para guardar todos los emails en una base de datos de forma que podamos mantener actualizados con noticias a nuestros seguidores.<br />
<a href="http://masquewordpress.com/ejemplos/pagina-de-lanzamiento/">Ver Ejemplo Online</a><br />
<a href="http://masquewordpress.com/ejemplos/pagina-de-lanzamiento.zip">Descargar código</a></p>
<p><div style="float:left; text-align:left;><img alt='' src='http://1.gravatar.com/avatar/516ffa1373c8295d2e5ff5267fc53399?s=100&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D100&amp;r=G' class='avatar avatar-100 photo' height='100' width='100' /></div><h3><a href='http://www.masquewordpress.com/author/Damian/' title='Damian'>Damian</a></h3><p>Programador en tiempos libres , amante de la tecnología, blogger amateur y emprendedor en sueños.</p><p><a href='http://www.masquewordpress.com/author/Damian/' title='M&aacute;s post de Damian'>M&aacute;s Posts de Damian</a>  - <a href='http://www.timersys.com' title='Damian'>Web</a> </p><p class="wpa-nomargin">Sigueme:<br /><a class='wpa-social-icons' href='http://www.twitter.com/chifliiiii'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/twitter.png' alt='Twitter'/></a><a class='wpa-social-icons' href='http://www.facebook.com/pages/Timersys/146687622031640'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/facebook.png' alt='Facebook'/></a><a class='wpa-social-icons' href='http://ar.linkedin.com/pub/damian-logghe/26/173/321'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/linkedin.png' alt='LinkedIn'/></a></p></p>]]></content:encoded>
			<wfw:commentRss>http://www.masquewordpress.com/como-crear-una-pagina-de-lanzamiento-con-php-ajax-y-jquery/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Paginación con PHP y MySQL + 3 estilos</title>
		<link>http://www.masquewordpress.com/paginacion-con-php-y-mysql-3-estilos/</link>
		<comments>http://www.masquewordpress.com/paginacion-con-php-y-mysql-3-estilos/#comments</comments>
		<pubDate>Mon, 25 May 2009 18:08:23 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[paginacion]]></category>

		<guid isPermaLink="false">http://masquewordpress.com/?p=23</guid>
		<description><![CDATA[En este tutorial les voy a enseñar el método que utilizo para hacer paginación en mis diseños.Pero para empezar ¿A que se le llama paginación? Esto es simplemente el índice que aparece abajo del todo que algunas veces contiene números y otras no, y nos sirve para cambiar de página. Es muy útil cuando tenemos [...]]]></description>
			<content:encoded><![CDATA[<p>En este tutorial les voy a enseñar el método que utilizo para hacer paginación en mis diseños.Pero para empezar ¿A que se le llama paginación? Esto es simplemente el índice que aparece abajo del todo que algunas veces contiene números y otras no, y nos sirve para cambiar de página. Es muy útil cuando tenemos muchos datos para mostrar y ya resulta feo que aparezca todo en la misma página.</p>
<h3>Típica estructura:</h3>
<p style="text-align: center;"><img class="size-full wp-image-25 aligncenter" style="border: 0pt none; background-color: #fff;" title="estructura-paginacion" src="http://masquewordpress.com/wp-content/uploads/2009/05/estructura-paginacion.png" alt="estructura paginación" width="335" height="162" /></p>
<p>La estructura más comun suele contar con 2 botones (Previous y next) más otros tantos con los números de las páginas que tengamos(variable segun la cantidad de datos). El número resaltado indica en que página nos encontramos actualmente , y si no hay más páginas hacia abajo o hacia arriba se deshabilitaran los botones de Previous y Next respectivamente. Por último tenemos el selector de números que nos permitira saltar directamente a cualquier página sin necesidad de pasar una a una.</p>
<p>Para diseñar esta estructura usaremos una lista HTML (&lt;ul&gt;) que a su vez contendra tantos elementos de lista (&lt;li&gt;) como sea necesario. A cada lista le vamos a asignar un ID que definirá su estilo. A continuación paso a explicar más detalladamente.</p>
<h3>Paginación al estilo de Flickr:</h3>
<p>En este caso vamos a diseñar la paginación al estilo de Flickr y se verá del siguiente modo:</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-26" title="flicrk" src="http://masquewordpress.com/wp-content/uploads/2009/05/flicrk.png" alt="flicrk" width="266" height="46" /></p>
<p>El código HTML que vamos a usar es muy simple y nos servira como esqueleto para cualquier estilo , ya que solo necesitaremos cambiar el ID de la lista que en el siguiente caso será <strong><em> &#8220;pagination-flickr&#8221;.</em></strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;pagination-flickr&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;previous-off&quot;</span>&gt;</span>«Previous<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;active&quot;</span>&gt;</span>1<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;?page=2&quot;</span>&gt;</span>2<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;?page=3&quot;</span>&gt;</span>3<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;?page=4&quot;</span>&gt;</span>4<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;?page=5&quot;</span>&gt;</span>5<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;?page=6&quot;</span>&gt;</span>6<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;?page=7&quot;</span>&gt;</span>7<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;next&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;?page=8&quot;</span>&gt;</span>Next »<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span></pre></td></tr></table></div>

<p>Ahora solo nos queda agregar el <strong>código CSS</strong> para darle estilo a nuestra lista:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* -------------------------------------------- */</span>
<span style="color: #808080; font-style: italic;">/* ------------- Pagination: Flickr -----------	*/</span>
<span style="color: #808080; font-style: italic;">/* -------------------------------------------- */</span>
ul    <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#pagination-flickr</span> li          <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">11px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* savers */</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#pagination-flickr</span> a           <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #993333;">solid</span> <span style="color: #933;">1px</span> <span style="color: #cc00cc;">#DDDDDD</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#pagination-flickr</span> .previous-off<span style="color: #00AA00;">,</span>
<span style="color: #cc00cc;">#pagination-flickr</span> <span style="color: #6666ff;">.next-off</span>   <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#666666</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">3px</span> <span style="color: #933;">4px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#pagination-flickr</span> <span style="color: #6666ff;">.next</span> a<span style="color: #00AA00;">,</span>
<span style="color: #cc00cc;">#pagination-flickr</span> <span style="color: #6666ff;">.previous</span> a <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #993333;">solid</span> <span style="color: #933;">1px</span> <span style="color: #cc00cc;">#FFFFFF</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#pagination-flickr</span> <span style="color: #6666ff;">.active</span>     <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#ff0084</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">4px</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#pagination-flickr</span> a<span style="color: #3333ff;">:link</span><span style="color: #00AA00;">,</span>
<span style="color: #cc00cc;">#pagination-flickr</span> a<span style="color: #3333ff;">:visited   </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#0063e3</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">3px</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#pagination-flickr</span> a<span style="color: #3333ff;">:hover     </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #993333;">solid</span> <span style="color: #933;">1px</span> <span style="color: #cc00cc;">#666666</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<h3>Paginación al estilo de DIGG:</h3>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-27" title="digg" src="http://masquewordpress.com/wp-content/uploads/2009/05/digg.png" alt="digg" width="277" height="33" /></p>
<p>La estructura como pueden ver es la misma. Solo cambiamos el atributo ID de la lista.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;pagination-digg&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;previous-off&quot;</span>&gt;</span>«Previous<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;active&quot;</span>&gt;</span>1<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;?page=2&quot;</span>&gt;</span>2<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;?page=3&quot;</span>&gt;</span>3<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;?page=4&quot;</span>&gt;</span>4<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;?page=5&quot;</span>&gt;</span>5<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;?page=6&quot;</span>&gt;</span>6<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;?page=7&quot;</span>&gt;</span>7<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;next&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;?page=8&quot;</span>&gt;</span>Next »<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span></pre></td></tr></table></div>

<p>Y nuevamente añadiremos el estilo correspondiente. Como vereis los elementos son los mismos, solo cambiamos algunos atributos:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* -------------------------------------------- */</span>
<span style="color: #808080; font-style: italic;">/* ----------- Pagination: Digg Style --------- */</span>
<span style="color: #808080; font-style: italic;">/* -------------------------------------------- */</span>
ul    <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#pagination-digg</span> li          <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">11px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* savers */</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#pagination-digg</span> a           <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #993333;">solid</span> <span style="color: #933;">1px</span> <span style="color: #cc00cc;">#9aafe5</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#pagination-digg</span> .previous-off<span style="color: #00AA00;">,</span>
<span style="color: #cc00cc;">#pagination-digg</span> <span style="color: #6666ff;">.next-off</span>   <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #993333;">solid</span> <span style="color: #933;">1px</span> <span style="color: #cc00cc;">#DEDEDE</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#888888</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">3px</span> <span style="color: #933;">4px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#pagination-digg</span> <span style="color: #6666ff;">.next</span> a<span style="color: #00AA00;">,</span>
<span style="color: #cc00cc;">#pagination-digg</span> <span style="color: #6666ff;">.previous</span> a <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#pagination-digg</span> <span style="color: #6666ff;">.active</span>     <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#2e6ab1</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FFFFFF</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">4px</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* savers */</span> <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#pagination-digg</span> a<span style="color: #3333ff;">:link</span><span style="color: #00AA00;">,</span>
<span style="color: #cc00cc;">#pagination-digg</span> a<span style="color: #3333ff;">:visited   </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#0e509e</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">3px</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#pagination-digg</span> a<span style="color: #3333ff;">:hover     </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #993333;">solid</span> <span style="color: #933;">1px</span> <span style="color: #cc00cc;">#0e509e</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<h3>Estilo de paginación limpio:</h3>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-28" title="clean" src="http://masquewordpress.com/wp-content/uploads/2009/05/clean.png" alt="clean" width="270" height="34" /></p>
<p>Para crear un estilo un poco más limpio y menos cargado podemos usar el siguiente codigo CSS. Recordar que tienen que cambiar el <strong>ID</strong> del elemento <strong>&lt;ul&gt;</strong> por <strong> &#8220;pagination-clean&#8221; </strong>:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* -------------------------------------------- */</span>
<span style="color: #808080; font-style: italic;">/* ------------- Pagination: Clean ------------ */</span>
<span style="color: #808080; font-style: italic;">/* -------------------------------------------- */</span>
<span style="color: #cc00cc;">#pagination-clean</span> li          <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">11px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* savers */</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #808080; font-style: italic;">/* savers #pagination-clean li,*/</span>
<span style="color: #cc00cc;">#pagination-clean</span> a           <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">border-right</span><span style="color: #00AA00;">:</span><span style="color: #993333;">solid</span> <span style="color: #933;">1px</span> <span style="color: #cc00cc;">#DEDEDE</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#pagination-clean</span> .previous-off<span style="color: #00AA00;">,</span>
<span style="color: #cc00cc;">#pagination-clean</span> <span style="color: #6666ff;">.next-off</span>   <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#888888</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">3px</span> <span style="color: #933;">4px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#pagination-clean</span> <span style="color: #6666ff;">.next</span> a<span style="color: #00AA00;">,</span>
<span style="color: #cc00cc;">#pagination-clean</span> previous a  <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#pagination-clean</span> <span style="color: #6666ff;">.active</span>     <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000000</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">4px</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* savers */</span> <span style="color: #000000; font-weight: bold;">border-right</span><span style="color: #00AA00;">:</span><span style="color: #993333;">solid</span> <span style="color: #933;">1px</span> <span style="color: #cc00cc;">#DEDEDE</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#pagination-clean</span> a<span style="color: #3333ff;">:link</span><span style="color: #00AA00;">,</span>
<span style="color: #cc00cc;">#pagination-clean</span> a<span style="color: #3333ff;">:visited   </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#0e509e</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">3px</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#pagination-clean</span> a<span style="color: #3333ff;">:hover     </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Con esto ya tenemos unas listas y su correspondientes estilos para que nuestra paginación quede de una forma profesional. El siguiente paso es añadir el codigo PHP necesario para crear el índice de acuerdo a la cantidad de datos que tengamos y poder así modificar la consulta SQL para que nos muestre ciertos resultados. Para las conexiones a la base de datos voy a seguir los pasos descritos en <a href="http://masquewordpress.com/php/dbphp-como-definir-los-parametros-de-conexion-de-tu-base-de-datos/" target="_blank">este artículo</a>.</p>
<p>Para empezar necesitamos hacer 2 consultas SQL en lugar de 1. La primera va a ser para recuperar <strong>TODOS </strong> los datos y asi poder calcular cuantas páginas vamos a necesitar. La segunda consulta va a mostrar un rango de resultados según en que página estemos.</p>
<p>Por ejemplo digamos que queremos mostrar una tabla con datos de películas donde nos muestre el nombre de la película, el año de creación , etc. La tabla SQL esta compuesto por los siguientes campos: idPelicula(int(5)), nombre(VARCHAR(150)), director(VARCHAR(100)), anio(DATE).</p>
<p>A continuación como seria el código:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">//INCLUYO LA HOJA DE ESTILOS</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;link href=&quot;css/paginacion.css&quot; type=&quot;text/css&quot; rel=&quot;stylesheet&quot;&gt;
<span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'config/db.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$conn</span><span style="color: #339933;">=</span>get_db_conn<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//AL PRINCIPIO COMPRUEBO SI HICIERON CLICK EN ALGUNA PÁGINA </span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'page'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$page</span><span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'page'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">//SI NO DIGO Q ES LA PRIMERA PÁGINA</span>
    <span style="color: #000088;">$page</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//ACA SE SELECCIONAN TODOS LOS DATOS DE LA TABLA</span>
<span style="color: #000088;">$consulta</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;SELECT * FROM peliculas&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$datos</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$consulta</span><span style="color: #339933;">,</span><span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//MIRO CUANTOS DATOS FUERON DEVUELTOS</span>
<span style="color: #000088;">$num_rows</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_num_rows</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$datos</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//ACA SE DECIDE CUANTOS RESULTADOS MOSTRAR POR PÁGINA , EN EL EJEMPLO PONGO 15</span>
<span style="color: #000088;">$rows_per_page</span><span style="color: #339933;">=</span> <span style="color: #cc66cc;">15</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//CALCULO LA ULTIMA PÁGINA</span>
<span style="color: #000088;">$lastpage</span><span style="color: #339933;">=</span> <span style="color: #990000;">ceil</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$num_rows</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$rows_per_page</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//COMPRUEBO QUE EL VALOR DE LA PÁGINA SEA CORRECTO Y SI ES LA ULTIMA PÁGINA</span>
<span style="color: #000088;">$page</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span><span style="color: #000088;">$page</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$lastpage</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$page</span><span style="color: #339933;">=</span> <span style="color: #000088;">$lastpage</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$page</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//CREO LA SENTENCIA LIMIT PARA AÑADIR A LA CONSULTA QUE DEFINITIVA</span>
<span style="color: #000088;">$limit</span><span style="color: #339933;">=</span> <span style="color: #0000ff;">'LIMIT '</span><span style="color: #339933;">.</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$rows_per_page</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">','</span> <span style="color: #339933;">.</span><span style="color: #000088;">$rows_per_page</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//REALIZO LA CONSULTA QUE VA A MOSTRAR LOS DATOS (ES LA ANTERIO + EL $limit)</span>
<span style="color: #000088;">$consulta</span> <span style="color: #339933;">.=</span><span style="color: #0000ff;">&quot; <span style="color: #006699; font-weight: bold;">$limit</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$peliculas</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$consulta</span><span style="color: #339933;">,</span><span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$peliculas</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">//SI FALLA LA CONSULTA MUESTRO ERROR</span>
 <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Invalid query: '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
      <span style="color: #666666; font-style: italic;">//SI ES CORRECTA MUESTRO LOS DATOS </span>
      <span style="color: #000000; font-weight: bold;">?&gt;</span> &lt;table&gt;&lt;thead&gt;
        &lt;tr&gt;&lt;th&gt;Título&lt;/th&gt;&lt;th&gt;Director&lt;/th&gt;&lt;th&gt; Año de producción&lt;/th&gt;&lt;/tr&gt;
        &lt;/thead&gt;
        &lt;tbody&gt;
    <span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_assoc</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$peliculas</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>  <span style="color: #000000; font-weight: bold;">?&gt;</span>
        &lt;tr&gt;&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'nombre'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> &lt;/td&gt;&lt;td&gt; <span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'director'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> &lt;/td&gt;&lt;td&gt; <span style="color: #000000; font-weight: bold;">&lt;?</span><span style="color: #b1b100;">echo</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'anio'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> &lt;/td&gt;&lt;/tr&gt;
       <span style="color: #000000; font-weight: bold;">&lt;?</span>  <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
      &lt;/tbody&gt;
      &lt;/table&gt;
<span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #666666; font-style: italic;">//UNA VEZ Q MUESTRO LOS DATOS TENGO Q MOSTRAR EL BLOQUE DE PAGINACIÓN SIEMPRE Y CUANDO HAYA MÁS DE UNA PÁGINA</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$numrows</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$nextpage</span><span style="color: #339933;">=</span> <span style="color: #000088;">$page</span> <span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$prevpage</span><span style="color: #339933;">=</span> <span style="color: #000088;">$page</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;ul id=&quot;pagination-digg&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #666666; font-style: italic;">//SI ES LA PRIMERA PÁGINA DESHABILITO EL BOTON DE PREVIOUS, MUESTRO EL 1 COMO ACTIVO Y MUESTRO EL RESTO DE PÁGINAS</span>
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 	<span style="color: #000000; font-weight: bold;">?&gt;</span>
      &lt;li class=&quot;previous-off&quot;&gt;&amp;laquo; Previous&lt;/li&gt;
      &lt;li class=&quot;active&quot;&gt;1&lt;/li&gt; <span style="color: #000000; font-weight: bold;">&lt;?</span>
	<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span> <span style="color: #000088;">$page</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">&lt;=</span> <span style="color: #000088;">$lastpage</span> <span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
			&lt;li&gt;&lt;a href=&quot;busquedas.php?page=<span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$i</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$i</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;&lt;/li&gt;
 <span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #009900;">&#125;</span>
       <span style="color: #666666; font-style: italic;">//Y SI LA ULTIMA PÁGINA ES MAYOR QUE LA ACTUAL MUESTRO EL BOTON NEXT O LO DESHABILITO</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lastpage</span> <span style="color: #339933;">&gt;</span><span style="color: #000088;">$page</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>		
      &lt;li class=&quot;next&quot;&gt;&lt;a href=&quot;busquedas.php?page=<span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$nextpage</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; &gt;Next &amp;raquo;&lt;/a&gt;&lt;/li&gt;<span style="color: #000000; font-weight: bold;">&lt;?</span>
	<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
	  &lt;li class=&quot;next-off&quot;&gt;Next &amp;raquo;&lt;/li&gt;
<span style="color: #000000; font-weight: bold;">&lt;?</span>	<span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">//EN CAMBIO SI NO ESTAMOS EN LA PÁGINA UNO HABILITO EL BOTON DE PREVIUS Y MUESTRO LAS DEMÁS</span>
	<span style="color: #000000; font-weight: bold;">?&gt;</span>
	 &lt;li class=&quot;previous&quot;&gt;&lt;a href=&quot;busquedas.php?page=<span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$prevpage</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;  &gt;&amp;laquo; Previous&lt;/a&gt;&lt;/li&gt;<span style="color: #000000; font-weight: bold;">&lt;?</span>
      <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">&lt;=</span> <span style="color: #000088;">$lastpage</span> <span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                       <span style="color: #666666; font-style: italic;">//COMPRUEBO SI ES LA PÁGINA ACTIVA O NO</span>
	  		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">?&gt;</span>	&lt;li class=&quot;active&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$i</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/li&gt;<span style="color: #000000; font-weight: bold;">&lt;?</span>
			<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">?&gt;</span>	&lt;li&gt;&lt;a href=&quot;busquedas.php?page=<span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$i</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; &gt;<span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$i</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;&lt;/li&gt;<span style="color: #000000; font-weight: bold;">&lt;?</span>
			<span style="color: #009900;">&#125;</span>
	  <span style="color: #009900;">&#125;</span>
         <span style="color: #666666; font-style: italic;">//Y SI NO ES LA ÚLTIMA PÁGINA ACTIVO EL BOTON NEXT		</span>
	  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lastpage</span> <span style="color: #339933;">&gt;</span><span style="color: #000088;">$page</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>	<span style="color: #000000; font-weight: bold;">?&gt;</span>	
      &lt;li class=&quot;next&quot;&gt;&lt;a href=&quot;busquedas.php?page=<span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$nextpage</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;Next &amp;raquo;&lt;/a&gt;&lt;/li&gt;<span style="color: #000000; font-weight: bold;">&lt;?</span>
	  <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">?&gt;</span> &lt;li class=&quot;next-off&quot;&gt;Next &amp;raquo;&lt;/li&gt;<span style="color: #000000; font-weight: bold;">&lt;?</span>
	  <span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span>	  
<span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/ul&gt;&lt;/div&gt;<span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #009900;">&#125;</span> 
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Seguramente esta última parte del codigo se pueda mejorar ya que la escribí un poco &#8220;rapido&#8221;, así que estoy abierto a sugerencias. De todas formas a mi me funciona todo correctamente. Espero que les haya servido de ayuda, ya que en su día me costo mucho encontrar un buen tutorial sobre la paginación y ninguno de los que encontre venia completo. Un saludo!!!</p>
<h4><a href="http://masquewordpress.com/ejemplos/paginacion.rar">Descargar ejemplo</a></h4>
<div class="avia-box alert    "><span class="avia-innerbox" ><a href="http://www.masquewordpress.com/paginacion-php-con-clase/">Nueva version usando una clase PHP</a></span></div>
<p><div style="float:left; text-align:left;><img alt='' src='http://1.gravatar.com/avatar/516ffa1373c8295d2e5ff5267fc53399?s=100&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D100&amp;r=G' class='avatar avatar-100 photo' height='100' width='100' /></div><h3><a href='http://www.masquewordpress.com/author/Damian/' title='Damian'>Damian</a></h3><p>Programador en tiempos libres , amante de la tecnología, blogger amateur y emprendedor en sueños.</p><p><a href='http://www.masquewordpress.com/author/Damian/' title='M&aacute;s post de Damian'>M&aacute;s Posts de Damian</a>  - <a href='http://www.timersys.com' title='Damian'>Web</a> </p><p class="wpa-nomargin">Sigueme:<br /><a class='wpa-social-icons' href='http://www.twitter.com/chifliiiii'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/twitter.png' alt='Twitter'/></a><a class='wpa-social-icons' href='http://www.facebook.com/pages/Timersys/146687622031640'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/facebook.png' alt='Facebook'/></a><a class='wpa-social-icons' href='http://ar.linkedin.com/pub/damian-logghe/26/173/321'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/linkedin.png' alt='LinkedIn'/></a></p></p>]]></content:encoded>
			<wfw:commentRss>http://www.masquewordpress.com/paginacion-con-php-y-mysql-3-estilos/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
		<item>
		<title>DB.php : Como definir los parametros de conexión de tu base de datos</title>
		<link>http://www.masquewordpress.com/dbphp-como-definir-los-parametros-de-conexion-de-tu-base-de-datos/</link>
		<comments>http://www.masquewordpress.com/dbphp-como-definir-los-parametros-de-conexion-de-tu-base-de-datos/#comments</comments>
		<pubDate>Sun, 24 May 2009 18:49:59 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[base de datos]]></category>

		<guid isPermaLink="false">http://masquewordpress.com/?p=58</guid>
		<description><![CDATA[En mis diseños siempre defino los valores de conexión a la base de datos en un archivo php llamado db.php  (database name, username, password, database host), de forma que cada vez que necesito conectarme tan solo tengo que hacer un include del mismo. Una vez que tengamos creado nuestra base de datos a traves de [...]]]></description>
			<content:encoded><![CDATA[<p>En mis diseños siempre defino los valores de conexión a la base de datos en un archivo php llamado <strong>db.php</strong>  (database name, username, password, database host), de forma que cada vez que necesito conectarme tan solo tengo que hacer un include del mismo.</p>
<p>Una vez que tengamos creado nuestra base de datos a traves de phpMyAdmin o desde nuestro gestor en el hosting, tan solo tenemos que crear este archivo, que es muy sencillo y solo ocupa unas lineas.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #666666; font-style: italic;">//datos de conexion que hay que editar con los que corresponda</span>
<span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DB_IP'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'localhost'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DB_USER'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'unnombredeusuario'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DB_PASS'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'unpassword'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DB_NAME'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'nombredelabasededatos'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">// Funcion que vamos a usar para realizar la conexion (Acá no se edita nada)</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #000000; font-weight: bold;">function</span> get_db_conn<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$conn</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DB_IP'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DB_USER'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DB_PASS'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DB_NAME'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;No pudo conectarse a la BD: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$conn</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Con eso ya tendriamos los datos de conexión listos, aunque yo siempre agrego una pequeña funcion para proteger los datos de inyección SQL (o como dicen en ingles SQL INJECTIONS).Por lo que me aseguro que cada vez que carga una conexion , cargo también la funcion que me va a ayudar a protegerme.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//PARA PROTEGER SQL INJECT</span>
<span style="color: #000000; font-weight: bold;">function</span> cleanQuery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">get_magic_quotes_gpc</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>   <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">phpversion</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;=</span> <span style="color: #0000ff;">'4.3.0'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$string</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Por lo tanto nuestro archivo db.php queria de la siguiente manera:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DB_IP'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'localhost'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DB_USER'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'unnombredeusuario'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DB_PASS'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'unpassword'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DB_NAME'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'nombredelabasededatos'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">// Database queries</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #000000; font-weight: bold;">function</span> get_db_conn<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$conn</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DB_IP'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DB_USER'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DB_PASS'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DB_NAME'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;No pudo conectarse a la BD: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$conn</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//PARA PROTEGER SQL INJECT</span>
<span style="color: #000000; font-weight: bold;">function</span> cleanQuery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">get_magic_quotes_gpc</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>  <span style="color: #666666; font-style: italic;">// prevents duplicate backslashes</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">phpversion</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;=</span> <span style="color: #0000ff;">'4.3.0'</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$string</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Una vez armado el db.php , solo nos queda incluirlo en nuestras páginas. y lo haremos de la siguiente manera:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'config.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Una vez incluido nuestro archivo podemos realizar una nueva conexión de la siguiente forma:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//Creamos la variable $conn y le asignamos la conexión a la base de datos</span>
<span style="color: #000088;">$conn</span><span style="color: #339933;">=</span>get_db_conn<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>La función <strong>cleanQuery</strong> la vamos a usar para &#8220;limpiar&#8221; las variables. Si juntamos todo los visto anteriormente y suponiendo que tenemos un archivo llamado busquedas.php al cual le pasamos una variable $_GET['pelicula'] podriamos dejar el código de la siguiente manera:</p>
<p>EJ:<strong>busquedas.php?pelicula=killBill</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'config.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$conn</span><span style="color: #339933;">=</span>get_db_conn<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$nombrePelicula</span><span style="color: #339933;">=</span> cleanQuery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'pelicula'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$consulta</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;SELECT * FROM peliculas WHERE nombre='<span style="color: #006699; font-weight: bold;">$nombrePelicula</span>'&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$peliculas</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$consulta</span><span style="color: #339933;">,</span> <span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$peliculas</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
 <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Invalid query: '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">//la consulta se ejecuto correctamente y mostramos los datos</span>
   <span style="color: #000000; font-weight: bold;">?&gt;</span> &lt;table&gt;&lt;thead&gt;
        &lt;tr&gt;&lt;th&gt;Título&lt;/th&gt;&lt;th&gt;Director&lt;/th&gt;&lt;th&gt; Año de producción&lt;/th&gt;&lt;/tr&gt;
        &lt;/thead&gt;
        &lt;tbody&gt;
    <span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> mysql_fecth_assoc<span style="color: #009900;">&#40;</span><span style="color: #000088;">$peliculas</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>  <span style="color: #000000; font-weight: bold;">?&gt;</span>
        &lt;tr&gt;&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'nombre'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> &lt;/td&gt;&lt;td&gt; <span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'director'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> &lt;/td&gt;&lt;td&gt; <span style="color: #000000; font-weight: bold;">&lt;?</span><span style="color: #b1b100;">echo</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'año'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> &lt;/td&gt;&lt;/tr&gt;
       <span style="color: #000000; font-weight: bold;">&lt;?</span>  <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
      &lt;/tbody&gt;
      &lt;/table&gt;</pre></td></tr></table></div>

<p>Esta sería la forma sencilla de configurar las conexiones a una base de datos. Por favor comenten cualquier duda que vaya surgiendo. Un Saludo</p>
<h4><a href="http://masquewordpress.com/ejemplos/db.rar">Descargar db.php</a></h4>
<p><div style="float:left; text-align:left;><img alt='' src='http://1.gravatar.com/avatar/516ffa1373c8295d2e5ff5267fc53399?s=100&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D100&amp;r=G' class='avatar avatar-100 photo' height='100' width='100' /></div><h3><a href='http://www.masquewordpress.com/author/Damian/' title='Damian'>Damian</a></h3><p>Programador en tiempos libres , amante de la tecnología, blogger amateur y emprendedor en sueños.</p><p><a href='http://www.masquewordpress.com/author/Damian/' title='M&aacute;s post de Damian'>M&aacute;s Posts de Damian</a>  - <a href='http://www.timersys.com' title='Damian'>Web</a> </p><p class="wpa-nomargin">Sigueme:<br /><a class='wpa-social-icons' href='http://www.twitter.com/chifliiiii'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/twitter.png' alt='Twitter'/></a><a class='wpa-social-icons' href='http://www.facebook.com/pages/Timersys/146687622031640'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/facebook.png' alt='Facebook'/></a><a class='wpa-social-icons' href='http://ar.linkedin.com/pub/damian-logghe/26/173/321'><img src='http://www.masquewordpress.com/wp-content/plugins/wp-about-author//images/linkedin.png' alt='LinkedIn'/></a></p></p>]]></content:encoded>
			<wfw:commentRss>http://www.masquewordpress.com/dbphp-como-definir-los-parametros-de-conexion-de-tu-base-de-datos/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

