|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this 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
|
|||
|
|||
|
A shoutbox script in need of help
Well i would like to get my script working with alternating row colours and also it posts the new message at the top but i want it at the bottom how do i do this
Here is the code <?php mysql_pconnect("localhost","username","password"); mysql_select_db("shoutbox"); if($submit) { $result=MYSQL_QUERY("INSERT INTO shoutbox (id,name,message,url)"."VALUES ('NULL','$name', '$message','$url')"); // inserting it into the shoutbox table which we made in the mysql statements before } $result = mysql_query("select * from shoutbox order by id desc limit 12"); //returning the last 12 messages while($r=mysql_fetch_array($result)) //the while loop { $url=$r["url"]; $id=$r["id"]; $message=$r["message"]; $name=$r["name"]; echo "<a href = $url>$name</a> : $message <br>"; } ?> Here is the board URL |
|
#2
|
|||
|
|||
|
Hi Makka,
In order to get alternating row colours, you'll need to make use of the modulus operator (%)... PHP Code:
To get your newest message to appear at the bottom, it's just a matter of using the ORDER BY command in your SQL statement... ie: SELECT * FROM messages ORDER BY message_date DESC Hope that helps...
__________________
____________________________________________ Developer Shed Weekly Writer | DevArticles Forum Moderator Build Your Own KlipFolio Klip With PHP FrankManno.com - Under Construction Design Interactive Group - Under Construction |
|
#3
|
||||
|
||||
|
"SELECT * FROM messages ORDER BY message_date DESC" will make the newest msg appear @ the TOP!
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > A shoutbox script in need of help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|