0

I have a table of data that includes picture and video which the files are saved in Eventpic folder in my localhost, I need the picture and video in table to show the file when user clicked on them; this code refer to the eventpic not each individual pic.

$sqlget="SELECT * FROM eventform";
      $sqldata=mysqli_query($con,$sqlget)
      or die("Error Getting Data");
      echo "<table border=2 bordercolor=#440000 cellpadding=2 bgcolor=#DDDDDD width=100%>";
      echo "<tr bgcolor=#555555 style=font-size:18px><th>Event Code</th><th>Event Name</th><th>Event Type</th><th>Event Level</th><th>Start Date</th>
      <th>End Date</th><th>Point</th><th>Picture</th><th>Video</th><th>Description</th></tr>";



      while($row=mysqli_fetch_array($sqldata, MYSQLI_ASSOC)){
          echo "<tr align=center><td>";
          echo $row['event_code'];
          echo "</td><td>";
          echo $row['event_name'];
          echo "</td><td>";
          echo $row['event_type'];
          echo "</td><td>";
          echo $row['event_level'];
          echo "</td><td>";
          echo $row['start_date'];
          echo "</td><td>";
          echo $row['end_date'];
          echo "</td><td>";
          echo $row['points'];
          echo "</td><td>";
      echo "<a href=http://localhost/greenstudio/eventpic/>".$row['pic']."</a>"; >>> PRoblem is here
          echo "</td><td>";
          echo $row['video'];
          echo "</td><td>";
          echo $row['description'];
          echo "</td></tr>";


      }

       echo "</table>";
      ?>

======My table =====

$pic= ($_FILES['pic']); 
  $temp_pic=($_FILES["pic"]["tmp_name"]);
  $pic_type=($_FILES["pic"]["type"]);
  $pic_name=($_FILES["pic"]["name"]);
  $pic_size=($_FILES["pic"]["size"]);
  $pic_error=($_FILES["pic"]["error"]);
  $temp_video=($_FILES["video"]["tmp_name"]);
  $video_type=($_FILES["video"]["type"]);
  $video_name=($_FILES["video"]["name"]);
  $video_size=($_FILES["video"]["size"]);
  $video_error=($_FILES["video"]["error"]);
$uploads_dir_pic = "eventpic/".$pic_name;
  $uploads_dir_video="videos/".$video_name;
if($pic_size>1000000){
              die ("The size of the pic is too big");

                  }
                  if($video_size>5000000){
              die ("The size of the video is too big");

                  }

      move_uploaded_file($temp_pic,$uploads_dir_pic);
      $path_pic=($uploads_dir_pic);
      }
      move_uploaded_file($temp_video,$uploads_dir_video);
      $path_video=($uploads_dir_video);
INSERT $path_pic & $path-video in database
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Shane
  • 25
  • 11

2 Answers2

0

Can you try this,

  echo "<a href='http://localhost/greenstudio/eventpic/".$row['pic']."' >".$row['pic']."</a>"; 

OR

  echo "<a href='eventpic/".$row['pic']."' >".$row['pic']."</a>"; 
Krish R
  • 22,583
  • 7
  • 50
  • 59
0

create a separate script that loads the image from the database
Set header for image

header("Content-type: image/png");

Here's something similar How to retrieve images from MySQL database and display in an html tag

Community
  • 1
  • 1
Mario Segura
  • 325
  • 1
  • 8