Jump to content

Anders Moen

Members
  • Posts

    866
  • Joined

  • Last visited

Everything posted by Anders Moen

  1. It's called pagination.Here's a script that works: <?php // config------------------------------------- $host = "localhost"; //your database host $user = "username"; // your database user name $pass = "password"; // your database password $db = "db_name"; // your database name$table = "table_name"; // your table name$filename = "index.php"; // name of this file $option = array (5); // in the url you'll see &go=5, so if you write $option = array(5, 10, 15); you can write &go=5, &go=10 or &go=15 (after how many records that should display on the page).$default = 5; // This is what it displays if you don't change anything in the url (&go=some_number)$action = $_SERVER['PHP_SELF']; // if this doesn't work, enter the filename // end config--------------------------------- $opt_cnt = count ($option); $go = $_GET['go']; if ($go == "") { $go = $default; } elseif (!in_array ($go, $option)) { $go = $default; } elseif (!is_numeric ($go)) { $go = $default; } $nol = $go; $limit = "0, $nol"; $count = 1; $connection = mysql_connect ($host, $user, $pass) or die ("Unable to connect"); mysql_select_db ($db) or die ("Unable to select database $db"); // control query------------------------------ /* this query checks how many records you have in your table. change this to match your own table*/ $off_sql = mysql_query ("SELECT * FROM $table") or die ("Error in query: $off_sql".mysql_error()); $off_pag = ceil (mysql_num_rows($off_sql) / $nol); //-------------------------------------------- $off = $_GET['offset']; if (get_magic_quotes_gpc() == 0) { $off = addslashes ($off); } if (!is_numeric ($off)) { $off = 1; } if ($off > $off_pag) { $off = 1; } if ($off == "1") { $limit = "0, $nol"; } elseif ($off <> "") { for ($i = 0; $i <= ($off - 1) * $nol; $i ++) { $e = 0 + $i; $limit = "$e, $nol"; $count = $e + 1; } } // Query to extract records from database. Change this to match your own table, but leave "LIMIT $limit" part unchanged. $sql = mysql_query ("SELECT * FROM $table ORDER BY id DESC LIMIT $limit") or die ("Error in query: $sql".mysql_error()); while ($row = mysql_fetch_array($sql)) {echo 'This is where you select from the database.';$count += 1; } if ($off <> 1) { $prev = $off - 1; echo " <a href=\"$filename?page=news&offset=$prev&go=$go\">Previous</a> "; } for ($i = 1; $i <= $off_pag; $i ++) { if ($i == $off) { echo " [ <b> $i </b> ] "; } else { echo " <a href=\"$filename?page=news&offset=$i&go=$go\">$i</a> "; } } if ($off < $off_pag) { $next = $off + 1; echo " <a href=\"$filename?page=news&offset=$next&go=$go\">Next</a> "; } echo "<br />\r\n"; echo "Page <b>$off</b> of <b>$off_pag</b><br />\r\n";?> Just one thing: this script is taken directly of my simple forum so you might need to remove some tables and stuff.
  2. What?!I can't see no difference between those two sites, except the content in the middle =/
  3. I haven't used outer glow =/But yeah, thanks for the tip about liven it up but I don't know what to put on. Does anybody here have any ideas?
  4. You mean like this? <?phpif (isset($_POST['submit'])) {$con = mysql_connect("localhost","peter","abc123");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("my_db", $con);$sql="INSERT INTO person (FirstName, LastName, Age)VALUES('$_POST[firstname]','$_POST[lastname]','$_POST[age]')";if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }echo "1 record added";mysql_close($con);}else {?><form action="insert.php" method="post">Firstname: <input type="text" name="firstname" />Lastname: <input type="text" name="lastname" />Age: <input type="text" name="age" /><input type="submit" name="submit" value="Submit" /></form><?php}?> This is taken from W3Schools PHP MySQL section, so it's not safe for sql-injections just so you know.
  5. Hey again everybody!I've been working some more on my CMS but this time I was thinking a little bit more of the design than the last time.I was just wondering if this design I've been working on is worth a try...(see image below). It's made out of the old look of the CMS (http://andersmoen.hotserv.dk/cms/) just this time I think the graphics are a little bit better.The gray background-color on one of the links is the hover on the menu. So what you think of it? What should be changed? Remember: this CMS is gonna be out for download, and I'm developing a "standard" design that comes along with the download and that's gonna be a simple one and this is the design it might be so I really want your honest opinions about it. So now you know why it's just simple.
  6. Welcome to the forum again Fermat
  7. Like I said, you can use float: left; on the h1 classes: <head><style type="text/css>h1.cs { color: black; float: left; }h1.fps { color: blue; float: left; }</style></head><body><h1 class="cs">Text</h1><h1 class="fps">Text2</h1></body>
  8. Nope, it's not Fermat. You can use <head><style type="text/css>h1.cs { color: black; float: left; }h1.fps { color: blue; float: left; }</style></head><body><h1 class="cs">Text</h1><h1 class="fps">Text2</h1></body>
  9. If you are one of the people who use Piczo guestbooks, and shoutboxes people can come delete entries in it, and edit posts and stuff like that.Because Piczo has some big XSS holes, and the worst is that it's really simple to edit or even delete posts.But I don't want to get banned from the forum, or something like that, so I cannot tell you how to do this. Just want you to know so you know what's happening if you use Piczo and suddenly some of your entries are gone or edited.A big thank you to the JavaScript, haha!
  10. If you want your site to load faster, use this code between <head> and </head> <link rel="stylesheet" type="text/css" href="style.css" /> .And style.css looks like this: a:link, a:active, a:visited { font-size: 00px; }a:hover { font-size: 00px; } In the a:hover you can change i.e the text-decoration to be nothing, so you get some "effects" at your site: a:link, a:active, a:visited { font-size: 00px; }a:hover { font-size: 00px; text-decoration: none; } Like AeroCoder, change 00
  11. Welcome to the board AeroCoder!
  12. Welcome to the board Tuulen! Great to see you coming here hehe
  13. Ohh...something I didn't get in the previous posts then
  14. Have you called it favicon.ico? Or else it won't work in all browsers. And if you use IE6 (or below) and maybe IE7 (don't know), it doesn't work.And the code to get it is<link rel="shortcut icon" href="favicon.ico"> and not <link rel="icon" type="image/png" href="http://example.com/myicon.png"> It might be a good idea to have type="image/something" too, but I don't know how that code goes with favicons.
  15. Use Flash instead. Download a 30 day free trial of Adobe Macromedia Flash 8 or a simple program called KoolMoves (not able to save in demo version though). Marquee is really bad...it laggs too on sites that uses them. Not the site, but the marquee text itself.
  16. Stop a screenshot? Do you mean so people can't take screenshots of your site or something? I don't think that works, though
  17. I think bots will pick it up, cause they probably read the source, or?
  18. Anders Moen

    CMS with PHP

    Yea, you can have users there if that's what you meant. And yes, it's simple, but it works and that's what counts, hehe.About the users, I just sat that up because that's just the test area of the system, and people didn't want to use "Demo User" so I created a form and some code so people could register :)But this was like version 1, where I forgot to strip tags in the title and where you can make sites and some if empty codes, but I will fix those bugs when I get time.What functions I use...hm, well, *cough cough* hehe..Just contact me further if you want to use it hehe. I'm working on the security too. I have mysql_real_escape_string around everything I think. I'm gonna put on htmlentities when I get time also so.
  19. Anders Moen

    CMS with PHP

    If you don't want to use such things as WordPress or CuteNews, but build your own, like I have done here you can start looking at W3Schools PHP section. That's the codes I've used in my system, but I've just modified them and built on more stuff on the codes and put them together and a lot more.PS: my system is an open source right now, so if you want to try it, just log in with "demo" as username and password. On my system you can make pages and stuff. Yeah, you figure it out yourself.
  20. Anders Moen

    html help

    It's not <a href="#" target="blank" > link </a> but <a href="#" target="_blank"> link </a> (_blank).And if he uses XHTML transitional it will work, but not with strict :)That's why I'm using transitional instead of strict.
  21. I just can't make it work *crying*I really want to learn it cause I can't find any other free hosts WITH databases that's free...
  22. Anders Moen

    forms

    The Master, read what he says next time. He said "save it as an ascii file on the server rather than emailing it". He doesn't want to use e-mail :)But to save things in a file at your server when people clicks at the submit button, you can use this tutorial
  23. Thanks for those comments!This was like "version 1", but in version 2 (I've already started on it).In version 2 it might come with a pm system (don't know how yet lol), and maybe some more. But I just finished the version 1 (which has some bugs in the title and stuff lol), and some more features. If you have any suggestions/improvements about it, please tell me so I can add more in version 2 and fix bugs in version 2
×
×
  • Create New...