Ver Mensaje Individual
  #20 (permalink)  
Antiguo 07/09/2011, 12:13
Tunnecino
 
Fecha de Ingreso: julio-2011
Mensajes: 22
Antigüedad: 12 años, 10 meses
Puntos: 2
Respuesta: Sistema de Quotes #Post

Es que tengo que anidar funciones o si no, ya me dirás tu como envío la id de la noticia por cada post.

Edit:

Al final, algo así termina de funcionarme :D

Código:
function BBCodeExpand($string, $idn) {
	GLOBAL $idn;
	function mi_callback($match){
		return ProcessQuote($match[1], $GLOBALS['idn']); // el número
	}	
	function ProcessQuote($match, $idn){
		# Buscamos el post del quote
		ConexionDB();
		# Get Relacionadas
		$query = mysql_query('SELECT mensaje FROM noticias_comentarios WHERE idn = "'.$idn.'" AND idp = "'.$match.'"');
		$check = mysql_num_rows($query);
		if($check == 0) {
			return '<a class="tooltip" href="#'.$match.'" ref="El mensaje #'.$match.' no existe"><strong>#'.$match.'</strong></a>';
		}else{
			$fetch = mysql_fetch_array($query);
			return '<a class="tooltip" href="#'.$match.'" ref="'.$fetch['mensaje'].'"><strong>#'.$match.'</strong></a>';
		} 
	}	
	$string = preg_replace_callback('/#(\d+)\b/', 'mi_callback', $string);
	return $string;	
}

echo BBCodeExpand($string, $idn);
Gracias por todo! :D