The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Dynamic vBgarage images..
I'm helping a friend who has VBUlletin 3.0 installed and I'm trying to pull a random image from the database.
The way I set it up was by adding a snippet of code to one of the garage templates and inserting a random number for the image ID. Well this works when the number coincides with an actual image ID, but when it doesn't, I get the dreaded "Red X". So what I decided to do now was query the db, create an array out of the entire vbgarageid field, then use my random number as an index for the array. Needless to say, I tried this and could not get it to work correctly. I think mainly because I'm trying to create an array out of the entire field, as opposed to a single row. Here's the link: http://www.lincolnvscadillac.com/vbgarage.php Any help on how to solve this problem is appreciated. Kale |
#2
|
||||
|
||||
Questions about modifying vBulletin's default behaviour and asking about modifications in general, should be posted in General vBulletin Questions. Please read the forum descriptions more carefully in future. I've moved your thread there for you
Thanks, - Dean |
#3
|
||||
|
||||
Here's a simple database TABLE, to make you understand how it all works, cause what you're saying doesn't make sense:
_____|fielda| fieldb| rowa | x | z | rowb | y | q | when you select something from the db, you either select one row (query_first) or more rows (query) you'll then get an array, the array being the row selected... the key is the field name and the value is the actual entry for that row. to query the above table and get the x value i'd do: $a = $DB_site->query_first("SELECT * FROM table WHERE fielda='x'"); to get the x value then use: $a['fielda']; Hope this makes you understand it better. |
#4
|
|||
|
|||
Yeah, that's the problem with this method, I can grab ROW data, but not COLUMN data...
There's probably a better, simpler way to do this, I just haven't found it yet. Kale |
#5
|
||||
|
||||
now if i understand properly, this should work....
SELECT * FROM table ORDER BY RAND() and you use $a['mycolumn'] to get your random field... |
#6
|
|||
|
|||
What I ended up doing was connecting to the db and selecting the garage ID based upon the random number. Then I looked for a match by counting the number of records. If I've got at least one row, cool, the ID is valid. If not it loops...
Kale |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|