vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Is there anyway of doing this (https://vborg.vbsupport.ru/showthread.php?t=38613)

wolfe 05-14-2002 08:34 AM

Is there anyway of doing this
 
right first off

in mySQL

i have post id's liek this

1
2
3
4
6
8
9
12

is there anyway of making it go like this

1
2
3
4
5
6
7
8
9
10
11
12

by moving post 6 to the 5 slot and 8 to the 6 slot

1
2
3
4
6
8
9
12

in asending order

so i could add an old DB

Logician 05-14-2002 09:21 AM

You cant do this while you get the the result with SQL. However after fetching the results, assign them into a array and then you can sort this array in any way you like..

wolfe 05-14-2002 09:24 AM

what do u mean m8 i aint that good with mySQL

Logician 05-14-2002 10:13 AM

I meant:

If you are searching for a SELECT SQL query that will do what you asked, no, you cant find.

Instead:

First get your SQL result in the original form with simple SELECT query, ie:

1
2
3
4
6
8
9
12

Assign this result to an array with mysql_fetch_row command..

Now you will have an array like that:
$array[0]=1
$array[1]=2
$array[2]=3
..
$array[4]=6
$array[5]=8
..
$array[7]=12

Now since you have an array, you can do anything you like with this array. Do you want to switch 6 and 8, here you go:
$a=$array[5];
$array[5]=$array[6];
$array[6]=$a;

You'll have:
$array[0]=1
$array[1]=2
$array[2]=3
..
$array[4]=8
$array[5]=6
..
$array[7]=12

See?

wolfe 05-14-2002 03:42 PM

m8 how do i do it using phpMyAdmin

Logician 05-14-2002 04:22 PM

wolfe, this is what I'm trying to say: You cant do it via SQL (=PhpMyAdmin). To have such a custom sorted result you need to process your SQL results in a PHP file with PHP and do the sorting there..SQL can only manage basic sortings and custom sortings like you asked.. Hope this helps..

wolfe 05-14-2002 04:26 PM

so i need to make a php file with the above in ti

Mark Hensler 05-14-2002 07:42 PM

I think he wants to change the ids for cetain posts so that he can import a previous DB dump.

wolfe 05-14-2002 08:55 PM

yep thats it

also is there a way of making a import

in another DB

go like this

say the first DB ends @

1342

is there anyway of making the others go from 1342 +


All times are GMT. The time now is 01:36 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.01010 seconds
  • Memory Usage 1,719KB
  • 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
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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