I have a code like so.
function tutorial_type() {
$output = '';
$select_types = db_query("SELECT vid, name, description FROM {vocabulary} ORDER BY weight DESC");
while ($termshow = db_fetch_object($select_types)) {
$newid = $termshow->vid;
echo $newid;
$output .= 'vid.'">'.$termshow->name.' [0]
'.$termshow->description.'
';
$result = db_query("SELECT tid, name FROM {term_data} WHERE tid=$newid");
while ($term = db_fetch_object($result)) {
$output .= 'tid.'">'.$term->name.' ';
}
unset($newid);
$output .= '
';
}
return $output;
}
Problem is it gets the correct id for this part.
$output .= 'vid.'">'.$termshow->name.' [0]
'.$termshow->description.'
';
But this one
$newid = $termshow->vid;
echo $newid;
is echoing vid: 65 even though there is no fields number 65 only 6 and 5.
Comments
A pointer and a guess
First when posting code it helps to place it in code tags like this <code>your code</code> so it easier to read.
As for your problem, I think the code is working fine. If you replace the
echo $newidwithdrupal_set_message("The vid is $newid");you should see two seperate messages. Since your code is echoing $newid, it echos the first one followed by the second one with nothing inbetween so you are seeing them "pasted" together when they appear on the screen.My bad, sorry. I got it
My bad, sorry.
I got it working now, thanks.