Hi
I am a complete newbie and can't figure out how to sort a simple database.
I have a db called 'garage' with a table called 'cars' that has the fields id,make,model. The code below allows me to insert data but I wish to then sort it by id.
<html><body><?php
$user="root";
$conn=mysql_connect("localhost","root","")or die("err:conn");
$self=$_SERVER['PHP_SELF'];
$id=$_POST['id'];
$make=$_POST['make'];
$model=$_POST['model'];
?>
<form action="<?php echo($self);?>" method="post">
ID:<input type ="int" name="id">
make: <input type="text" name ="make">
model:<input type="text" name="model">
<input type="submit" value ="Submit"></form>
<?php
$rs=mysql_select_db("garage",$conn)or die("err:db");
$sql="insert into cars (id,make,model)values($id,\"$make\",\"$model\")";
$rs=mysql_query($sql,$conn);
if($rs){echo("Record added:$id $make $model");}
else die("Record not added");
$arr=array($id,$make,$model);
rsort ($arr);
?>
</body></html>
you will see my attempt at sorting in the two lines of code starting $arr. That doesn't work. How do I do it please?