Jump to content

[SOLVED] Question of ordering!!!


Recommended Posts

Hi there!

 

I'm using MySQL 5.0.67, and I'm bilding a website with php.

 

I want to order the data by initial letter of the content, but not ascending or descending but order by letter J, then C, then W, then O and the others letters dont matter because just have with this initial letters. It's for displaying the data by styles in the php page, with the jazz style in top.

 

Thanks for the help!

 

Link to comment
https://forums.phpfreaks.com/topic/145578-solved-question-of-ordering/
Share on other sites

Hi try but dont work and for what I understand this is for ordering by field name and what I need is ordering the records with base in the field "estilo" and that appear on top the "Jazz" records Letter "J", next the records beggining letter "C", next beggining letter "W" and for last letter "O".

 

Thanks for the help!

Dont work!!!

 

mysql_select_db($database_dargil_site, $dargil_site);
$query_listdestaques = "SELECT * FROM destaques ORDER BY FIELD(SUBSTRING(estilo,1,1),"J","C","W","O")";
$listdestaques = mysql_query($query_listdestaques, $dargil_site) or die(mysql_error());
$row_listdestaques = mysql_fetch_assoc($listdestaques);
$totalRows_listdestaques = mysql_num_rows($listdestaques);
?>

 

This is the code I have in this moment!

Thanks

Of course it doesn't.

 

You're using double quotes in double quoted string. Either escape them, or enclose the string in single quotes. (Or change internal quotes to single quotes)

$query_listdestaques = "SELECT * FROM destaques ORDER BY FIELD(SUBSTRING(estilo,1,1),"J","C","W","O")";

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.