LJ Host
09-21-2005, 06:48 PM
Hi guys.. I know little about Programming but I am working with a script and I need to move row 3 (record 3) to the top of the table. What is a command to do this? I have been poking around in myPHPadmin and could not find an easy way to do this.
Thanks for your help :D
Dan L
09-21-2005, 06:57 PM
Why exactly do you want to do this? You generally don't move rows like that. :)
LJ Host
09-21-2005, 07:00 PM
well I'm using osticket and it appears to order the departments based on the record number. so I want to reorder them now that I am happy with my departments. But I do not want to delete all the rows and start over.
There are 4 records (0-3) and I need to move the last one to the second spot.
Dan L
09-21-2005, 07:04 PM
Add an order_id attribute, and manually enter the order you want in them.
Then go into osticket and have it ORDER BY `order_id` ASC.
RobertMaltby
09-21-2005, 07:09 PM
What I would do is make another field (like order_id) and then put the records in order from 0-4 (or however you please) and then when you call the db / records just: ORDER BY by `order_id` ASC
hope it helps (I basically just re-stated DanX's comment..)
LJ Host
09-21-2005, 07:12 PM
OK guys.. slow down a bit.. I'm not too literate in php mysql.
So there already is a column called "ID" and I tried renumbering those with no luck.
Are you familiar with OSticket and would you know where to locate the code to enter this "order by". I would need to know exactly what to put there.
Thanks for your help.. I will try to post the code where the form is. I'm guessing that this is where I would put this code??
Thanks for your help guys :D
RobertMaltby
09-21-2005, 07:17 PM
Well, Im not 100% familiar with it.. however.. what I'd do is just look for the .php page the dept's show up on... then try to break it down from there.. you should be able to change the ID field.. (I dont know what would stop you?)
LJ Host
09-21-2005, 07:18 PM
ok I found the code on the new ticket form:
<select name="cat">
<?
$cats = mysql_query("SELECT * FROM ticket_categories");
while ($category = mysql_fetch_array($cats)) {
$selected = ($_REQUEST[cat] == $category[ID]) ? " SELECTED": "";
?>
<option value="<?=$category[ID]?>"<?=$selected?>><?=$category[name]?></option>
<?
}
?>
</select>
What would I change it to?
RobertMaltby
09-21-2005, 07:31 PM
<select name="cat">
<?
$cats = mysql_query("SELECT * FROM ticket_categories ORDER BY id ASC");
while ($category = mysql_fetch_array($cats)) {
$selected = ($_REQUEST[cat] == $category[ID]) ? " SELECTED": "";
?>
<option value="<?=$category[ID]?>"<?=$selected?>><?=$category[name]?></option>
<?
}
?>
</select>
change "id" to whatever it is in your DB..
LJ Host
09-21-2005, 07:37 PM
Sweet it worked... there were only 2 places I could find that listed it so it was not a big change... thanks for your help.. I really appreciate it :D