Jump to content

wintallo

Members
  • Posts

    57
  • Joined

  • Last visited

    Never

Everything posted by wintallo

  1. Hey, I was wondering how I could select the first 20 rows of a MySQL table and insert those same rows into a new table. This is my code for ordering a table by score descending and selecting the first twenty rows and then printing them out on the page. [code] <?php include 'db.php'; if(!isset($_GET['page'])){     $page = 1; } else {     $page = $_GET['page']; } $max_results = 20; $from = (($page * $max_results) - $max_results); $sql = mysql_query("SELECT * FROM tetris ORDER BY score DESC LIMIT $from, $max_results"); while($row = mysql_fetch_array($sql)){     echo "<tr><td>";     echo $row['name'];     echo "</td><td>";     echo $row['score'];     echo "</td><td>";     echo $row['date'];     echo "</td></tr>"; } ?> [/code] What could I do to this code to copy the selected rows into a table called tetris_hs. Thanks for reading. Joel wintallo.com
  2. I just made the field an integer and used fill zeros and it worked fine. Thanks guys! Joel wintallo.com
  3. I got this script from a pagination tutorial on this site an it works great except one thing. I want to add a rank column to a highscore table. The problem is, when it's displayed, the first page's ranks are 1-10, but on the second page, when it should be numbered 11-20, it starts over again at one. How can I fix it so it keeps counting up as you go through the page. Here's the code [code] <table width="500" border="1" align="center" cellspacing="1" cellpadding="2">   <tr>     <td colspan="4"><div align="center"><strong>Tetris Highscores</strong></div></td>   </tr>   <tr>     <td width="37"><strong>Rank</strong></td>     <td width="234"><strong>Name</strong></td>     <td width="38"><strong>Score</strong></td>     <td width="160"><strong>Date</strong></td>   </tr> <?php include 'db.php'; if(!isset($_GET['page'])){     $page = 1; } else {     $page = $_GET['page']; } $max_results = 10; $from = (($page * $max_results) - $max_results); $sql = mysql_query("SELECT * FROM tetris ORDER BY score DESC LIMIT $from, $max_results"); $rank = 1; while($row = mysql_fetch_array($sql)){     echo "<tr><td>";     echo $rank;     echo "</td><td>";     echo $row['name'];     echo "</td><td>";     echo $row['score'];     echo "</td><td>";     echo $row['date'];     echo "</td></tr>";     $rank = $rank + 1; } $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM tetris"),0); $total_pages = ceil($total_results / $max_results); echo "<center>Select a Page<br />"; if($page > 1){     $prev = ($page - 1);     echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> "; } for($i = 1; $i <= $total_pages; $i++){     if(($page) == $i){         echo "$i ";         } else {             echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";     } } if($page < $total_pages){     $next = ($page + 1);     echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>"; } echo "</center>"; ?> </table> [/code] THanks for reading! Joel wintallo.com
  4. Hey, I was wondering how I could concatenate zeros at the beginning of a integer. For example, I would want all variables to have 8 digits so I concatenate. 8 zeros in front of 5 (00000005), 5 zeros in front of 4536 (000004536), etc. I would do this so that when I'm ordering a mySQL database by a field called "score" that it orders correctly. If I don't do this it orders 34880 after 120661. I would want it to automatically calculate how many zeros it would need to concatenate at the beginning of a number.  Thanks for reading. Joel [email protected]
  5. I was wondering if anyone knows how to program a Try HTML script in PHP. If you're not sure what I mean, check out these to pages to see what I'm talking about. http://photobucket.com/practice.php http://www.w3schools.com/html/tryit.asp?filename=tryhtml_basic IF this isn't possible in php, can it be done in a cgi script? Thanks! wintallo.com
  6. I'm working on a website project where a user must find the password for each level by going on a hint given each level. Right now I only have the password gate worked out but I want it so users can register for a username. When they complete a level, I want their progress to be recorded with their username.  SO the next time they log in they can start off at the dame level instead of having to start at the first level. If you don't understand what I'm saying, look at [url=http://www.flooble.com/scav/]http://www.flooble.com/scav/[/url]. My server has MySQL and PHP capabilities. To see what my project looks like right now, go to [url=http://scavhunt.wintallo.com/scavenger/]http://scavhunt.wintallo.com/scavenger/[/url]. Thanks!
  7. Hey, I was wondering if anyone knew of a script that checked a user's browser user agent and either let them onto a page, or didn't let them onto a page. I mean, say I required a user to have the user agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6 How would I make it so only people with this user agent could access a page. If you have no idea what i'm talking about, I want something that works like this website. (except not for PSP) http://www.geneonanimation.com/psp/ Thanks! Joel wintallo.com
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.