Affiliate Programs
 
Search affiliate programs for: 
Affiliate Categories
» Affiliate Networks
» Ad Networks
» 2 Tier Programs
» Pay Per Sale
» Pay Per Lead
» Residual Income
» Datafeeds
» Multi Tier Programs
» Business Opps
» Other Programs

Newsletter
Get newly added affiliate programs by email. Enter your email here:
Article Categories
» Affiliate Marketing
» Business
» Ecommerce
» Hosting
» Marketing
» Sales
» Web Designing
» Webmasters
» SEO & Promotion
» Working At Home
» Other Articles
» Affiliate Glossary


Go Back   AffiliateSeeking Forum > Website Creation, Design & Maintenance > Databases > MySQL

MySQL Need help with your MySQL database or would you like to help others. Discuss everything about MySQL in here.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-06-2009, 12:51 PM
komrad komrad is offline
Junior Member
 
Join Date: Jul 2008
Posts: 4
komrad is on a distinguished road
Default way to inserting data into a MYSQL table data in an ordered way

Hello all,

I'd like to know if there is a way to insert into a MYSQL table data in an ordered way?
Right now as a workaround I've literally made a table of questions with questionID as primary key, nextQuestion and prevQuestion pointing to other questionIDs. Basically I've made a two way linked list from scratch. Is there anything built into MYSQL that implements this?

Thanks in advance.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-25-2009, 06:00 AM
marylane marylane is offline
Junior Member
 
Join Date: Dec 2008
Posts: 9
marylane is on a distinguished road
Anyone? I would be interested in this too, as I have a habit of making a mess
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-21-2009, 11:24 PM
troublescoot troublescoot is offline
Junior Member
 
Join Date: Feb 2009
Posts: 20
troublescoot is on a distinguished road
Quote:
Originally Posted by komrad View Post
Hello all,

I'd like to know if there is a way to insert into a MYSQL table data in an ordered way?
Right now as a workaround I've literally made a table of questions with questionID as primary key, nextQuestion and prevQuestion pointing to other questionIDs. Basically I've made a two way linked list from scratch. Is there anything built into MYSQL that implements this?

Thanks in advance.
It seems like you want a way to automagically point to the previous/next records for navigational purposes.

If that's what it is, you can just do a query for each-

Code:
<?php

$previous = mysql_query(sprintf("SELECT questionID FROM [table] WHERE (questionID < %d) LIMIT 1", $currentQuestionId));

$next = mysql_query(sprintf("SELECT questionID FROM [table] WHERE (questionID > %d) LIMIT 1", $currentQuestionId));

?>
That's a very rudimentary way of doing it.

Not sure if that helps, but it's all I could do given the info.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-03-2009, 10:52 PM
tanja tanja is offline
Senior Member
 
Join Date: Dec 2008
Posts: 1,667
tanja is on a distinguished road
Thanks for your explanation! It's very useful for me
__________________
software development | designer clothes
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-04-2010, 11:17 AM
jurwanwall jurwanwall is offline
Member
 
Join Date: Nov 2010
Posts: 85
jurwanwall is on a distinguished road
#
INSERT INTO question_list
#
SET TEXT='The text of the question',
#
previous_id='-1',
#
next_id='-1';

#
INSERT INTO question_list
#
SET TEXT='Inside question text',
#
previous_id=LAST_INSERT_ID(),
#
next_id=-1;

#
#
UPDATE question_list

#
INSERT INTO question_list
#
SET TEXT='Inside question text',
#
previous_id=LAST_INSERT_ID(),
#
next_id=-1;

#
#
INSERT INTO question_list
#
SET TEXT='Last question text',
#
previous_id=LAST_INSERT_ID(),
#
next_id=-1;
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 03-16-2011, 01:09 PM
israpost israpost is offline
Junior Member
 
Join Date: Mar 2011
Posts: 5
israpost is on a distinguished road
Quote:
Originally Posted by jurwanwall View Post
#
INSERT INTO question_list
#
SET TEXT='The text of the question',
#
previous_id='-1',
#
next_id='-1';

#
INSERT INTO question_list
#
SET TEXT='Inside question text',
#
previous_id=LAST_INSERT_ID(),
#
next_id=-1;

#
#
UPDATE question_list

#
INSERT INTO question_list
#
SET TEXT='Inside question text',
#
previous_id=LAST_INSERT_ID(),
#
next_id=-1;

#
#
INSERT INTO question_list
#
SET TEXT='Last question text',
#
previous_id=LAST_INSERT_ID(),
#
next_id=-1;
exactly that's correct check this up i too have used..



Jewish Recipes
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 06-06-2011, 12:41 PM
tylerlongtw tylerlongtw is offline
Senior Member
 
Join Date: May 2011
Posts: 392
tylerlongtw is on a distinguished road
its better to insert your data with any order and use ORDER BY Clause while retrieving your data.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:59 PM.


Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.0.0
© 2004-2011 AffiliateSeeking. All rights reserved.