Ver Mensaje Individual
  #4 (permalink)  
Antiguo 01/08/2008, 18:24
klaudia_ru
 
Fecha de Ingreso: septiembre-2006
Mensajes: 41
Antigüedad: 17 años, 7 meses
Puntos: 0
Respuesta: PHP Generator for MySQL

este es el codigo php
Cita:
<?php
for ($i = $startrec; $i < $reccount; $i++)
{
$row = mysql_fetch_assoc($res);
$style = "dr";
if ($i % 2 != 0) {
$style = "sr";
}
?>
<tr>
<td class="<?php echo $style ?>"><?php echo build_link("http://localhost/imagen/imagen/", htmlspecialchars($row["id"]), ".php", "", outimage($i, "ima", "20", "", "")) ?></td>
</tr>
<?php
}
mysql_free_result($res);
?>
y las funciones son:
Cita:
function outimage($recid, $field, $alt, $width, $height)
{
$res = "<img src=\"ima.php?getimage=$recid&field=$field\" border=0 alt=\"$alt\"";
if ($width <> '')
$res = $res." width=\"$width\"";
if ($height <> '')
$res = $res." height=\"$height\"";
$res = $res.">";
return $res;
}

function getimage($recid, $field)
{
$res = sql_select();
mysql_data_seek($res, $recid);;
$row = mysql_fetch_assoc($res);
echo $row[$field];
}

function build_link($prefix, $href, $suffix, $target, $content)
{
if ($href == '')
{
$res = $content;
}
else
{
$res = "<a href=\"".$prefix.$href.$suffix."\" target=\"".$target."\">".$content."</a>";
}
return $res;
}