SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 45 of 45

Thread: GuestBook

  1. #26
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    177
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That code checks if $_Get["commentpage"] has a value (meaning theURL that looks something like this: index.php?commentpage=something)

    Of course, that's with $_GET, not $_Get...

  2. #27
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is this right. the guest_id refers on the database
    PHP Code:
    $page = (isset($_GET['guest_id'])) ? $_GET['guest_id'] : 0;

    $start $page 4;

    $q mysql_query("SELECT * FROM `comments` LIMIT $start,4"); 

  3. #28
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im really really stuck. I cant figure it out how and where should i place it.

    PHP Code:
    <?php
    $getdata
    ="SELECT * FROM comments ORDER BY guest_id DESC LIMIT 0,4";
    $getdata2=mysql_query($getdata) or die("Could not get data");
    while(
    $getdata3=mysql_fetch_array($getdata2))
    {
      
    $getdata3[guest_name]=strip_tags($getdata3[guest_name]);
      
    $getdata3[guest_rating]=strip_tags($getdata3[guest_rating]);
      
    $getdata3[guest_message]=strip_tags($getdata3[guest_message]);
      
    $getdata3[guest_date]=strip_tags($getdata3[guest_date]);
    ?>

    <div class="headinglarge"> Title <?php
    for ($i=1$i<="$getdata3[guest_rating]"$i++)
    {
    echo 
    '<img src="images/star.gif">';
    }
    ?><img src="images/del.gif"></div><div class="adminbtn"><img src="images/admin.gif" width="65" height="52" border="0" ></div>
    <div class="headingsub"> <?php echo "$getdata3[guest_date]"?> by <?php echo "$getdata3[guest_name]"?></div>
    <div class="content"> <?php echo "$getdata3[guest_message]"?>
    </div><hr>
    <?php ?>
    <?php 
    $page 
    = (isset($_GET['commentpage'])) ? $_GET['commentpage'] : 0;
    $start $page 4;
    $q mysql_query("SELECT * FROM comments LIMIT $start,4");
    ?>
    <?php
    $nextpage 
    $page 1;
    ?>
    <table width="119" border="0" align="center" cellpadding="0" cellspacing="3">
              <tr>
                <td width="16" align="right"><?php "<a href=\"?commentpage=".$nextpage."\"><img src="images/pfirst.gif" width="15" height="16"></a>" ?>
    </td>
                <td width="16" align="right"><img src="images/pprev.gif" width="15" height="16"></td>
                <td width="7" align="center">1</td>
                <td width="16" align="left"><img src="images/pnext.gif" width="15" height="16"></td>
                <td width="46" align="left"><img src="images/plast.gif" width="15" height="16"></td>
              </tr>
            </table>

  4. #29
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    177
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After a quick first glance, a couple of things:
    PHP Code:
    $getdata3[guest_name]=strip_tags($getdata3[guest_name]); 
    You forgot the quotes or double quotes inside the []. It should be $getdata3["guest_name"].

    PHP Code:
    <?php echo "$getdata3[guest_date]"?>
    The quotes there will make it show as a string, so exactly as it says between quotes. To use the value of that variable, take the quotes out there (but place them inside the [] brackets, like this:
    PHP Code:
    <?php echo $getdata3["guest_date"]; ?>
    After those two issues're fixed, try again and let us know what exactly it does wrong if it still doesn't work.

  5. #30
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The only problem is the button. I cant do the thing that if click the next it will go to the next 4 comments and if i click the previous it will go back to the previous 4 comments. and so on. I use arkinstall procedure and dyan procedure that youve given to me (link to dysan problem)

  6. #31
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    177
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:
    PHP Code:
    $start $page 4;
    $end $page 5;

    $q mysql_query("SELECT * FROM comments LIMIT" $start "," $end); 

  7. #32
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Still my buttons not working. My guest_id is set as auto increment in the database. But why i cant use the image buttons. I cant go to the another 4 comments
    PHP Code:
    <?php

    $getdata
    ="SELECT * FROM comments ORDER BY guest_id DESC LIMIT 0,4";

    $getdata2=mysql_query($getdata) or die("Could not get data");

    while(
    $getdata3=mysql_fetch_array($getdata2))

    {

      
    $getdata3[guest_name]=strip_tags($getdata3[guest_name]);

      
    $getdata3[guest_rating]=strip_tags($getdata3[guest_rating]);

      
    $getdata3[guest_message]=strip_tags($getdata3[guest_message]);

      
    $getdata3[guest_date]=strip_tags($getdata3[guest_date]);

    ?>



    <div class="headinglarge"> Title <?php

    for ($i=1$i<="$getdata3[guest_rating]"$i++)

    {

    echo 
    '<img src="images/star.gif">';

    }

    ?><img src="images/del.gif"></div><div class="adminbtn"><img src="images/admin.gif" width="65" height="52" border="0" ></div>

    <div class="headingsub"> <?php echo "$getdata3[guest_date]"?> by <?php echo "$getdata3[guest_name]"?></div>

    <div class="content"> <?php echo "$getdata3[guest_message]"?>

    </div><hr>

    <?php ?>
    This is the part of the buttons
    PHP Code:
    <?php 
    $page 
    = (isset($_GET['guest_id'])) ? $_GET['guest_id'] : 0;
    $start $page 4;
    $end $page 5;
    $q mysql_query("SELECT * FROM comments LIMIT $start,$end");
    ?>
    <?php
    $nextpage 
    $page 1;
    ?>
    <table width="119" border="0" align="center" cellpadding="0" cellspacing="3">
              <tr>
                <td width="16" align="right"><img src="images/pfirst.gif" width="15" height="16"></td>
                <td width="16" align="right"><img src="images/pprev.gif" width="15" height="16"></td>
                <td width="7" align="center"><?php echo $_POST["$nextpage"]; ?></td>
                <td width="16" align="left"><img src="images/pnext.gif" width="15" height="16"></td>
                <td width="46" align="left"><img src="images/plast.gif" width="15" height="16"></td>
              </tr>
            </table>
            <br />    
            <br />

  8. #33
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    177
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Before the table, do an echo $page; so you get to see the value $page gets. Sounds like that one's always the same.

  9. #34
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I change my code here it is
    PHP Code:
    <?php
    $glimit 
    4;
    if (isset(
    $_GET['page']) || empty($_GET['page']) || $_GET['page'] == 1)
    {
    $page 1;
    $flimit 0;
    $limit $flimit.",".$glimit;
    }
    else
    {
    $page $_GET['page'];
    $llimit $_GET['page'] * $glimit;
    $flimit $llimit $glimit;
    $limit $flimit.",".$glimit;
    }
    $sql mysql_query("SELECT * FROM comments ORDER BY guest_id DESC LIMIT $limit");
    while (
    $row mysql_fetch_array($sql))
    {
    ?>
            <div class="headinglarge"><?php echo $row["guest_title"]; ?><img src="images/del.gif"></div>
            <div class="adminbtn"><img src="images/admin.gif" width="65" height="52" border="0" ></div><br>
            <div class="headingsub"> Posted at <?php echo $row["guest_date"]; ?> by <?php echo $row["guest_name"]; ?></div>
            <div class="headingsub"><?php 
            
    for($i=1$i<=$row["guest_rating"]; $i++) {    echo '<img src="images/star.gif">';    }
            
    ?></div>
            <div class="content"><?php echo $row["guest_message"]; ?></div>
            <hr>
    <?php ?>
            <table width="119" border="0" align="center" cellpadding="0" cellspacing="3">
              <tr>
                <td width="16" align="right"><img src="images/pfirst.gif" width="15" height="16"></td>
                <td width="16" align="right"><img src="images/pprev.gif" width="15" height="16"></td>
                <td width="7" align="center">1</td>
                <td width="16" align="left"><img src="images/pnext.gif" width="15" height="16"></td>
                <td width="46" align="left"><img src="images/plast.gif" width="15" height="16"></td>
              </tr>
            </table>
    In displaying im not using a <form> im only using a <div> so there no action to be happen. Except in adding. My button is an image. But still nothings work fine. Help me with those button.

  10. #35
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    just put the code I gave you on the top of the page. And yes, your code on post #27 is right.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  11. #36
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But base on my code. i change your code.Kindly look on my post $34. I change your code there. Now what should i put in the image button to link in the another 4 comments and so on.

  12. #37
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think your code
    PHP Code:
    $page = (isset($_GET['commentpage'])) ? $_GET['commentpage'] : 0;

    $start $page 4;

    $q mysql_query("SELECT * FROM `comments` LIMIT $start,4"); 
    is equal to this code that i made

    PHP Code:
    <?php
    $glimit 
    4;
    if (isset(
    $_GET['page']) || empty($_GET['page']) || $_GET['page'] == 1)
    {
    $page 1;
    $flimit 0;
    $limit $flimit.",".$glimit;
    }
    else
    {
    $page $_GET['page'];
    $llimit $_GET['page'] * $glimit;
    $flimit $llimit $glimit;
    $limit $flimit.",".$glimit;
    }
    $sql mysql_query("SELECT * FROM comments ORDER BY guest_id DESC LIMIT $limit");

  13. #38
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The problem is i dont know what is the correct position of this code
    PHP Code:
    <?
    $nextpage 
    $page 1;
    echo 
    "<a href=\"?commentpage=".$nextpage."\">Next</a>";
    ?>
    if im going to put that on my image button like this
    PHP Code:
    <?

    $nextpage 
    $page 1;
                <
    td width="16" align="right">echo "<a href=\"?page=".$nextpage."\"><img src="images/pfirst.gif" width="15" height="16"></a>";</td>
                <
    td width="16" align="right"><img src="images/pprev.gif" width="15" height="16"></td>
                <
    td width="7" align="center">1</td>
                <
    td width="16" align="left"><img src="images/pnext.gif" width="15" height="16"></td>
                <
    td width="46" align="left"><img src="images/plast.gif" width="15" height="16"></td>
              </
    tr>
            </
    table>
    ?>
    and so on it doesnt work

  14. #39
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your code is working fine. but the limitation is quite not right it keeps enable to next even theres no records left.

  15. #40
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I use your code now but i cant put it on my image button
    PHP Code:
    <?php
    $nextpage 
    $page 1;
    $prev $page 1;
    echo 
    "<a href=\"?commentpage=".$nextpage."\">Next</a>";
    echo 
    "&nbsp; <a href=\"?commentpage=".$prev."\">Prev</a>";
    //"<a href=\"?commentpage=".$nextpage."\"></a>";
    ?>
    and still i can keep pressing the next button or prev button even theres no record left.

    PHP Code:
    //1. wont work
    echo "<a href=\"?commentpage=".$nextpage."\"><img src="a.gif"></a>";
    //2. wont work
    echo "<a href=\"?commentpage=".$nextpage."\">'<img src="a.gif">'</a>";
    //3. wont work
    echo '"<a href=\"?commentpage=".$nextpage."\"><img src="a.gif"></a>"';
    //4. wont work
    echo '"<a href=\"?commentpage=".$nextpage."\">'<img src="a.gif">'</a>"'

  16. #41
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    this will:
    PHP Code:
    echo "<a href=\"?commentpage=".$nextpage."\"><img src=\"a.gif\"></a>"
    you need to backslash the double-quotes for the image source.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  17. #42
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    About the limitation of my buttons, im gone with it. i dont know what else should i write. I dont know what should i code on my First Button, Next Button, Prev Button, Last Button. Your code is right about next and i write it in vice versa to produce in prev button. but i dont know how should i limit that if theres no record left it should not be click anymore.

  18. #43
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    ok.
    try this:
    top:
    Code php:
    <?
    $page = (isset($_GET['commentpage'])) ? $_GET['commentpage'] : 0;
    $start = $page * 4;
    $q = mysql_query("SELECT * FROM `comments` LIMIT $start,4");
    $q2 = mysql_query("SELECT count(*) FROM `comments`");
    $recordcount = mysql_result($q2, 0);
    $maxpagecount = ($recordcount &#37; 4 == 0) ? ($recordcount / 4) : ceil($recordcount);
    bottom:
    Code php:
    <table width="119" border="0" align="center" cellpadding="0" cellspacing="3">
    	<tr>
    		<td width="16" align="right"><a href="?commentpage=1"><img src="images/pfirst.gif" width="15" height="16"></a></td>
    		<? if($page > 1){ ?>
    			<td width="16" align="right"><a href="?commentpage=<? echo ($page - 1); ?>"><img src="images/pprev.gif" width="15" height="16"></a></td>
    		<? } ?>
    		<td width="7" align="center">1</td>
    		<? if($page < $maxpagecount){ ?>
    			<td width="16" align="left"><a href="?commentpage=<? echo ($page + 1); ?>"><img src="images/pnext.gif" width="15" height="16"></a></td>
    		<? } ?>
    		<td width="46" align="left"><a href="?commentpage=<? echo $maxpagecount; ?>"><img src="images/plast.gif" width="15" height="16"></a></td>
    	</tr>
    </table>

    that should work - haven't tested it though.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  19. #44
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    tHANK YOU ITS WORKING EVEN THERES A LITTLE BIT ERROR, BUT NOW I NEED TO WORK WITH DELETE .... THANKS AGAIN

  20. #45
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    hey, that's what these forums are for
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •