martes, 25 de septiembre de 2007

fecha de hoy, dia de hoy

<?

echo date("d/m/Y");

?>

VER URL

martes, 18 de septiembre de 2007

Hacer un href enlace con un div

<div onclick="javascript:location.href='http://www.ua.es';" style="width: 80px; height: 20px; cursor: pointer">
</div>

lunes, 17 de septiembre de 2007

EDITAR subiendo un fichero

//********** UPDATE

// si hay imagen la sube
$fichero="";
$enquery="";

$dir = "../cliente/descargas/"; // directorio donde se sube el fichero POST
$nombrefichero="fichero"; // nombre de la variable del fichero POST
$tamanyoimagen=200; // tamaño a redimensionar
$lado="w"; // w HORIZONTAL, h VERTICAL
$redimensiona="no"; // si PARA SI, no PARA NO
$variableentabla="descfichero"; // nombre del fichero en la tabla
$variabledeborrado="borrarfichero"; // nombre de varible de BORRAR el fichero
$valorvariableborradosi="1"; // valor de la varibale POST de borrar
$valorvariableborradono="0"; // valor de la varibale POST de NO borrar


// mira si habia un fichero antes
$query="SELECT * from descargas where descid='".$_POST['id']."'";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result) or die(mysql_error());
$ficheroantiguo=$row[$variableentabla];


if (is_uploaded_file($_FILES[$nombrefichero]['tmp_name']))
{

// si habia un fichero antiguo lo borra
if ($ficheroantiguo!="")
{
$borrar = $dir.$row[$variableentabla];
unlink($borrar);
}
//***

// sube el nuevo fichero con la ID delante del nombre
$nombre = $_FILES[$nombrefichero]['name'];
$fichero=$_POST['id'].$nombre;
$temp = $dir.$fichero;

move_uploaded_file($_FILES[$nombrefichero]['tmp_name'], $temp);

if ($redimensiona=="si")
redimensionar_ok($temp2, $temp2, $lado, $tamanyoimagen);

$enquery=",".$variableentabla."='".$fichero."'";
}
else // SI NO SUBE FICHERO
{

// si se quiere borrar el antiguo sin subir ninguno
if ($_POST[$variabledeborrado]==$valorvariableborradosi)
{

// si habia un fichero antiguo lo borra
if ($ficheroantiguo!="")
{
$borrar = $dir.$row[$variableentabla];
unlink($borrar);
}
//***

$fichero="";

$enquery=",".$variableentabla."=''";
}

// si NO se quiere borrar el antiguo sin subir ninguno
if ($_POST[$variabledeborrado]==$valorvariableborradono)
{
$enquery="";
}
}



$query="UPDATE descargas set `desctitulo_es`='".$_POST['tituloes']."',`desctitulo_en`='".$_POST['tituloen']."',`desctitulo_va`='".$_POST['titulova']."' ".$enquery." where `descid`='".$_POST['id']."'";
$result = mysql_query($query) or die(mysql_error());

miércoles, 12 de septiembre de 2007

Imprimir pantalla Javascript

<SCRIPT LANGUAGE="javascript" TYPE="text/javascript">

function imprimir()
{
if (window.print)
{
window.print();
}
}

</SCRIPT>



<a href="javascript:imprimir()" class="enlace" title='Imprimir pantalla' onMouseOut="window.status=''; return true;" onMouseOver="window.status='Imprimir pantalla'; return true;">Imprimir pantalla</a>

redireccionar automaticamente

//***** en HTML

<META HTTP-EQUIV="Refresh" CONTENT="0; URL=http://www.google.es">




//***** en PHP

header ("Location: http://www.google.es");

lunes, 10 de septiembre de 2007

Combobox relacionados dinamicos entre si

<script language="javascript">

function setOptions(chosen)
{
var selbox = document.miformu.opttwo;

selbox.options.length = 0;

if (chosen == " ")
{
selbox.options[selbox.options.length] = new Option('Please select one of the options above first',' ');
}

if (chosen == "1")
{
selbox.options[selbox.options.length] = new Option('first choice - option one','oneone');
selbox.options[selbox.options.length] = new Option('first choice - option two','onetwo');
}

if (chosen == "2")
{
selbox.options[selbox.options.length] = new Option('second choice - option one','twoone');
selbox.options[selbox.options.length] = new Option('second choice - option two','twotwo');
}

if (chosen == "3")
{
selbox.options[selbox.options.length] = new Option('third choice - option one','threeone');
selbox.options[selbox.options.length] = new Option('third choice - option two','threetwo');
}

}
</script>


<form name="miformu">
<div align="center">
<select name="optone" size="1" onchange="setOptions(document.miformu.optone.options[document.miformu.optone.selectedIndex].value);">
<option value=" " selected="selected"> </option>
<option value="1">First Choice</option>
<option value="2">Second Choice</option>
<option value="3">Third Choice</option>
</select>

<br><br>

<select name="opttwo" size="1">
<option value=" " selected="selected">Please select one of the options above first</option>
</select>

<input type="button" name="go" value="Value Selected" onclick="alert(document.miformu.opttwo.options[document.miformu.opttwo.selectedIndex].value);">
</div>
</form>

jueves, 6 de septiembre de 2007

enlace href en un area de una imagen

<img src="../imagenes/contacto.png" USEMAP="#mapa1" border="0">

<MAP NAME="mapa1">
<AREA SHAPE=rectangle COORDS="0,125,325,155" HREF="mailto:<?echo $row['paremail'];?>" ALT="Email">
<AREA SHAPE=rectangle COORDS="0,235,325,280" HREF="somos.php?seccion=formulario" ALT="Email">
</MAP>

VER CODIGO EN URL