Jump to content

pocobueno1388

Members
  • Posts

    3,369
  • Joined

  • Last visited

    Never

Everything posted by pocobueno1388

  1. <?php if (isset($_POST['sort'])){ $sort = $_POST['sort']; if ($sort == '1') $url = "www.something.php"; if ($sort == '2') $url = "www.somethingelse.php"; //keep going like this header("Location: $url"); } ?> <form id="sort" name="sort" method="post" action="action.php"> <label> <select name="select"> <option value="#">Sort By...</option> <option value="0">All Members</option> <option value="1">Username</option> <option value="2">Last Online</option> <option value="3">Online Only</option> <option value="4">Offline Only</option> </select> </label> </form>
  2. Show more code that is around line 47. Your query should have been giving an error though, and what I changed it to should have fixed that.
  3. Change it to this <?php $query = mysql_query("SELECT u.username FROM users u INNER JOIN active_users a ON a.username=u.username WHERE a.timestamp < (NOW() - INTERVAL 5 MINUTE) AND u.username='{$req_user_info['username']}'")or die(mysql_error()); ?>
  4. Your going to have to give a lot more of a description than that.
  5. Here, I will give you some example code to look at. <?php //select message from db $query = mysql_query("SELECT message FROM table"); $row = mysql_fetch_assoc($query); //This will echo out the ENTIRE message echo $row['message']; //Now to change it so it only echos out some of the message, we do this $message = substr($row['message'], 0, 15); echo $message.'...'; //will print the first 15 letters, then add a ... ?>
  6. They just use the substr() function to show a limited amount of text, then add the "..." to the end. Then the more link will lead to a page that will have the message ID in the URL, and it will display the entire message on that page. www.php.net/substr
  7. You need to try and catch the error. Try changing your code to this <?php $sql = "SELECT count(*) AS count FROM subscribers"; $result = mysql_query($sql ,$db)or die(mysql_error()); $row = mysql_fetch_assoc($result); $subscribers = $row['count']; ?>
  8. I'm assuming your url looks something like this? www.domain.com/page.php?letter=a You could put this code at the top of the pages <?php session_start(); if (isset($_GET['letter'])){ $_SESSION['letter'] = $_GET['letter']; } ?>
  9. You could pass a function an array of field names and then an array of values that correspond to the fields. Here is a simple function. <?php function insert($fields, $values){ $query = "INSERT INTO table (".implode(',', $fields).") VALUES (".implode(',', $values).")"; $result = mysql_query($query)or die(mysql_error()); } ?> Example use <?php $fields = array("1", "2", "3"); $values = array("uno", "dos", "tres"); insert($fields, $values); ?>
  10. Yes, a screen shot would be nice. The code may be useful as well.
  11. Use nl2br() when displaying the row from the database. www.php.net/nl2br
  12. Definitely a warm, wet winter. I'm happy to be living in Florida during winter, so far it's been 70+ degrees everyday. The only thing I miss about snow is being able to ski. Earthquake or Hurricane
  13. It would help if you added a mysql_error catch to the queries like this <?php mysql_query("INSERT INTO users (Promo) VALUES ('$PromoGot')")or die(mysql_error()); mysql_query("INSERT INTO pokemon_info (user_id, pokemon_name, pokemon_attack, pokemon_defence, pokemon_image, pokemon_gender, pokemon_icon, pokemon_level, pokemon_exp, nexp, attack1, attack2, attack3, attack4, pokemon_slot) VALUES ('$ID', '$PokemonName', '$Attack', '$Defence', '$Image', '$PromoGender', '$Icon', '$Level', '$EXP', '$NEXP', '$Attack1', '$Attack2', '$Attack3', '$Attack4', '$AP_Slot')")or die(mysql_error()); ?>
  14. Here is another working example you can look at <?php $limit = 10; $query_count = "SELECT count(*) FROM table"; $result_count = mysql_query($query_count) or die("Error: " . mysql_error()); $totalrows = mysql_result($result_count, 0, 0); $numofpages = ceil($totalrows/$limit); if (isset($_GET['page'])) $page = $_GET['page']; else $page = 1; $offset = ($page - 1) * $limit; $query = "SELECT * FROM table LIMIT $offset, $limit"; echo $query .'<br>'; $result = mysql_query($query) or die("Error: " . mysql_error()); //Exit if no records to display if (mysql_num_rows($result) == 0) { exit("Nothing to Display!"); } while ($row = mysql_fetch_array($result)) { echo $row['col']."</br>"; } //Enable the Prev link if not first page if ($page > 1) { echo("<a href=\"index.php?page=".($page-1)."\">PREV</a> "); } else { echo("PREV "); } //Create links for each page in report for ($i=1; $i<=$numofpages; $i++) { if ($i == $page) { echo "$i "; } else { echo "<a href=\"index.php?page=$i\">$i</a> "; } } //Enable the Next link if not last page if ($page < $numofpages) { echo("<a href=\"index.php?page=".($page+1)."\">NEXT</a>"); } else { echo("NEXT"); } ?>
  15. That method would work, but using joins is more efficient. Also, there is no reason to alias the field names as you did in that query.
  16. You need a construct function <?php class Rectangle { var $width; var $height; function __construct($width, $height){ $this->width = $width; $this->height = $height; } //...the rest of the class code here } $myRectangle = new Rectangle(10,20); ?>
  17. SELECT i.item, c.name FROM items i LEFT JOIN categories ON i.category = c.id
  18. <?php $data = mysql_query("SELECT * FROM users WHERE userid_2 > 0 ORDER BY rand()") or die(mysql_error()); $num_rows = mysql_num_rows($data); echo $num_rows; //will echo how many rows were returned from the query ?>
  19. Like this SELECT * FROM table ORDER BY rand()
  20. Eck! Neither. I don't think either of them should even exist Hot Weather or Cold Weather
  21. Not much difference there, but I will go with Coke. Chocolate or Vanilla
  22. I'm using Windows. Should it matter?
×
×
  • 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.