Psychoman
09-01-2004, 06:15 AM
Hey guys, I have a question for you,
I basically have the system down, I just need your help figuring out the best way to do it.
I want to be able to have dynamic links that use a database to display them. each row has an id, an order_id, the link text and the page to link to. now, I would like to be able to sort the display of links by the "order_id" that can do something like this.
Link order id
Books 1
Magazines 2
Catalogs 3
then use an administrative php script to move the links arround, say select magazines then "move up" and it adds 1 to books and subtracts 1 to magazines ending up with
Magazines 1
Books 2
Catalogs 3
Like i said, the basics is simple enough, however, what would be the best way to apply this to php so that it always knows which entries to modify? I can come up with something, but its not much.... I'm kinda zoned out as it is so that may be my whole problem. either way, i can use some outsider's help.
Here's what I can come up with
$sql="SELECT * FROM links WHERE order_id='$current_order";
$result = @mysql_query($sql,$db);
if ($moveup == on){
$new_order_id = $current_order + 1;
$sql="UPDATE order_id='$new_order_id' WHERE order_id='$current_order";
$result = @mysql_query($sql,$db);
// I'm actually stuck here.... how can I check to see if there is an entry under the one I am editing, using count?
} else {
$new_order_id = $current_order - 1;
$sql="UPDATE order_id='$new_order_id' WHERE order_id='$current_order";
$result = @mysql_query($sql,$db);
// I'm actually stuck here.... how can I check to see if there is an entry under the one I am editing, using count?
}
sorry its really crude, thats basically off the top of my head... can somone help me out?
Thanks,
Ray
I basically have the system down, I just need your help figuring out the best way to do it.
I want to be able to have dynamic links that use a database to display them. each row has an id, an order_id, the link text and the page to link to. now, I would like to be able to sort the display of links by the "order_id" that can do something like this.
Link order id
Books 1
Magazines 2
Catalogs 3
then use an administrative php script to move the links arround, say select magazines then "move up" and it adds 1 to books and subtracts 1 to magazines ending up with
Magazines 1
Books 2
Catalogs 3
Like i said, the basics is simple enough, however, what would be the best way to apply this to php so that it always knows which entries to modify? I can come up with something, but its not much.... I'm kinda zoned out as it is so that may be my whole problem. either way, i can use some outsider's help.
Here's what I can come up with
$sql="SELECT * FROM links WHERE order_id='$current_order";
$result = @mysql_query($sql,$db);
if ($moveup == on){
$new_order_id = $current_order + 1;
$sql="UPDATE order_id='$new_order_id' WHERE order_id='$current_order";
$result = @mysql_query($sql,$db);
// I'm actually stuck here.... how can I check to see if there is an entry under the one I am editing, using count?
} else {
$new_order_id = $current_order - 1;
$sql="UPDATE order_id='$new_order_id' WHERE order_id='$current_order";
$result = @mysql_query($sql,$db);
// I'm actually stuck here.... how can I check to see if there is an entry under the one I am editing, using count?
}
sorry its really crude, thats basically off the top of my head... can somone help me out?
Thanks,
Ray