Calling on date<

windows

Guest
hey guys, just a question

I want to call something out of the data base i have a code like this ::

$result = mysql_query("SELECT tid, title FROM ibf_topics order by title limit 0,7");

while ($row = mysql_fetch_array($result))
{
?>

<a href=http://www.htmlforums.com/archive/index.php/"http://forums.tcb-team.com/index.php?showtopic=<?=$row["tid"]?>"><?=$row["title"];?></a><br>

<?
}
mysql_free_result($result);

?>

But i shows me the topics, but not the new ones and if i chance order by title to order by date i got an error, could someone help me on this one ??you can't use date in mysql, it is a reserved word. change the column name to soemthign else.I only ment how can i call mine information like i now do,i only want the new topics, now it will let me see random topics, dont need that.Well what is your 'date' column called then? To order by date is otherwise correct. I'd say "ORDER BY datecolumn DESC" would be what you want? Puts the newest row on top.Maybe i explained it wrong, got no colummn named date.

got columms like tid, title, posts, etc

But u can call the latest topics (tid) now he calls randomly the topics.

Wanted to know what i have to add to mine code to call the latest topics(tid)Oh and by the way, I found this:


The following symbols (from the table above) are disallowed by SQL-99 but allowed by MySQL as column/table names. This is because some of these names are very natural names and a lot of people have already used them.

ACTION
BIT
DATE
ENUM
NO
TEXT
TIME
TIMESTAMP



<!-- m --><a class="postlink" href="http://www.mysql.com/doc/en/Reserved_words.html">http://www.mysql.com/doc/en/Reserved_words.html</a><!-- m -->

Thought so, because I recall having used 'date' as column name myself. I guess it's not very recommended though.aha, is tid auto incremented then? bigger number = newer article? "ORDER BY tid DESC" then?
BTW, it now selects random articles? that's very odd.you can't call by date if you don't have a date column.

try: order by tid ASC or DESC (which ever way you want it to show)

it isn't random either.

Rydberg, yes it does say that and yes it is not recommened to use it and it will cause problems. just like I use 'status' but sometimes that has caused my many of problems.Solved it guys, i changed mine code to

$result = mysql_query("SELECT tid, title FROM ibf_topics order by tid desc limit 0,7");

Works fine now.

next problem is i got many catergories (cid)
like 12 or 13.

Now he gets the info from all categories, but can i lock some cid`s so that he is not showing that info i want to hideno you can't lock a column in mysql.

you have to add another column and set it when you don't want to use it and then have php check this column. that is the easiest way.$result = mysql_query("SELECT tid, title FROM ibf_topics WHERE cid != 1 AND cid != 2 ORDER BY tid DESC LIMIT 0,7");

Like that maybe? 1 and 2 were just chosen as examples. I guess it would be better to have these 'private' topics in another table.


Edit:
Scoutt's idea with an extra column would be more recommendable, since it's more dynamic. But if you're redesigning the database, you might as well put the private info in another table, while you're at it.
You wouldn't need to have PHP checking the value of that column btw, make MySQL do it, that's better. It will then always return 7 topics for you(if there are 7 qualified ones, of course) as well as it is faster.I call it from a forum, so i cant change it other wise i have to to massive coding.

and like $cid=cid 1,3,4,5,8,9,11 doesnt it work like that

and add that cid code to mine orginal codeSomebody some ideas ??? :eek:Rydberg already answered it.
 
Back
Top