Jump to content

jondo

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jondo's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. cheers for the reply, i don't really trying to learn a whole new area like that though, i have found from past experience that it leaves you with a patchy knowledge of what you are trying to learn, i find tutorials etc better once you actually have a solid grounding in a technology
  2. hi, i am going to be getting a VPS in the near future and would like to get a good book on system administration. if possible it should contain: how to set the server up for LAMP development, configuring apache, php, mysql etc; setup and usage of openSSL and openSSH. i have never had to set up or maintain a server before so the book really needs to start at the beginning. any recommendations? thanks for your help
  3. i see could they add a DOM system which created javascript at runtime for the browser executing the script?
  4. well is there an equivalent of eg using getElementById() to get a division then changing it's css?
  5. Hi, I have recently been introduced to the Document Object Model in javascript however as cross browser compatibility is such an issue I was wondering if the same things or some of the same things can be accomplished in php? cheers
  6. when i used php to create a new file, i checked the permissions and it was 644, even less than i had before, and yet it works, i am just finishing for the day just now and can't be bothered experimenting any more today but tomorrow i will thoroughly check it and find out the exact threshold for writing, and will post when i do. thanks for the help
  7. Hi, I am trying to write to a file with php <?php // set file to write $file = '/home/somedir/text.txt'; // check if file is writable if(is_writable($file)) { // open file $fh = fopen($file, 'w') or die('Could not open file!'); // write to file fwrite($fh, 'Hello, file!') or die('Could not write to file'); // close file fclose($fh); } else { print("file not writable"); } ?> I have set the file and directory it is in to 764 as I thought that would allow php to write to the file, however even after changing it to 764 the file is not writable. could someone please tell me the file permissions needed, or if 764 is correct, what am I doing wrong? any help is much appreciated. (by the way i realise if i just set it to 777 then it will probably work, but I remember reading that you don't want to give any unnecessary write access as this would allow anybody to delete the files or directories. all i want to do is add: the ability for php to write to a file, to the default permission, which is 755 as far as i remember)
  8. haha after trying to sort the logic of this for so long I missed the most obvious mistake! I found the problem in this line: if ($page+$limitpages>$total_pages) { $page_stop==$total_pages; } i used the comparison operator ==, instead of assignment statement = silly me...! all working now thank you all very much for your help, and offers of help cheers
  9. ok I have changed the code at the top which sets the $page_start and $page_stop again, I don't have the minus numbers problem or the too many page links problem, however now, if the page I am on gets past 6 out of 9 (which is $totalpages - $limitpages), then the page number links won't display (ie on page 7, 8 and 9 only previous and next links show) this is the updated code [code] $limitpages = 3; if($page-$limitpages<1) { $page_start==1; } else { $page_start = $page-$limitpages; } if ($page+$limitpages>$total_pages) { $page_stop==$total_pages; } else { $page_stop = $page + $limitpages; } // Build Previous Link if($page > 1){ $prev = ($page - 1); $host = $_SERVER['PHP_SELF'];     echo "<a href=\"".$_SERVER['PHP_SELF']."?category=$category&amp;page=$prev\">&lt;</a>&nbsp;"; } for($i = $page_start; $i <= $page_stop; $i++) { if(($page) == $i){ echo "$i "; } else {             echo "<a href=\"".$_SERVER['PHP_SELF']."?category=$category&amp;page=$i\">$i</a>&nbsp;"; } } // Build Next Link if($page < $total_pages){ $next = ($page + 1);     echo "<a href=\"".$_SERVER['PHP_SELF']."?category=$category&amp;page=$next\">&gt;</a>"; } echo "</div>"; [/code]
  10. thanks mate but i'm afraid it didn't do anything, didn't actually display previous, numbers or next link (I did slot in the code you told me to) i have edited the original code i posted to this [code] $limitpages = 3; if(($page - $limitpages)<=1) { $pagestart==1; } else { $pagestart==$page-$limitpages; } $page_stop = $page + $limitpages; if ($page_stop > $total_pages) { $page_stop==$total_pages; } // Build Previous Link if($page > 1){ $prev = ($page - 1); $host = $_SERVER['PHP_SELF'];     echo "<a href=\"".$_SERVER['PHP_SELF']."?category=$category&amp;page=$prev\">&lt;</a>&nbsp;"; } for($i = $page_start; $i <= $page_stop; $i++) { if(($page) == $i){ echo "$i "; } else {             echo "<a href=\"".$_SERVER['PHP_SELF']."?category=$category&amp;page=$i\">$i</a>&nbsp;"; } } // Build Next Link if($page < $total_pages){ $next = ($page + 1);     echo "<a href=\"".$_SERVER['PHP_SELF']."?category=$category&amp;page=$next\">&gt;</a>"; } echo "</div>"; [/code] and this works as it should, except that it includes minus number pages (eg when on page 1, page links are "-2 -1 0 1 2 3 4" where it should start at 1, and when on the last real page (page 9), the page links are "6 7 8 9 10 11 12", where it should just be 6-9 as before you can see what I mean in action here: http://host.hostingseries44.net/~charles7/exhibition.php?category=8 any help much appreciated cheers
  11. Hi guys, I am currently using this script for pagination [code] $limitpages = 5; $page_limit = $page + $limitpages; if ($page_limit > $total_pages ){$page_limit = $total_pages ;} $page_start = $page; $page_stop = $page_start + $limitpages; if ($page_stop > $total_pages) { $page_stop = $page_stop -$total_pages ; $page_start = $page_start -$page_stop; } // Build Previous Link if($page > 1){ $prev = ($page - 1); $host = $_SERVER['PHP_SELF'];     echo "<a href=\"".$_SERVER['PHP_SELF']."?category=$category&amp;page=$prev\">&lt;</a>&nbsp;"; } for($i = $page_start; ($i <= $total_pages & $i <=$page_limit); $i++) { if(($page) == $i){ echo "$i "; } else {             echo "<a href=\"".$_SERVER['PHP_SELF']."?category=$category&amp;page=$i\">$i</a>&nbsp;"; } } // Build Next Link if($page < $total_pages){ $next = ($page + 1);     echo "<a href=\"".$_SERVER['PHP_SELF']."?category=$category&amp;page=$next\">&gt;</a>"; } echo "</div>"; [/code] which is from a php tutorial here and modified with help from siguy to limit the number of pages. It works great, apart from 1 little thing which is that you can move forward fine by clicking on a page number, and the code will display a few links for pages behind and ahead of the current page.  However if you then click the first link, after the page loads, the only way to go back is to keep clicking the back (<) button.  I have tried to modify it myself but I kept getting infinite loops and browser crashes! If you want to see what I mean in action, click here: http://host.hostingseries44.net/~charles7/exhibition.php?category=8 (this page will actually have around 1000 items in it soon, not the 40 odd just now, so it is necessary to limit the pages) thank you very much for your time.
×
×
  • 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.