PDA

View Full Version : Over my head??


jsell
09-06-2002, 03:33 PM
Hey everyone first of all i would like ot thank you in advance for the help but here it goes

i am trying to hack my own "admin Recommended" type of hack where I replace the post icon's with a yes or a no icon at my choosing. I want it to show up in the forumdisplay when i choose if i want to reccomend the thread or not. I have everything working except it doesn;t diplay the icon's correctly. obviously there is soemthing wrong with my code. I am pretty new to php and to Vbulletin so please go easy one me.


// reco hack

unset($recodata);
unset($reco);



$recodata=$DB_site->query("SELECT reco from recodata data WHERE threadid='$threadid'");

if (($recodata[recomend]==1)) {
eval("\$reco= \"".gettemplate("reco_yes")."\";");

} else {

eval("\$reco= \"".gettemplate("reco_no")."\";");
}
}



//end add reco hack



above is the code i am using in forumdisplay.php

what happens is that is displays only the "reco_no" template

it's like it's either not getting the info from the query or it's using the same info for every thread (i think)

can some one please help

again thanks

Jsell

Velocd
09-07-2002, 04:42 AM
Try this jsell:


// reco hack

$recodata=$DB_site->query("SELECT reco FROM recodata WHERE threadid='$threadid'");

if ($recodata[reco]==1) {
eval("\$reco= \"".gettemplate("reco_yes")."\";");

} else {

eval("\$reco= \"".gettemplate("reco_no")."\";");
}

//end add reco hack


Youre problem was that you were not getting the values of the query into an array. Whenever you create a array from a query, you must put it in $array[element] form. "element" is usually the name of the column selected in the array. You had a number of small syntax errors in the code.

Also, because this is getting values of many threads, you need to put the code in a while loop, and fetch or extract the array. This while loop has already been made in forumdisplay.php ofcourse.

So in forumdisplay.php, find:

while ($thread=$DB_site->fetch_array($threads)) { // and $counter++<$perpage) {


And below it place your code.

Try the above code, I hope it works since I'm not all that sure what you are doing. ;)

jsell
09-07-2002, 03:49 PM
Thanks for your help Velocd but there is still a problem:

let me try a more detailed explination and tell you some more test's I have run

What i have done is I added a input field in "showthread" where I can select yes/No for if I recomend a thread to a user to read. For now I am going to replace the message icon with a yes/no icon in the forum display (later I will add a new box in the table for it so I have both icon's) evrythign is wokring except the forum display in thee database if I choose "yes" it enters a value of 1 if i choose "no" i enters a value of 2 etc.

what happens when i enter the code in "forumdisplay.php" your's or mine, is that every thread show's the same icon the icon inside the "reco_no" template.

So to try to test this in the forumdisplaybit template i put the variable $recodata[reco] and it comes up as a blank for every thread even though the database has value's for all of them

My conclusion:

that for some reason the Query is not getting the info form the database (double and triplechecked the table names etc. ) but I can't figure out why it's doing that maybe the

WHERE threadid='$threadid'

part is incorrect but i can't find diferent variable to use

jsell

jsell
09-09-2002, 12:07 AM
Thanks for the help I found a workaround for this that does what i need

jsell