Jump to content

[SOLVED] Reverse Order ... and form trouble


Gem

Recommended Posts

Hiya, I've got this code that displays my articles ... but I need them to be displayed "newest first" ..

 

Can anyone help me with that?

 

  <?php
$con = mysql_connect("CONNECTION DETAILS");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }mysql_select_db("DBNAME", $con);$result = mysql_query("SELECT * FROM articles");while($row = mysql_fetch_array($result))
  {
  echo $row['Title'];
  echo "<br />";
  echo $row['SubTitle'];
  echo "<br />";
  echo $row['Article'];
  echo "<br />";
  }mysql_close($con);
?>

 

Also, heres my form ... I cant get the textarea to display properly, it just displays the same as the other fields which is really annoying ... any ideas??

 

  <form action="insert.php" method="post">
Title: <input type="text" name="title" />
Description: <input type="text" name="subtitle" />
News Update:  <input type="textarea" name="article" />
<input type="submit" />
</form>

 

Thanks loads

 

Gem xxx

Link to comment
https://forums.phpfreaks.com/topic/149009-solved-reverse-order-and-form-trouble/
Share on other sites

OK LOL - What did I do wrong?

 

I just done the index on column "ID" - though I dont really know what that actually means ...

 

so then I did this...

  }mysql_select_db("bssql", $con);$result = mysql_query("SELECT * FROM articles");while($row = mysql_fetch_array($result) ORDER BY INDEX SORT DESC;)

 

and got this:

PHP Parse error: syntax error, unexpected T_STRING in d:\webspace\bradleystokejudoclub.co.uk\wwwroot\news.php on line 17

 

Help ...  ???  :(

it goes in the mysql_query statement not at the end of the line ...

 

and take out the "SORT", that was a typo on my part

}mysql_select_db("bssql", $con);$result = mysql_query("SELECT * FROM articles  ORDER BY ID DESC");while($row = mysql_fetch_array($result)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.