Jump to content
Sign in to follow this  
scoobs

Random Showroom Generator

Recommended Posts

Ok, as another effort to find some of the treasures buried within TC I wrote a quick and hacky random showroom generator - every time you click the link in the left frameset, it goes to a random TC entry in the right, and it works really well, as I'm finding stuff I would normally never look at...

Soooo, Chris, might be a nice little function to build into TC. If you are lacking in inspiration, users can click on the randomiser and maybe find something interesting...

Share this post


Link to post
Share on other sites

Without access to the db I can't do it properly - like I say, it was a 2 minute hacky job, I just generate a random number between 1 and the current max showroomID (36,000 or so) and redirect to the showroom page with the random id parameter.

10-20% of these won't work as the showroom entry has been deleted - TC will just redirect to the homepage.

To do it properly you need db access and generate a random db record - seed and generate a random number between 1 and num_showroom_records and return that row - this will always give a valid showroom then.

You could also expand it, only return NIB entries, or favourites, or action photos by having a default flipmenu or something.

Anyway if you want to play with mine (oo-er!), I've uploaded a copy to: http://www.benhall.co.uk/tamiya/tc1.php

PHP code for the random frame is just:


<?php

srand((double)microtime()*1000000);	    seed the random number generator

$id = rand(1,36997);								 generate random number between 1 and 36000ish

header ("Location: http://www.tamiyaclub.com/showroom_model.asp?cid=".$id);	   redirect to uRL

?>

Share this post


Link to post
Share on other sites

This could be also be made into a javascript bookmarklet - that would mean you could just click it again if the showroom page doesn't exist...

Add the following as a bookmark...

BLOCKED SCRIPTvoid(location.href='http://www.tamiyaclub.com/showroom_model.asp?cid='+Math.round(Math.random()*37000));

You can keep it up to date by clicking on the left hand newest model on the club's home page - check what number is in the uRL, and replace the 37000 above as required...

Share this post


Link to post
Share on other sites

Yep - cool! A neater version of the same thing, I've stuck it in my toolbar :) - but still a proper db coded version would be better :)

Share this post


Link to post
Share on other sites
quote:Originally posted by Matt2000

i got the homepage [:P] very impressive.


id="quote">id="quote">

Like I said above, this is just a hacky way of doing it, 10-20% of the time you will hit a deleted entry and TC will redirect to the homepage. You just keep clicking the random link and see what comes up.

It's no substitute to doing it properly, but it at least lets you play with the idea and see what it throws up in practice...

Share this post


Link to post
Share on other sites

Chris, if you want a bit of code for loading a truly random record from SQL Server let me know and I'll send it over to you...

Share this post


Link to post
Share on other sites
quote:Originally posted by netsmithUK

cool - please send it across

thanks


id="quote">id="quote">YGM [:D]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...