Jump to content

TrueColors

Members
  • Posts

    45
  • Joined

  • Last visited

About TrueColors

  • Birthday 06/10/1972

Profile Information

  • Gender
    Not Telling

TrueColors's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. From my understanding, you have a list of Names and when you select one - you want the relevant ID to be in the textbox. That is exactly what I did. The value attribute contains the ID of the username.
  2. Try something like this. The value in the dropdown is the ID of the user. <script type="text/javascript"> function showid ( val ) { document.forms[0].elements['id'].value = val; } </script> <form> <select onchange="showid(this.value)"> <option value="-1" selected disabled>Select One</option> <option value="1">Username 1</option> <option value="2">Username 2</option> </select> <input type="text" name="id" /> </form>
  3. You will have to explain what it is you are trying to achieve.
  4. I also recommend XAMPP (link in creata.physics post)
  5. What about gizmola's solution? Also, what's bad about using count() inside for() ?
  6. You could check if a cropped file exists, if so - load that image else crop the original image and save it as a cropped file. That should dramatically lower CPU usage.
  7. Not guaranteed to work but what does produce: SELECT SUM(`count`) as itemcount, item_id FROM order_list GROUP BY item_id ORDER BY itemcount DESC LIMIT 10
  8. Your use of "database" is not allowed, because it's part of MySQL syntax. You can prevent this from happening by using back ticks around the table name eg: `database` or changing the table name to something different.
  9. mysql_query returns a resource on success and false on failure. As the parameter passed is not a resource states that your query is indeed failing due to an error of some kind. Please use the following format: $result = mysql_query ( "SELECT Name FROM empdata ORDER BY Name ASC" ) or trigger_error ( mysql_error ( ) ); What this does, if an error were to occur it'll throw an error. The key function here is mysql_error.
  10. I believe you'd need your JavaScript inside the page that the iFrame includes.
  11. I have a little class you may use. The class uses a db handler aswell... which is what $db is. It features functions like "execute" and a few others. You may look in the class to see what is used. You can replace them with mysql_* or whatever you desire if you do not have a $db handler. It'll require some changes but it would be fine. the 20 inside the instancing of the class, is the amount of rows per page to be displayed. The "page" is the ID, so ... url would be www.site.com/index.php?page=1 (note the "page" in the url) The query below also uses the FULL query. The class handles it and uses some changes to create the count() function in mysql. The rest is self explanatory. Here is this little bit: $page = new Pagination ( $db, 20, "page" ); $page -> buildQueryString (); $page -> setQuery ( "SELECT column FROM table" ); $page -> setNumberRows (); $page -> setPages (); $page -> setCurrentRow (); foreach ( $page -> getResults () as $result ) { // your content here... $result is an array of the columns from your database. } Here is the class... <?php /** * Name: Pagination Object * Author: Andrew Judd * Date: May 14, 2011 */ class Pagination { /** * An instance of the database object */ private $db = NULL; /** * The query which will be run. */ private $query = NULL; /** * The total number of rows that the full query will return. */ private $numRows = NULL; /** * The number of rows to return per page. */ private $perPage = NULL; /** * The number of the current page. */ private $curPage = NULL; /** * The number of the first page. */ private $firstPage = 1; /** * The number of the last page. */ private $lastPage = NULL; /** * The number of the current row. */ private $curRow = NULL; /** * The $_GET page identifier */ private $pageID = NULL; /** * The url QUERY string */ private $queryString = NULL; /** * The three-argument constructor which takes in the connection to the database. * @param mixed $db - The database object * @param int $perPage - The number of rows per page * @param string $pageIdentifier - The page identifier */ public function __construct ( $db, $perPage = 20, $pageIdentifier = 'page' ) { $this -> db = $db; $this -> perPage = $perPage; $this -> pageID = $pageIdentifier; } /** * This function will build the URL Query String and remove any current page ID's */ public function buildQueryString () { if ( isset ( $_SERVER [ 'QUERY_STRING' ] ) && !empty ( $_SERVER [ 'QUERY_STRING' ] ) ) { $ex = explode ( "&", $_SERVER [ 'QUERY_STRING' ] ); foreach($ex as $k => $query) { if ( preg_match ( "/" . $this -> pageID . "(.*)\b/", $query ) ) unset ( $ex [ $k ] ); } if ( count ( $ex ) > 0 ) { $this -> queryString = implode ( "&", $ex ) . '&'; } } } /** * The setter for the query. * @param string $query - The query which will be run */ public function setQuery ( $query ) { $this -> query = $query; } /** * This function will set the current and last page. */ public function setPages () { $this -> lastPage = ceil ( $this -> numRows / $this -> perPage ); if ( !isset ( $_GET [ $this -> pageID ] ) || $_GET [ $this -> pageID ] < $this -> firstPage) { $this -> curPage = $this -> firstPage; } else if ( $_GET [ $this -> pageID ] > $this -> lastPage) { $this -> curPage = $this -> lastPage; } else { $this -> curPage = $_GET [ $this -> pageID ]; } } /** * This function will set the current row based upon * the current page and rows per page */ public function setCurrentRow () { $this -> curRow = ( $this -> curPage - 1 ) * $this -> perPage; } /** * This function is used in order to set the number of rows * that will be returned from the full query. */ public function setNumberRows () { /* Make sure that the query is set */ if ( $this -> query == NULL ) { /* Query wasn't set, so the number of rows is -1 */ $this -> numRows = -1; } else { /* Build the query to retrieve how many rows are present */ $sql = preg_replace ( '/SELECT (.*) FROM\b/' , 'SELECT COUNT(*) AS NumRows FROM' , $this -> query ); $query = $this -> db -> execute ( $sql ); $r = $this -> db -> fetchassoc ( $query ); /* Return the number of rows that are present */ $this -> numRows = $r [ 'NumRows' ]; } } /** * This function is used in order to retrieve an array of results * that will be returned from the full query */ public function getResults () { /* Build and execute the query to retrieve the amount of rows set */ $sql = $this -> query . ' LIMIT ' . $this -> curRow . ', ' . $this -> perPage; $query = $this -> db -> execute ( $sql ); $results = array (); while ( $row = $this -> db -> fetchassoc ( $query ) ) { $results[] = $row; } return ( $results ); } /** * This function is used to retrieve a list of Pages which would * be used for the page navigation */ public function getPageNavigation () { $links = ''; if ( ( $this -> curPage - 5 ) > $this -> firstPage ) $links .= '<a href="?' . $this -> queryString . $this -> pageID . '=' . $this -> firstPage . '">First</a> ... '; for ( $i = ($this -> curPage - 5 ); $i <= ( $this -> curPage + 5); $i++ ) { if ( $i >= $this -> firstPage && $i <= $this -> lastPage ) { $links .= '<a href="?' . $this -> queryString . $this -> pageID . '=' . $i . '">' . ( ( $i == $this -> curPage ) ? "[$i]" : $i ) . '</a> '; } } if ( ( $this -> curPage + 5 ) < $this -> lastPage ) $links .= ' ... <a href="?' . $this -> queryString . $this -> pageID . '=' . $this -> lastPage . '">Last</a>'; return($links); } } ?> If you don't want to use it, it's fine, don't worry about it. If you have a database handler already... just pass it through when you instance the class... and there is no need to alter the class at all. Just thought I'd share my little ... pagination
  12. Yeah it came back up but two kids were acting innapropiately. One of them was MAU5 which also had nicks of FC, Magician, DashB, etc etc. He's a troll. So CrayonViolent closed it back down. I believe CrayonViolent is trying to get in contact with Daniel, there are no notes left by him so getting the backup and everything is difficult.
  13. You haven't explained properly, neither have you shown any code or explained your problem.
  14. It was down, then it was bought back up by CrayonViolent - though he was having issues. FreakBot wasn't there either, it's hidden somewhere. It's down again now though.
  15. I put the scrollbar on the div. I used JavaScript to loop through the LI's and add the widths, including padding's and any margins. Then that total width is the width of the UL. The JavaScript is: <script type="text/javascript"> function updateULWidth() { var item_width = 0; $("ul#attachmentList li").each(function() { var wide = $(this).width(); $(this).css({'width' : wide + "px"}); item_width += parseInt($(this).css('padding-left')) + parseInt($(this).css('padding-right')) + parseInt($(this).css('margin-left')) + parseInt($(this).width()); }); $("ul#attachmentList").css({'width' : item_width + "px"}); } </script>
×
×
  • 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.