hiii

i want to share a video link from youtube in textarea and show on the div ,when im share embeded code from youtube it showed on the div but when im share the link ,it only show the link so how i ll i share link in same way as embedeb code ??

<?php
(isset($_SESSION['email_id']))
{
  echo $_SESSION['email_id'];
  $u_id=$_SESSION['email_id'];
}
  $sql="select * from post where post_id='$user_id'";
$result=mysql_query($sql);
$total_description=mysql_num_rows($result);
//$user_id=$_SESSION['email_id'];
 while($row=mysql_fetch_array($result))
    { $description=$row['description'];
     //$user_name=$row=['fname'];
      $user_name=$row['name'];
      $user_lname=$row['lname'];
      $user_email=$_SESSION['email_id'];
     } 
$description="";
if(isset($_POST['submit']))
{
$date=@date('Y-m-d H-i-s');
$description=$_POST['description'];$_SESSION['email_id']=$user_id;
$user_name=$row['name'];
$user_lname=$row['lname'];
$post="INSERT INTO `post`(`post_id`,`comment_id`,`user_id`,`description`,`date`) VALUES(NULL,0,'$user_id','$description','$date')";
 $result1=mysql_query($post);
 //echo $result;
 if(!$result)
 {
  die(mysql_error());
 }
}
?>


//and the div where it show
<div class="posted">
       <?php  echo "$user_name"." "."$user_lname";?>
        <?php echo $description;?> 


            </div>
Member Avatar for diafol

You can set up your table to just hold the video identifier, e.g. Ujwod-vqyqA
You can then build the embed link dynamically through php.

$videoframe = "<iframe width=\"560\" height=\"315\" src=\"http://www.youtube.com/embed/$video_id\" frameborder=\"0\" allowfullscreen></iframe>";

This has the advantage of not having to update ALL your video embed codes in a table if you want to change say the dimensions or if, perish the thought, YT decide to change the format of its embed code (can't see that happening though).

Example:

VIDEOS TABLE

video_id [32]
video_identifier [Ujwod-vqyqA]
video_type_id [2]

EMBED_CODES TABLE

video_type_id [2]
video_supplier [YouTube]
embed_code [<iframe width="560" height="315" src="http://www.youtube.com/embed/#VIDEO#" frameborder="0" allowfullscreen></iframe>]

You then replace the #VIDEO# string with video_identifier, e.g. str_replace()

BTW:
Your import code for the textarea can strip the embed code to leave just the video_identifier before inserting it into the DB. You could use regex for this (based on the 'src=').

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.