D
D
Dmitry2021-09-06 15:51:25
PHP
Dmitry, 2021-09-06 15:51:25

How to select a specific row from Mysql?

Good afternoon, developers, please tell me how to implement this, I have never encountered this before, I have been working for only a month and I have been studying for six months, but this is the first time. There is a base (let it be params), it has a column (let it be full) it has a large description of the product and somewhere in all this description there is

<iframe width="560" height="315" src="https://www.youtube.com/embed/IGuHlPNioRk" frameborder="0" allowfullscreen></iframe>

I need to write a script that will run through all these full columns and select the IGuHlPNioRk code and write it to another table, I don’t even know where to start and how to write. who can push the idea and suggest how to be thank you very much.
I understand that you need to use preg_match but I don’t know what to write,
$req = mysqli_query(DB::db(), 'SELECT id,full FROM params WHERE id=247397');
// var_dump($req);
while( $row = mysqli_fetch_assoc( $req ) ){
  $data = [];

  if(preg_match('/< *iframe[^>]*src *= *["\']?([^"\']*)/i', $row['full'], $matches)){

    $full = $row['full'];
    var_dump($full);
  }
  
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Akina, 2021-09-06
@Akina

SELECT SUBSTRING_INDEX(SUBSTRING(full FROM 30 + LOCATE('https://www.youtube.com/embed/', full)), '"', 1)
FROM params
WHERE LOCATE('https://www.youtube.com/embed/', full)
-- AND id=247397

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question