Jump to content

DreamOn

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Everything posted by DreamOn

  1. Thanks for the reply Scotty. You need to bare with me with this as i am fairly new to PHP, about 1-2month. this is the code which was in cart.php $cart = $_SESSION['cart']; $action = $_GET['action']; switch ($action) { case 'add': if ($cart) { $cart .= ','.$_GET['id']; } else { $cart = $_GET['id']; } break; } i have added this to the top of index.php and changed the link to the following: echo '<p>' . $fldname . ' <a href="' . $_SERVER['PHP_SELF'] . '?viewdetail=' . $nameid . '&action=add&id=' . $row['idinfo'] . '">Add to report</a></p>'; but still cant get this to work, can you see where im going wrong? -Dream.
  2. Hi All I have my shopping cart working correctly, just a small tweak which i would like to make to it. Here is the code i currently use... echo '<p>' . $fldname . ' <a href="cart.php?action=add&id=' . $row['idinfo'] . '">Add to report</a></p>'; But i want it so that when i click 'Add to report' is does not take me to cart.php, but it still adds the item into the shopping cart. kind of just refeshs the current page? Im sure it is only a small tweak which needs to be done.. Any help would be great -Dream
  3. fast learner i have previous programming experience but only with MS Access VBA. Plus non stop reading and testing does help i will check that link out. Cheers -Dream
  4. Hi All Im trying to get my Paganation to work, well it is working, just not how i want it to work... atm it will list 2 records per page, then it will list the page numbers... First Previous 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 etc Next Last My page numbers show every page, so when i have 100+pages it will show them all. I would like to change my current code to something like the following: 1 2 3 4 5 6 7 8 9 10 - Next 10 Previous 10 - 11 12 13 14 15 16 17 18 19 20 - Next 10 below is my current code... i have only just started to learn PHP (2-3days ago) ive looked at aload of tutorials but still cant get my head around how to do it. My Current Code: if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; }; $start_from = ($page-1) * 2; $rs_result = @mysql_query("SELECT Count(idinfo) from info WHERE fldName LIKE '". $_GET['run'] . "%'"); $row1 = mysql_fetch_row($rs_result); $total_records = $row1[0]; $total_pages = ceil($total_records / 2); if ($total_pages == 1) {} else {If ($page == 1) {} else{ echo " <a href='index.html?run=". $_GET['run'] . "&page=1'> <<-First</a> "; echo " "; } If ($page == 1) {} else{ $previous = $page-1; echo " <a href='index.html?run=". $_GET['run'] . "&$previous'> <-Previous</a> "; } } for ($i=1; $i<=$total_pages; $i++) { echo "<a href='index.html?run=". $_GET['run'] . "&page=".$i."'>Page ".$i."</a> "; } if ($page == $total_pages) { } else { $previous = $page+1; echo " <a href='index.html?run=". $_GET['run'] . "&page=$previous'> Next-></a> "; If ($page == $total_pages) {} else{ echo " <a href='index.html?run=". $_GET['run'] . "&page=$total_pages'> Last->></a> "; } } echo ("<br> Page $page of $total_pages<br><br>"); } There is probably better ways to code this in, but it works like this so i am happy Any help will be great. Thanks -Dream
  5. DreamOn

    Split Page

    Got it working, Cheers
  6. DreamOn

    Split Page

    Hi All, New here and i need some help with this... I am designing a website which will list names depening on which letter you select from the list... for this example, ill use letter S. below is the code i have function myS(){ if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; }; $start_from = ($page-1) * 1; $result = @mysql_query("SELECT idinfo, fldName FROM info WHERE fldName LIKE 's%' ORDER BY fldName LIMIT $start_from, 1"); while ($row = mysql_fetch_assoc($result)) { echo ("<p>" . $row["fldName"] . "</p>"); } $rs_result = @mysql_query("SELECT Count(idinfo) from info WHERE fldName LIKE 's%'"); $row1 = mysql_fetch_row($rs_result); $total_records = $row1[0]; $total_pages = ceil($total_records / 1); for ($i=1; $i<=$total_pages; $i++) { echo "<a href='index.html?run=s&page=".$i."'>".$i."</a> "; } } i have it so it shows one record per page, and when i click the next page i want it to show the next record for that page, but its not working and i think its something to do with this part of the coding: echo "<a href='index.html?run=s&page=".$i."'>".$i."</a> "; for testing purposes i am only showing 1 record per page, once i have it fully working, i will list around 5-10, but i know how to get that changed, just cant get this page change to work. Any help with this will be great. -DreamOn P.S - sorry if its in the wrong section, could a mod move it if so.
×
×
  • 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.