|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
sortby?
How would I be able to sort info by letter? ie, when you visit the page, it shows the last 5 updates, but when click a letter to sort it by, like A, it just shows the topics that start with A.
|
|
#2
|
|||
|
|||
|
RE: sortby?
:-/
..put yer topics in an array and use the sort function. |
|
#3
|
|||
|
|||
|
RE: sortby?
if you are pulling from a database :
SELECT * FROM TABLE WHERE field LIKE 'A%' OR field LIKE 'a%' ORDER BY field |
|
#4
|
|||
|
|||
|
RE: sortby?
|
|
#5
|
|||
|
|||
|
RE: RE: sortby?
I am not quite sure what the above snipplet is suppose to do, however Matt led you in the right direction. I am assuming you want your result to include only topics that start with "A" but you probably also want them sorted by date. You are, of course, going to want to pass your script the char to sort by. Try something like this: select * from table where TOPIC_FIELD like '".strtoupper($char)."%' or TOPIC_FIELD like '".strtolower($char)."%' order by DATE_FIELD desc Hope that helps. |
|
#6
|
|||||
|
|||||
|
RE: sortby?
I haven't been able to try this for a few days due to my server being down, but I get an unexpected T string on it
php Code:
|
|
#7
|
|||
|
|||
|
RE: sortby?
In your first query:
$result = mysql_query("select * from interdb ORDER BY bandname like '".strtoupper($char)."%'" LIMIT 5,$db); You need to take out the " that is before LIMIT. So it should look like this: $result = mysql_query("select * from interdb ORDER BY bandname like '".strtoupper($char)."%' LIMIT 5,$db); That is the first thing to check, Then rerun the code and see if there is any other lines w/errors. When debugging you want to use a top-down approach, many times when fixing errors/warnings on line 1 will also clear line errors/warning in latter lines. Hope that helps. |
|
#8
|
|||
|
|||
|
RE: sortby?
Forgot this part. After removing the " before the LIMIT you need to place it after the 5. It should look like this:
$result = mysql_query("select * from interdb ORDER BY bandname like '".strtoupper($char)."%' LIMIT 5",$db); Sorry. |
|
#9
|
|||
|
|||
|
RE: sortby?
now I'm getting this phrase error
Parse error: parse error, unexpected ')' in /home/gmflp/public_html/test.php on line 28 which is the line echo( "<br><b><font class=rm><a href=vinter.php?id=" .$myrow[id]. " class=rm>...Read More</a></b></font>" ); |
|
#10
|
|||
|
|||
|
RE: sortby?
That line of code is used twice. Is it the first instance or the second?
|
|
#11
|
|||
|
|||
|
RE: sortby?
On a side note, echo does not require an open paren ( and a close paren ).
echo "some text"; // legal echo "text".$foo; // legal echo "text".$foo."text"; // legal echo $foo."text"; // legal echo $foo; // legal |
|
#12
|
|||
|
|||
|
RE: sortby?
now I'm getting this error, thanks for your help by the way
Parse error: parse error, unexpected '{' in /home/gmflp/public_html/test.php on line 30 |
|
#13
|
|||
|
|||
|
RE: sortby?
Not knowing what the rest of your code looks like, I can't tell you where exactly the problem is. However, I can tell you that the error means that you do not have an equal amount of {'s and }'s.
I would sugesst going thru your code and matching every open { with its closing }. This is where your personal programming style comes into play. Personally, and I believe this to be true "industry wide", is that after every { I indent two spaces so that everything lines up nice and neat on the left hand side. That should sort of help. |