Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/08/2008, 14:59
mvlsistemas
 
Fecha de Ingreso: mayo-2004
Mensajes: 903
Antigüedad: 20 años, 9 meses
Puntos: 4
APORTE: Mostrar video de you tube con registro en bd

Hola buena gente, sepan disculpar la humildad del intento de aporte pero me ha sido útil.

Insertas un registro con la url de you tube y lo mostras en tu web.

creas una tabla videos con el campo dirección y luego insertas desde form.php la url.

Código:
<form action="insert.php" method="post">
  URL YOU TUBE

    <input type="text" id ="direccion" name="direccion" >

  

    <input name="submit" type="submit" value="Enviar!">

</form>
luego el insert.php lo guarda en la tabla videos.

Código PHP:
<?php 
   
$direccion 
$_POST['direccion'];

include (
'cone.php'); 
//Ejecucion de la sentencia SQL 

mysql_query("insert into videos (direccion) values ('$direccion')",$enlace); 

?>
y lo mostramos con mostrar.pfp

Código PHP:
<table width="1003" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <!--DWLayoutTable-->
  <tr valign="top">
    <td width="657" height="16"><?php
$id
=$_POST[id];
include (
'cone.php');  
 
$_pagi_sql =("SELECT id,direccion From videos WHERE id ='$id'");
 
//cantidad de resultados por p&aacute;gina (opcional, por defecto 20)
$_pagi_cuantos 1
//Incluimos el script de paginaci&oacute;n. &Eacute;ste ya ejecuta la consulta autom&aacute;ticamente
include("paginator.inc.php");
while (
$registro mysql_fetch_array($_pagi_result)) {
?>
      <table width="614" align="center" cellpadding="4" cellspacing="4" bgcolor="#EEEEEE">
        <tr align="center" bgcolor="#000000">
          <td width="1384" colspan="6"><?php 
          $direccion 
$_POST['direccion'];
          if(
$registro['direccion']){
    
$video str_replace("http://www.youtube.com/watch?v=","http://www.youtube.com/v/",$registro['direccion']);
    echo 
'<object width="425" height="350">';
    echo 
'<param name="movie" value="'.$video.'"></param>';
    echo 
'<param name="wmode" value="transparent"></param>';
    echo 
'<embed src="'.$video.'" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed>';
    echo 
'</object>';
    }
    

?></td>
        </tr>
        <tr>
          <td colspan="6" valign="top"><HR size="1">
              <p>&nbsp;
      </p>
              <p> </td>
        </tr>
      </table>
    <?php
}
?></td>
  </tr>
</table>
cone.php

Código PHP:
<?php    
// Conexion, seleccion de base de datos
$enlace mysql_connect('localhost''user''pass')
   or die(
'No pudo conectarse : ' mysql_error());
mysql_select_db('name_base') or die('No pudo seleccionarse la BD.');


?>
paginator.inc.php es el de J. pinedo esta en el foro creo

Última edición por mvlsistemas; 25/08/2008 a las 15:19