Qua bài này, mình sẽ giúp bạn hiển thị những câu danh ngôn một cách ngẫu nhiên theo như DEMO bên dưới (nhấn F5 để thấy tác dụng).
Điều trước tiên là bạn cần có một hosting (có thể dùng free hosting như byethost.com để thử nghiệm). Mở công cụ Notepad trên máy tính của bạn rồi dán vào đó bằng đoạn code bên dưới rồi lưu file với tên là randomquotes.php.
- <?
- //////////////////////////////////////////////////////
- // PHP Random Quote Script for Blogspot applied by www.thuthuatblogger.info
- // Many thanks to http://davidmarotz.com/ for its original PHP code
- //////////////////////////////////////////////////////
- $bgcolor = '#FFFFCC';
- $textcolor = 'black';
- $textcolor2 = 'brown';
- $textsize = '4';
- $textsize2 = '3';
- // Array Structure: "Quote","Author"
- ("The Black Knight Always Triumphs!",
- "Monty Python",
- "I swear by my life and love of it that I will never live for the sake of<br>another man, nor ask another man to live for mine" ,
- "Atlas Shrugged",
- "It is clear that the individual who persecutes a man, his brother,<br> because he is not of the same opinion, is a monster",
- "Voltaire",
- "I agree that there is a natural aristocracy among men<br>The grounds of this are virtue and talents.",
- "Thomas Jefferson",
- "Liberty, when it begins to take root, is a plant of rapid growth.",
- "George Washington",
- "Never argue with an idiot. <br>They drag you down to their level <br>then beat you with experience",
- "Dilbert",
- "The Answer is 42. What is the question?",
- "Hitchikers Guide to the Galaxy",
- "Anyone who has never made a mistake has never tried anything new",
- "Albert Einstein",
- "Progress doesn't come from early risers, progress is made<br>by lazy men looking for easier ways to do things.",
- "Lazarus Long <font size=-2>(Time Enough for Love by Robert A. Heinlein)</font>",
- "Throughout history, poverty is the normal condition of man. <br>Advances which permit this norm to be exceeded - here and there, now and then - <br>are the work of an extremely small minority, frequently despised,<br> often condemned, and almost always opposed by all right-thinking people. <br>Whenever this tiny minority is kept from creating, or (as sometimes happens)<br> is driven out of a society, the people then slip back into abject poverty.<br><br>This is known as 'bad luck.'",
- "Robert Heinlein",
- "A little learning is a dangerous thing; Drink deep, or taste not the<br>Pierian spring. There shallow draughts intoxicate the brain, <br>and drinking largely sobers us again",
- "Alexander Pope",
- "The early bird gets the worm, but the second mouse gets the cheese",
- "Anonymous",
- "Subjugating the enemy's army without fighting is the true pinnacle of excellence",
- "Sun-tzu, The Art of War",
- "Work as though you were to live 100 years; pray as if you were to die tomorrow",
- "Benjamin Franklin",
- "The world is a stage, but the play is badly cast",
- "Oscar Wilde",
- "Truth is generally the best vindication against slander.",
- "Abraham Lincoln",
- "...mercy to the guilty is cruelty to the innocent...",
- "Adam Smith",
- "...I wish that I may never think the smiles of the great and powerful<br> a sufficient inducement to turn aside from the straight path<br> of honesty and the convictions of my own mind",
- "David Ricardo",
- "Democracy is the worst form of government except for all the others",
- "Winston Churchill",
- "You can only know the highest peaks if you have experianced the lowest valley's",
- "Richard Nixon",
- "They dress the wound of my people as though it were not serious. <br>'Peace, peace,' they say, when there is no peace.",
- "Jeremiah 6:14",
- "It is better to remain silent and be thought a fool<br> than to open your mouth and remove all doubt.",
- "Jonathan Swift",
- "The market system delivers the goods people want,<br>but those who make it work cannot readily explain why it is so.<br>The socialst or communist system does not deliver the goods, <br>but those who operate it can readily explain away its failure.",
- "F.A. Hayek, Law, Legislation and Liberty, Vol. II",
- "Never Stop Exploring<sup>tm</sup>",
- "The North Face"
- );
- // Gets the Total number of Items in the array
- // Divides by 2 because there is a Quote followed by an Author
- // Subtracted 1 from the total because '0' is not accounted for otherwise
- $nmbr = $nmbr*2;
- //$nmbr = 18;
- $quote = $allqts[$nmbr];
- $nmbr = $nmbr+1;
- $author = $allqts[$nmbr];
- $space = "<font color=$bgcolor>.....................................</font>";
- echo "document.write(\"<center><font color=$textcolor size='$textsize'><i>$quote</i></font><br>$space<font color=$textcolor2 size='$textsize2'>$author</font></center>\")";
- ?>
Trong đoạn code trên, bạn có thể thay thế những câu danh ngôn tiếng Anh bằng những câu danh ngôn tiếng Việt tương ứng, thêm hoặc bớt tùy ý theo đúng định dạng. Chú ý dùng <br> để xuống dòng cho câu văn.
Upload file randomquotes.php lên hosting của bạn để sử dụng.
Để hiển thị danh ngôn thì bạn đặt trong bài viết Blogspot hoặc tiện ích HTML/Javascript bằng dòng code như sau:
- <script type="text/javascript" src="http://www.tenmienhostingcuaban.com/randomquotes.php"></script>
Danh ngôn ngẫu nhiên bằng Javascript
ninest123 12.15
ReplyDeleteoakley sunglasses, louboutin shoes, michael kors outlet online, prada outlet, louis vuitton outlet online, oakley sunglasses, nike free, oakley sunglasses, replica watches, burberry outlet, christian louboutin, nike air max, tiffany jewelry, tiffany jewelry, ralph lauren outlet, ray ban sunglasses, burberry factory outlet, cheap jordans, longchamp outlet, michael kors, ralph lauren polo, michael kors outlet online, replica watches, gucci handbags, michael kors outlet, ray ban sunglasses, uggs on sale, michael kors handbags, nike outlet, nike air max, uggs on sale, uggs outlet, christian louboutin, prada handbags, uggs outlet, tory burch outlet, louis vuitton outlet, louboutin uk, longchamp bags, longchamp outlet, ray ban sunglasses, cheap oakley sunglasses, louis vuitton handbags, oakley sunglasses, louis vuitton, uggs on sale, michael kors outlet online, louis vuitton outlet
louboutin pas cher, timberland pas cher, nike trainers uk, true religion jeans, nike roshe run pas cher, nike air max pas cher, nike blazer pas cher, lunette ray ban pas cher, abercrombie and fitch, lululemon outlet, michael kors outlet online, michael kors, coach outlet store online, coach purses, new balance, nike air max, hollister uk, michael kors, lunette oakley pas cher, true religion outlet, nike tn pas cher, replica handbags, nike air max uk, longchamp soldes, nike free, longchamp pas cher, north face uk, ralph lauren pas cher, michael kors uk, north face pas cher, vanessa bruno pas cher, true religion outlet, polo ralph lauren uk, nike air force, converse, vans pas cher, nike roshe uk, burberry pas cher, sac guess pas cher, true religion outlet, nike air max uk, ray ban uk, hogan sito ufficiale, jordan pas cher, hermes pas cher, mulberry uk, polo lacoste pas cher, nike free pas cher, abercrombie and fitch UK
ReplyDeletesac louis vuitton, ugg,uggs,uggs canada, supra shoes, coach outlet, canada goose outlet, doke & gabbana, hollister, montre pas cher, pandora jewelry, swarovski uk, ugg pas cher, canada goose, juicy couture outlet, links of london uk, moncler uk, moncler, louis vuitton, canada goose jackets, louis vuitton uk, thomas sabo uk, barbour, moncler, moncler jackets, lancel, canada goose outlet, ugg,ugg australia,ugg italia, barbour jackets uk, canada goose, replica watches, karen millen uk, moncler, pandora jewelry, juicy couture outlet, swarovski jewelry, canada goose jackets, toms shoes, louis vuitton, marc jacobs, pandora charms, ugg uk, canada goose uk, canada goose pas cher, moncler outlet, bottes ugg pas cher, pandora uk, wedding dresses uk, moncler, moncler pas cher, sac louis vuitton, converse shoes outlet
ReplyDeleteninest123 12.15