By oskar_calvo on
this is the code.
<?php
function crearArbol($id_field,$show_data,$link_field,$parent,$prefix){
/*Armar query*/
$sql='SELECT distinct d.name, d.tid FROM term_data d, term_node dn, node nt, term_hierarchy th WHERE dn.tid = d.tid AND d.vid =3 AND nt.type = 'manualbp' AND nt.nid = dn.nid and '.$link_field.'='.$parent;
/*Asumiendo que se usa MySQL (se puede cambiar facilmente a otra db)*/
if ($parent != 0 && $prefix == '') $prefix = '--';
$rs=@mysql_query($sql);
if($rs){
/*Recorrer todos las entradas */
while($arr=mysql_fetch_array($rs)){
/* Imprimir campo a mostrar*/
echo('<option value="' . $arr[$id_field] . '">' . $prefix . $arr[$show_data] . '</option>' . chr(13));
//echo($prefix.$arr[$show_data].'<br>');
/* imprimir arbol the "hijos" de este elemento*/
crearArbol($tabla,$id_field,$show_data,$link_field,$arr[$id_field],$prefix.$prefix);
}
}
}
?>
<?php
echo chr(13);
crearArbol('d.tid','d.name','th.parent',0,'');
?>
the error is this:
Parse error: syntax error, unexpected T_STRING in /var/www/drupal/includes/common.inc(1347) : eval()'d code on line 4
Can someone explain me what's wrong?
thanks
Oskar
Comments
Line 4 should read
Line 4 should read as
--
Cheers,
Sivanandhan, P. (a.k.a. apsivam)
thanks.
thanks apsivam, I don't read now no error, but I doesn't show nothing.
oskar
gestión del conocimiento y de la información con software libre
Tip: Use Drupal's Database Abstraction Layer
I see you are creating your own database connection and accessing the database directly--that's a no-no when it comes to Drupal development.
Drupal has it's own database access http://drupal.org/node/101496 layer that provides access to the Drupal database plus lots of nifty features like a pre-exisiting database connection and SQL sanitization to prevent SQL injection attacks. It won't fix your syntax error--but if you are a begiing Drupal developer, you might want to start out on the right track... and save yourself some time rewriting code that is already available for you to use.
John Berns
Travel Guide
Travel Photographer
also don't forget to do a
also don't forget to do a check_plain() on all data which you can't trust. example: $arr[$show_data] should be check_plain($arr[$show_data])
If anyone want to help me will be great.
My idea is to take a list of term that are working with some nodes, and mix with another term.
The idea is to take a menu that show me the
/taxonomy/term/1,322 (father term)
--/taxonomy/term/11,322 (son term)
--/taxonomy/term/12,322 (son term)
/taxonomy/term/2,322 (father term)
/taxonomy/term/3,322 (father term)
etc...
I think that the function and query should be like those:
Thanks.
Oskar
gestión del conocimiento y de la información con software libre