1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| if(preg_match_all(
'#<a href="fiche-video.php\?id=([0-9]+)">(.+)</a>#Usi',
$contents,
$matches,
PREG_PATTERN_ORDER))
{
array_multisort($matches[1], SORT_ASC, SORT_NUMERIC, $matches[0], $matches[2]);
$id_list = implode(',', $matches[1]);
$sql = 'SELECT `id`,`nom` FROM `videos` WHERE `id` IN ('.$id_list.') ORDER BY id';
$result = sql_query($sql,'AFFICHE TITRE VIDEO POUR REWRITING');
$article_id_sql = NULL;
foreach ($matches[0] as $i => $pattern)
{
$article_id = $matches[1][$i];
$anchor = $matches[2][$i];
// si on n'est pas sur le bon article, on avance d'un enregistrement sql
if ($article_id_sql >= $article_id)
{
$article = mysql_fetch_assoc($result))
$article_id_sql = $article['id'];
}
// maintenant on devrait avoir le bon id, sinon, c'est que la requête n'a rien ramené pour cet id
if ($article_id_sql == $article_id)
{
//...
}
}
} |
Partager