Jump to content

ngreenwood6

Members
  • Posts

    1,356
  • Joined

  • Last visited

Everything posted by ngreenwood6

  1. i have one question in the table that you are querying does it have their place? For example if the high scores table holds my place i would be 20.
  2. should be: $query = "SELECT * FROM table WHERE something='something' ORDER BY name DESC, age ASC";
  3. That's awesome good find
  4. ok with the export that you gave me I ran this: SELECT messages.id,messages.message,messages.uid,messages.time,messages.board,messages.flagged,members.username FROM messages Left Join members ON messages.uid = members.id Left Join boards ON messages.board = boards.id Left Join events ON boards.id = events.board Left Join leagues ON events.league = leagues.id WHERE leagues.id = 1 It gave me 1 result, but that was only because the export that you sent me only had one event in it. I changed the id to 1 because there was no event id with 2 with the export that you gave me. Hopefully that will work for you. however, it is always better to link other tables to tables that you need to use info from it so you have a link to it. for instance you should probably add a lid field that holds the league id in the messages table. There is nothing wrong with doing that it is there so that you can link it using that. If you dont use links like that sometimes the info that you get will be off or you will have to go about doing it in a long way.
  5. yeah it wont hurt to learn there are alot of good examples out there.
  6. one common method is to set a cookie or a session value with the page that they were on. for example when the user visits protectedpage.php and doesnt have rights you would set a cookie with that pages location. then when the user logged in on login.php you would check if that cookie was set and if so you would redirect them to the url that is in the cookie and if not you would redirect them to there normal page. same idea for sessions but typically session arent set until a user is logged in thats why i went with the cookie example.
  7. here you go. i have left a little implementation for you but here is the basics. <?php //create the rectangle object $rectangle = new Rectangle(); //set the length and width $rectangle->setLength(3); $rectangle->setWidth(20); //get the area $area = $rectangle->calculateArea(); //display the area echo $area; class Rectangle{ private $length; private $width; public function setLength($length){ if(is_numeric($length) && $length > 0 && $length < 20){ $this->length = $length; } else { //do something here if its not a number, less than 0 or greater than 20 } } public function setWidth($width){ if(is_numeric($width) && $width > 0 && $width < 20) { $this->width = $width; } else { //do something here if its not a number, less than 0 or greater than 20 } } public function getLength(){ return $this->length; } public function getWidth(){ return $this->width; } public function calculateArea(){ return $this->length * $this->width; } } ?>
  8. worked for me when i did test.php?status=1
  9. i was bored so i figured I would help you out. I added the stuff at the top so you could see how to use it. the last part i left for you with the array. <?php $dog = new Dog('dog',50); $cat = new Cat('cat',25); $dog->speak(); echo '<br />'; $cat->speak(); abstract class Pet{ private $name; abstract protected function speak(); function __construct($name){ $this->setName($name); } protected function setName($name){ $this->name = $name; } protected function getName(){ return $this->name; } } class Cat extends Pet{ private $weight; function __construct($name, $weight){ $this->setName($name); $this->setWeight($weight); } private function getWeight(){ return $this->weight; } protected function setWeight($weight){ $this->weight = $weight; } public function speak(){ echo 'I am a '.$this->getName().' and I weigh '. $this->getWeight(); } } class Dog extends Pet{ private $weight; function __construct($name, $weight){ $this->setName($name); $this->setWeight($weight); } private function getWeight(){ return $this->weight; } protected function setWeight($weight){ $this->weight = $weight; } public function speak(){ echo 'I am a '.$this->getName().' and I weigh '. $this->getWeight(); } } ?>
  10. yeah the ( should be a { but you should always use hex codes(#000000 for black) for the colors. If you are using dreamweaver there is a color selector lol
  11. please do not use oni-kuns method and I will tell you why. Say you have 20 users in the database but maybe some of the other users were deleted leaving there id blank this would fail. The reason is say you had 25 registered but 5 were removed. the last id would be 25. Now if you used the method that oni-kun suggests it would select the count (or 20 in this case) as the id which would not be the correct id. Also that id might not even exist if it was one that was deleted.
  12. if you are using an autoincrement id you could do: $query = "SELECT * FROM users ORDER BY id DESC LIMIT 1"; The reason I did that is by doing it DESC you will get the last user and it will only return 1 result that way it doesnt go through all the users.
  13. ok so is it working?
  14. ngreenwood6

    Hello

    We have already met but I figured I would stop in and say welcome!
  15. oh sorry about that teh echo statement should also be inside of the if statement.
  16. just change the $Time variable to $Time = time(); that will give you a timestamp (something like 098767762348). You will need to store this into an int field (usually i set it to 20 just to be safe that the whole timestamp will be set there). Then when you need to show it you will do $date = date('m/d/Y',$Time);.
  17. try this: <?php $query = "SELECT *, substring(`title`,1,1) AS firstLetter FROM feudal WHERE `type` = 'Fanart' GROUP BY title, author ORDER BY title"; $result = mysql_query( $query ) or die(mysql_error()); $words = array('1','2','3','4','5','6','7','8','9','+'); $firstLetter = ''; while ($row = mysql_fetch_assoc($result)) { $url = $row[url]; $author = $row[author]; $title = $row[title]; if(in_array($firstLetter,$words)){ if($firstLetter != '#'){ $firstLetter = '#'; } echo '<h3><a name="'.$firstLetter.'">'.$firstLetter.'</a></h3>'; } else if (ucwords($firstLetter) != ucwords($row['firstLetter'])) { //Assign category to holding var $firstLetter = $row['firstLetter']; //echo firstLetter heading echo '<h3><a name="'.$firstLetter.'">'.$firstLetter.'</a></h3>'; } All I did there was add a line to check that the if the first letter has already been assigned and if it has do not repeat it.
  18. It could be because you already have a field name $results or $row, but without seeing the full code its hard to say. in all reality if it worked like that it should be working the other way too. OOP is present in php as well. You can make classes and create properties, methods and variables for those classes (or object). If you are ever going to do any programming in the business world you are going to need to know OOP pretty well. Here is an example of OOP in php: class person{ public $name; } $aperson = new person(); $aperson->name = 'nick'; echo $aperson->name; that is just a class that has a variable $name. then i create the class with a variable $aperson. Then i assign the variable $name in the class to nick then i just echo it to the screen. So OOP is everywhere.
  19. you arent doing the while loop anymore. you are just getting the first result by doing that.
  20. try this: // Check length of $row['album'] and create var $albumName based on it if (strlen($row['album']) >= 30) { $albumName = substr($row['album'],0,30) . '...' ; } else { $albumName = $row['album'] ; } // Echo out table using previously created $albumName echo "</td><td class='listingtitle'>Artist:</td><td><a href='http://megalyrics.net/search.html?c=".$row[artist]."' title='View ".$row[artist]." Lyrics'>".$row[artist]."</a></td></tr><td class='listingtitle'>Album:</td><td><a href='http://megalyrics.net/search.html?c=".$row[album]."' title='View ".$row[album]." Lyrics'>".preg_replace('/\s+?(\S+)?$/', '', $albumName)."...</a></td></tr>"; all i did was add a ) after $albumName because you werent closing the preg_replace function
  21. it looks like your query is failing, you should change your query to this when troubleshooting: $query=mysql_query("SELECT * FROM ip_table ORDER BY ID DESC") or die(mysql_error()); I think the issue is because you are trying to order it by ID but the field is id (different case) so try this: $query=mysql_query("SELECT * FROM ip_table ORDER BY id DESC");
  22. There is a syntax error, the closing parenthesis for preg_replace is missing.
  23. The only reason I can think of that this isnt running is because one of the values arent matching up. without actually being able to see the data and fields its kinda hard to troubleshoot. I would just look at the query and make sure that the tables that are supposed to join up are going to by looking at the values. Another thing that I can suggest is a really nice program that I use. Its called navicat. You must have the full version to do this but there is a query builder in there that will allow you to drag your tables there, select the fields, joins, where and much more for your query. Then you can actually perform the query to see what results you get. Might be worth a look for you. If you would like to upload a sql dump not necessarily with all the data but just something in each of the fields I would be more than happy to import it and see if I can build the query that you need.
  24. nightslyr beat me to it. you need to change your if statement to == and you should be using != for checking that something is not equal to rather than <>.
  25. try this: <?php $query = "SELECT *, substring(`title`,1,1) AS firstLetter FROM feudal WHERE `type` = 'Fanart' GROUP BY title, author ORDER BY title"; $result = mysql_query( $query ) or die(mysql_error()); $words = array('1','2','3','4','5','6','7','8','9','+'); $firstLetter = ''; while ($row = mysql_fetch_assoc($result)) { $url = $row[url]; $author = $row[author]; $title = $row[title]; if(in_array($firstLetter,$words)){ $firstLetter = '#'; echo '<h3><a name="'.$firstLetter.'">'.$firstLetter.'</a></h3>'; } else if (ucwords($firstLetter) != ucwords($row['firstLetter'])) { //Assign category to holding var $firstLetter = $row['firstLetter']; //echo firstLetter heading echo '<h3><a name="'.$firstLetter.'">'.$firstLetter.'</a></h3>'; }
×
×
  • 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.