Jump to content

wwfc_barmy_army

Members
  • Posts

    320
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

wwfc_barmy_army's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. Ahhh, spotted it: echo '' . $set_limit . ''; was coming after the correct number as there was no line space inbetween. Thanks anyways guys, knew it was something stupid lol. ::edit:: I tend to tidy up my code after i get it working (bad habit lol)
  2. The output from the total records is coming out a lot more than it should be. Was 80 (first page of paginiation) and 85 (second page), but now i've added 1 more record it's gone up to 90 (first page) and 95 (second Page). Should be 8 and 9. Any ideas?
  3. But i need that code there to be able to get the total number of records at the top of the page.
  4. Here we go: <?php $result2 = mysql_query("SELECT * FROM inputs WHERE user_id = " . $userid); if(!$result2){ die("Error quering the Database: " . mysql_error());} $total_items = mysql_num_rows($result2); echo "Total Number of records in Database: " . $total_items; $limit= $_GET['limit']; $page= $_GET['page']; //Set default if: $limit is empty, non numerical, //less than 10, greater than 50 if((!$limit) || (is_numeric($limit) == false) || ($limit < 10) || ($limit > 50)) { $limit = 5; //default } //Set default if: $page is empty, non numerical, //less than zero, greater than total available if((!$page) || (is_numeric($page) == false) || ($page < 0) || ($page > $total_items)) { $page = 1; //default } //calcuate total pages $total_pages = ceil($total_items / $limit); $set_limit = ($page * $limit) - $limit; echo '' . $set_limit . ''; ?> <table width="80%" border="1" class="sortable"> <thead> //////// ////////.. Table Headers ... //////// </thead> <?php $sql = "SELECT * FROM inputs WHERE user_id = " . $userid . " LIMIT " . $set_limit . ", " . $limit; $result = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($result)){ // //...Some outputs...// ?> <tr> //...Some outputs...// </tr> <?php } echo "</table>"; //prev. page: $prev_page = $page - 1; if($prev_page >= 1) { echo("<a href='?limit=$limit&page=$prev_page'><< Prev</a>"); } //Display middle pages: for($a = 1; $a <= $total_pages; $a++) { if($a == $page) { echo(" $a | "); //no link } else { echo(" <a href='?limit=$limit&page=$a'>$a</a> | "); } } //next page: $next_page = $page + 1; if($next_page <= $total_pages) { echo("<a href='?limit=$limit&page=$next_page'> Next > > </a>"); } ?>
  5. Hello. I have this piece of code: $result2 = mysql_query("SELECT id FROM mytable WHERE user_id = " . $userid); if(!$result2){ die("Error quering the Database: " . mysql_error());} $total_items = mysql_num_rows($result2); echo "Total Number of records in Database: " . $total_items; It works, but is producing a much larger value than the database is. The value from the code above is showing 80 on page 1 and 85 on page 2. (should be exactly the same) and the table only shows 5 on page 1 and 3 on page 2. They are using virtually the same sql (the table using a wildcard to get all records) Can anyone see what I'm doing wrong? I used a tutorial similar to this to create pagination if that helps: http://mtbud420.com/?p=76 Thanks.
  6. Is there a way to get the tables in a database and list them? Is there any issues with doing this? Thanks. Peter.
  7. Thanks for your advice HuggieBear. :) Thanks. Peter.
  8. Ah, so whats the advantage of having php 4 over php 5 and is there a reason i shouldn't update? Thanks.
  9. Thanks for your reply i have version PHP Version 4.4.3. Is this the problem? Thanks. Peter.
  10. Hello. I have been developing a site on my personal webserver on my computer but today i went to make it live on the net but i am getting this error on my server but not on my personal webserver: [quote]Fatal error: Call to undefined function: date_default_timezone_set() in /home/rpgsfind/public_html/site.php on line 72[/quote] It's with this bit of code: [code=php:0] <?php date_default_timezone_set("US/Eastern"); list($year, $mon, $day) = explode('-', $qry[4]); $sevenDays = (7 * 24 * 60 * 60); // 604,800 seconds in 7 days $entryTime = strtotime("$year-$mon-$day"); $now = strtotime("now"); if (($now - $entryTime) < $sevenDays) { echo "<img src='images/new.gif'>"; } ?> [/code] Why isn't it working on the live server, do i need to change something? any advice is welcome. Thanks. Peter.
  11. Oh yeah. Sorry it does. Didn't realise :P Thanks for all your help alpine. :) Peter.
  12. Thanks alpine :) is there a way to make it so for the drop down boxes it selects the value that is already in the database? I tried using value= in it but that didn't work. Any ideas? Thanks. Peter.
  13. this is the lastest code with dateadded: [code]<?php include '../includes/dbconnect.php'; if(isset($_POST['save'])) { foreach($_POST as $formfieldname => $postedvalue) { ${$formfieldname} = htmlspecialchars($postedvalue); } $update = mysql_query("UPDATE site SET name = '$name', sitelink = '$sitelink', sitedownload= '$sitedownload', dateadded = '$dateadded', publisher = '$publisher', filesize = '$filesize', graphics = '$graphics', review = '$review', limitations = '$limitations', requirements = '$requirements', pros = '$pros', cons = '$cons', editorrating = '$editorrating', publisherinfo = '$publisherinfo', onoffline = '$onoffline' WHERE id = '$id'") or die(mysql_error()); if(mysql_affected_rows()==1) { print "Site '$name' updated"; } else { print "Nothing was changed"; } } if(!empty($_GET['id'])) { $id = $_GET['id']; settype($id, "integer"); $select = mysql_query("SELECT * FROM site WHERE id = '$id'") or die(mysql_error()); if(mysql_num_rows($select)=="1") { $col = mysql_fetch_array($select, MYSQL_ASSOC); foreach($col as $fieldname => $value) { ${$fieldname} = $value; } } else { print "No unique record found with ID: $id"; } } echo <<<_HTML <table width="700" border="0" cellpadding="2" cellspacing="1" align="center"> <form method="post" action="$PHP_SELF"> <input type="hidden" name="id" value="$id"> <tr> <td width="100">Date Added</td> <td><input name="dateadded" DISABLED type="date" value="$dateadded"></td> </tr> <tr> <td width="100">Site Name</td> <td><input name="name" type="text" value="$name"></td> </tr> <tr> <td width="100">Site Link</td> <td><input name="sitelink" type="text" value="$sitelink"> (not including http://) </td> </tr> <tr> <td width="100">Download Link</td> <td><input name="sitedownload" type="text" value="$sitedownload">   (not including http://) </td> </tr> <tr> <td width="100">Publisher</td> <td><input name="publisher" type="text" value="$publisher"></td> </tr> <tr> <td width="100">Filesize (MB) </td> <td><input name="filesize" type="text" value="$filesize"> (If none (eg online gaming) then leave blank) </td> </tr> <tr> <td width="100">Limitations</td> <td><input name="limitations" type="text" value="$limitations"></td> </tr> <tr> <td width="100">Requirements</td> <td><input name="requirements" type="text" size="50" value="$requirements"></td> </tr> <tr> <td width="100">2D, 3D or TB </td> <td><select name="graphics" value="$graphics"> <option value="2D">2D</option> <option value="3D">3D</option> <option value="Text Based">TB</option> </select> </td> </tr> <tr> <td width="100">Online, Offine </td> <td><select name="onoffline" value="$onoffline"> <option value="Online">Online</option> <option value="Offine">Offline</option> <option value="Either">Either</option> </select> </td> </tr> <tr> <td width="100">Review</td> <td><textarea name="review" cols="50" rows="10">$review</textarea></td> </tr> <tr> <td width="100">Pros</td> <td><input name="pros" type="text" size="66" value="$pros"></td> </tr> <tr> <td width="100">Cons</td> <td><input name="cons" type="text" size="66" value="$cons"></td> </tr> <tr> <td width="100">Editor Rating</td> <td><select name="editorrating" value="$editorrating"> <option value="0">0</option> <option value="12">1</option> <option value="1">2</option> <option value="15">3</option> <option value="2">4</option> <option value="25">5</option> <option value="3">6</option> <option value="35">7</option> <option value="4">8</option> <option value="45">9</option> <option value="5">10</option> </select> </tr> <tr> <td width="100">Publisher Information </td> <td><textarea name="publisherinfo" cols="50" rows="10">$publisherinfo</textarea></td> </tr> <tr> <td width="100">&nbsp;</td> <td>&nbsp;</td> </tr> <tr> <td colspan="2" align="center"> <input name="save" type="submit" class="box" value="Edit this site"></td> </tr> </table> </form> </td> </tr> </table> </body> </html> _HTML; ?>[/code] Thanks.
  14. Hmm, also even though i have added a dataadded field aswell when i edit a record it sets the date to 0000-00-00, any ideas why? Thanks. Peter.
  15. Thanks for your help. You've been great! :) Just one thing, is there a way to make it so for the drop down boxes it selects the value that is already in the database? I tried using value= in it but that didn't work. Any ideas? Thanks again. Peter.
×
×
  • 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.