Jump to content

shergold

Members
  • Posts

    95
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

shergold's Achievements

Member

Member (2/5)

0

Reputation

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta name="generator" content= "HTML Tidy for Linux/x86 (vers 11 February 2007), see www.w3.org" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <style type="text/css"> #wrapper { width:680px; margin: 0 auto; padding: 0 20px; border-left: 1px solid #666666; border-right: 1px solid #666666; font-family: Georgia, Times, serif; } h1 { color:red; font-size: 2em; font-family: Aria, sans-serif; margin: 0; border-bottom: 2px dashed black; } h2 { } p { color: #003366; font-size: .9em; line-height: 150%; margin-top: 0; width: 400px; } .side { float: right; width: 200px; margin: 10px; padding: 5px; border: 1px solid; background-color: #CCCCCC; } #footer { clear: left; margin: 20px 10px; } </style> <title>Webpage Title</title> </head> <body> <div id="wrapper"> <div id="banner"></div> <h1>Website Title</h1> <div class="news"> <h2>News Item 1</h2> <p>Lorem ipsum dolor sit amet,consectetur adipiscing elit.Praesent vitae dolor risus, ultricies condimentum felis. In eget nisl risus. Fusce auctor euismod sapien ac facilisis. Vestibulum a dolor sed nisl gravida sagittis vel vitae tortor. In varius auctor sem, id faucibus tellus posuere a.Suspendisse quis arcu turpis, in pellentesque.</p> </div> <div class="news"> <h2>News Item 2</h2> <p>Lorem ipsum dolor sit amet,consectetur adipiscing elit.Praesent vitae dolor risus, ultricies condimentum felis. In eget nisl risus. Fusce auctor euismod sapien ac facilisis. Vestibulum a dolor sed nisl gravida sagittis vel vitae tortor. In varius auctor sem, id faucibus tellus posuere a.Suspendisse quis arcu turpis, in pellentesque.</p> </div> <div class="side"> <h3>Events</h3> <ul> <li>14/05/10 - Event name</li> <li>15/05/10 - Event name</li> <li>16/06/10 - Event name</li> </ul> </div> <div class="side"> <h4>Address</h4> <address> 15 lorem road,<br /> Impsum,<br /> England </address> </div> <div class="side"> <h4>Newsletter signup</h4>Recieve news and events via email <form action="newsletter.php" method="get"> <fieldset> Email: <input type="text" id="email" /><br /> <input type="submit" value="submit" /> </fieldset> </form> </div> <div id="footer"> <i>Copyright 2010</i> </div> </div> </body> </html> Hey everyone, Im having trouble getting the side boxes to float to the right of the text, any help is appriciated. Thanks, Shergold.
  2. umm.... how do you expect someone to be able to tell you a solution to the problem if we cannot see your code? please post it. shergold.
  3. also if i change the x and y values in the database the sprite still stays in the same location when i refresh the page which is in the first table square. Thanks, shergold.
  4. I've added the brackets, although it makes no difference.
  5. Hey guys, i was wondering if anyone could help me with the following php script that i have created, it is meant to be a game that allows a player sprite to move about a html table. When i click up it allows me to move off the board, it also wont allow me to move down at all and only one space left or right. the If statements that create the boundrys and meant to stop the sprite going off the board although its stopping moving about the board aswell. <?php $userName = "administrator"; function newGame(){ } function move(){ global $x, $y, $userName; //Move up/North if (isset($_POST['up'])) { $y = $y + 10; if ($y <= 100) $moved = 1; else { $y = $y - 10; echo "You cant move any further forward as you have reached the boundry"; } } //Move down/South elseif (isset($_POST['down'])) { $y = $y - 10; if ($y > 10) $moved = 1; else { $y = $y + 10; echo "You cant move any further south as you have reached the boundry"; } } //Move left/West elseif (isset($_POST['left'])) { $x = $x - 1; if ($x >= 0) $moved = 1; else { $x = $x + 1; echo "You cant move any further west as you have reached the boundry"; } } //Move right/East elseif (isset($_POST['right'])) { $x = $x + 1; if ($x <= 100) $moved = 1; else { $x = $x - 1; echo "You cant move any further east as you have reached the boundry"; } } //update user location if ($moved == 1) { require "connect.php"; $connection = mysql_connect($hostname, $username, $password) or die ("Cannot connect to the database server.") or die("cannot connect to the game server."); mysql_select_db($database, $connection); mysql_query("UPDATE location SET x = '$x' AND y = '$y' WHERE username = '$userName'"); } return $x; return $y; } function location(){ global $x, $y, $userName; // retrieve user location from database require "connect.php"; $connection = mysql_connect($hostname, $username, $password) or die ("Cannot connect to the database server."); mysql_select_db($database, $connection); $query = mysql_query("SELECT * FROM location WHERE username = '$userName'"); $result = mysql_num_rows($query); $location = mysql_fetch_assoc($query); if (!$result == 0) { $x = $location[0]; $y = $location[1]; } else echo "Cannot find location of user: $userName"; echo $x; echo $y; } function tile(){ $tile = "grass"; return $tile; } function render($rows = 10 , $cols = 10 , $tileWidth = 50 , $tileHeight = 50 ){ //functions location(); move(); //global variables global $userName, $lvl, $x, $y; $gameWidth = $cols * $tileWidth; $gameHeight = $rows * $tileHeight; $game = "<table frame=\"border\" width=\"$gameWidth\" height=\"$gameHeight\" cellpadding=\"0\" cellspacing=\"0\">\n"; // while there is more tiles to display keep looping for ($i = 0; $i < $rows; ++$i) { $game .= "<tr>\n"; for ($j = 0; $j < $cols; ++$j) { //if user location is equal to tile location display user if ($i == $y && $j == $x) $game .= "<td width=\"$tileWidth\" height=\"$tileHeight\" background=\"" . tile() . ".gif\"> <img src=\"mod.gif\" alt=\"$userName\" title=\"$userName\nlevel: $lvl\">\n</td>\n"; //else display no user else $game .= "<td width=\"$tileWidth\" height=\"$tileHeight\" background=\"" . tile() . ".gif\">\n</td>\n"; } $game .= "</tr>\n"; } print $game . "</table>\n"; } function error() { $message = ""; echo $message; } ?> Thanks allot, shergold.
  6. ah thankyou, yeah $y had a value of 0 . Shergold.
  7. ok thanks for everyones help, im also having trouble with the following if statement doing the same as the previous: elseif (isset($_POST['down'])) { $y = $y - 10; if ($y >= 0) $moved = 1; else { $y = $y + 10; echo "You cant move any further south as you have reached the boundry"; } }
  8. Hey guys, I was wondering what is wrong with the following code, it should be executing the code that executes when the if is true, but it is executing the else code. $x and $y variables both equal 0. if (isset($_POST['up'])) { $y = $y + 10; if (!$y > 100) $moved = 1; else { $y = $y - 10; echo "You cant move any further forward as you have reached the boundry"; } } Thanks, shergold.
  9. ahhh sorry lol... see it now hehe, accident.
  10. what do you mean? $tile is the variable and grass is the value of the variable.
  11. it still isnt working, heres my actual code function tile(){ $tile = "grass"; return $grass; } function render($rows = 10 , $cols = 10 , $tileWidth = 50 , $tileHeight = 50 ){ $gameWidth = $cols * $tileWidth; $gameHeight = $rows * $tileHeight; $game = "<table frame=\"border\" width=\"$gameWidth\" height=\"$gameHeight\" cellpadding=\"0\" cellspacing=\"0\">\n"; // while there is more tiles to display keep looping for ($i = 0; $i < $rows; ++$i) { $game .= "<tr>\n"; for ($j = 0; $j < $cols; ++$j) { //if user location is equal to tile location display user if ($i == $y && $j == $x) $game .= "<td width=\"$tileWidth\" height=\"$tileHeight\" background=\"" . tile() . ".gif\"><img src=\"mod.gif\" alt=\"tile\">\n</td>\n"; //else display no user else $game .= "<td width=\"$tileWidth\" height=\"$tileHeight\" background=\"" . tile() . "gif\">\n</td>\n"; if you cant put tile() in the middle of a variable is there anyway i can put the value of tile() in there?
  12. Hey guys, i was just wondering if anyone could point me in the right direction. Im trying to update the value of a variable in a function then use it outside of the function , for example; <?php function update(){ $tile = "grass"; } echo $grass; ?> I have tried using return $grass at the end of the function but it still isnt working. Thanks, shergold.
  13. Wow Ignace much simpler, i just fixed my code before you posted that but i think i will be using yours, thankyou very much! Also thankyou very much Cezar for your help. Shergold.
  14. no, if (($count % 10) == 0) doesnt work. The if statements are to put a <tr> to start a new row after every 10 tiles have been places in the table. So what im trying to do is at the start put a <tr> for the first row then put a </tr> when 10 have been placed then put <tr> for the next row and so on.
  15. Hey guys, basicly im trying to make a tile based game, but the tiles arnt displaying as i want them to, there should be 10 rows of 10 but it is displaying with the first row in the table containing 11 tiles and the last containing 9. I have tried changing the values in the if loops that add <tr> and </tr> but just cant seem to get it. Thanks allot for any answers as i really appriciate any help that can be given. <?php //Test Array function draw_game() { for ($counter = 0; $counter <= 99; $counter++) { $tiles["$counter"] = "test"; } $count = 0; echo "<table frame=\"border\" width=\"500\" height=\"500\" cellpadding=\"0\" />\n"; //for each of the tiles execute the code foreach( $tiles as $id => $tile) { //add start of table row tag if count is equal to 10,20,30 if ($count == 0 || $count == 11 || $count == 21 || $count == 31 || $count == 41 || $count == 51 || $count == 61 || $count == 71 || $count == 81 || $count == 91) { echo "<tr>\n"; } echo "<td width=\"50\" height=\"50\" alight=\"left\" valign=\"bottom\" />\n"; //check what tile image to output, default is grass switch($id) { case 999: echo "<img src=\"$id.gif\" alt=\"$tile\"/>\n"; break; default: { echo "<img src=\"grass.gif\" alt=\"$tile\"/>\n"; echo $count; } } echo "</td>\n"; //add end of table row tag if count is equal to 10,20,30 if ($count == 10 || $count == 20 || $count == 30 || $count == 40 || $count == 50 || $count == 60 || $count == 70 || $count == 80 || $count == 90 || $count == 100) { echo "</tr>\n"; } ++$count; } echo "</table>\n"; } ?> thanks, shergold.
×
×
  • 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.