vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   Query help (https://vborg.vbsupport.ru/showthread.php?t=49676)

geniuscrew 03-05-2003 12:32 PM

Query help
 
For The Ultimate Quote hack by Kurafire, the quotes are shown randomly using this query.

PHP Code:

// random quote hack by KuraFire
 
$quot=$DB_site->query_first("SELECT quote,name FROM quotes ORDER BY rand() LIMIT 1");
 
$thequote $quot['quote'];
 
$thequoter $quot['name']; 

how can I change it so it goes through all the quotes in order?

[They each have an id and ORDER BY id doesn't seem to be working :/]

Thanks

Boofo 03-05-2003 12:36 PM

Quote:

Originally posted by geniuscrew
For The Ultimate Quote hack by Kurafire, the quotes are shown randomly using this query.

PHP Code:

// random quote hack by KuraFire
 
$quot=$DB_site->query_first("SELECT quote,name FROM quotes ORDER BY rand() LIMIT 1");
 
$thequote $quot['quote'];
 
$thequoter $quot['name']; 

how can I change it so it goes through all the quotes in order?

[They each have an id and ORDER BY id doesn't seem to be working :/]

Thanks

I think it would be ORDER BY DESC LIMIT 1

geniuscrew 03-05-2003 12:41 PM

That gives an error. I tried ORDER BY id DESC - but now it just shows the last quote added

Boofo 03-05-2003 12:46 PM

Quote:

Originally posted by geniuscrew
That gives an error. I tried ORDER BY id DESC - but now it just shows the last quote added
Try this:

PHP Code:

ORDER BY quotesid desc LIMIT 1 


Boofo 03-05-2003 12:49 PM

If that doesn't work, maybe this will?

PHP Code:

ORDER BY quotes desc LIMIT 1 


geniuscrew 03-05-2003 12:49 PM

Still no luck - thanks anyway

Steve Machol 03-05-2003 07:15 PM

geniuscrew, to download hacks and get support you will need to go to this page and enter your email address, to show you are licensed. (you will need to use your customer number and password to access that page)
Thank you.

geniuscrew 03-05-2003 07:25 PM

sorry i just changed my email and fogot to update the thing -

Back on topic: can anyone help please?

Erwin 03-05-2003 07:49 PM

Take out the LIMIT 1 - that only limits it to 1 entry.

Boofo 03-05-2003 07:53 PM

I think they only want them to list 1 at a time but in order and not randomly, if I understood right, that is.

geniuscrew 03-05-2003 07:57 PM

Yup that's right Boofo :)

Erwin 03-05-2003 08:02 PM

Use this:

PHP Code:

$quot=$DB_site->query_first("SELECT quotesid,quote,name FROM quotes ORDER BY quotesid DESC LIMIT 1"); 


Boofo 03-05-2003 08:06 PM

Quote:

Originally posted by Erwin
Use this:

PHP Code:

$quot=$DB_site->query_first("SELECT quotesid,quote,name FROM quotes ORDER BY quotesid DESC LIMIT 1"); 


I was close. I forgot to do the first quotesid (actually I didn't know it had to be done that way). ;)

Let me know how it works, geniuscrew.

geniuscrew 03-05-2003 09:09 PM

Actually Boofo even though you didn't say, I was putting the id bit in the SELECT part [at the beginning] ;)

Still it's only showing the last quote. :/

Erwin 03-05-2003 09:50 PM

That is because that is what you wanted. The query chooses the very last quote listed.

Change DESC to ASC will make it choose the first quote listed. But it will not be random. It will always choose the first quote, or last quote.

geniuscrew 03-05-2003 10:02 PM

So there's no way of making it go through the list of quotes and display them one by one?

If not how do i make it even more random?

Thanks for the help guys.

Boofo 03-05-2003 10:26 PM

Quote:

Originally posted by geniuscrew
So there's no way of making it go through the list of quotes and display them one by one?

If not how do i make it even more random?

Thanks for the help guys.

Use RAND(NOW()) in place of RAND like I posted earlier in the thread. The NOW() supplies the necessary seed for the newer versions of mySQL. Trust me. It works. ;)

mr e 03-05-2003 10:26 PM

you could add another column that would display if it's been listed yet, not sure how to make it more random though

geniuscrew 03-05-2003 10:38 PM

Mr E: But would that let the same quote be used twice?

Boofo: Is that the most randomest of randoms? :) I did try it before ya know and it worked, but wasn't what I was looking for. But I'll use it :P


Thanks ppl.

Boofo 03-05-2003 10:49 PM

According to the mySQL site, that is more random than the old way (with RAND() alone) ever was. The seed needs to be there now and this is the automatic way to do it. It's all I use anymore and I have noticed a world of difference. But then I have over 642 quotes, so that helps. I use this for the member of the day hack and it makes a big difference there, too. Try it for a few days and let me know what you think. You will be amazed. ;)

geniuscrew 03-05-2003 10:56 PM

Ah- Hah - I thought I needed to add more quotes - I only have 4 and now it's sitting nicely ont the second one -_- - I'll add more and get back to ya.

Thanks for all your help and for putting up with my annoyance for that matter lol

Peace.

Boofo 03-05-2003 11:01 PM

No problem. Happy to help. ;) Keep me posted.

mr e 03-06-2003 12:57 AM

@geniuscrew you'd add another column with default of 0 then after it's displayed the quote the column would be set to 1, after all the columns are one, then all columns would be set back to 0 and everything would start over again

Erwin 03-06-2003 01:12 AM

Quote:

Originally posted by geniuscrew
So there's no way of making it go through the list of quotes and display them one by one?
To make it go down the list one by one, you need to make your site remember each member somehow, and remember which quote they have looked at, store it, so that the next time they return, the site can go to the next quote.

You can do this by adding a new column to the user table, and saving the quoteid that the member has looked at, and just add 1 after that OR use cookies to save the information.

Either way, it can be done, but would take some effort. :)

geniuscrew 03-06-2003 09:21 PM

Thanks Mr E and Erwin. Unfortunately I don't have the brains to do that kinda stuff.


All times are GMT. The time now is 11:46 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01562 seconds
  • Memory Usage 1,768KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (6)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (25)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete