Kwanhee Hwang
Kwanhee Hwang

Reputation: 47

how to make link button on result(video_title) from sql db to show video_link?

https://www.webslesson.info/2016/05/how-to-search-multiple-words-at-a-time-in-mysql-php.html

on this site showing example of How to search multiple words at a time in Mysql ph and i want to make an improve to this example. like after showing reuslt of (video_title) if i click on result(video_title) it shows www.whatever.com(video_link).

$condition = substr($condition, 0, -4);
                      $sql_query = "SELECT * FROM tbl_video WHERE " . $condition;
                      $result = mysqli_query($connect, $sql_query);
                      if(mysqli_num_rows($result) > 0)
                      {
                           while($row = mysqli_fetch_array($result))
                           {
                                echo '<tr><td>'.$row["video_title"].'</td></tr>';
                           }
                      }
                      else
                      {
                           echo '<label>Data not Found</label>';
                      }
                 }

Upvotes: 0

Views: 37

Answers (1)

Eiji
Eiji

Reputation: 453

I guess your column name is video_link So you should modify the echo line with

 echo '<tr><td><a href="' . $row["video_link"] . '">' . $row["video_title"] . '</a></td></tr>';

With your optional text :

if( !empty($row) ){
    echo '<tr><td><a href="' . $row["video_link"] . '">' . $row["video_title"] . $row["video_optionnal_text"] . '</a></td></tr>';
} else {
    echo '<tr><td><a href="' . $row["video_link"] . '">' . $row["video_title"] . '</a></td></tr>';
}

Upvotes: 1

Related Questions