Guestbook (scrolling) [SOLVED]

Web design related discussion or help, including CSS.

Guestbook (scrolling)

Postby Merle » Sun Mar 07, 2010 6:28 pm

hello all,
i am trying to make it so that all the text in the post screen is to scroll!
In the moment every time a message get's posted it pushes the 3 boxes down (name, email, message) so that at the end you would have to scroll for does boxes.

i have used the div statement but that does not work, can someone tell me where or what i can do to make the post screen to scroll?

P.s: sorry about my bad grammar! :oops:

  1. <body bgcolor="black" text="yellow">
  2. <?php
  3.  
  4. //PHP Guestbook using mySQL database
  5. echo "<h1>Guestbook</h1><hr>";
  6.  
  7. //connect to the database
  8. $connect = mysql_connect("localhost","root","") or die ("Couldn't connect!");
  9. //select table
  10. mysql_select_db("**********") or die("couldn't find db");
  11.  
  12.  
  13. //use query to get ALL data
  14.  
  15. $queryget = mysql_query("SELECT * FROM guestbook") or die("Error with query");
  16.  
  17.  
  18. while ($row = mysql_fetch_assoc($queryget))
  19. {
  20.  
  21. //get row data and store in variables
  22. $id = $row['id'];
  23. $name = $row['name'];
  24. $email = $row['email'];
  25. $message = $row['message'];
  26. $date = $row['date'];
  27. $time = $row['time'];
  28.  
  29. //show data to user
  30.  
  31. echo "
  32.  
  33.  
  34. <table>
  35. <tr>
  36. <td>
  37. <b>Posted by $name ($email) on $date at $time</b>
  38. </td>
  39. </tr>
  40. <tr>
  41. <td>
  42. ".nl2br(strip_tags($message))."
  43. </td>
  44. </tr>
  45.  
  46. </table>
  47. ";
  48.  
  49.  
  50.  
  51.  
  52. }
  53.  
  54.  
  55. echo "<hr>";
  56.  
  57. if (isset($_POST['submit']))
  58.  
  59.  
  60. {
  61.  
  62.  
  63. $name = $_POST['name'];
  64. $email = $_POST['email'];
  65. $message = $_POST['message'];
  66. $date = date("Y-m-d");
  67. $time = date("H:i:s:");
  68.  
  69.  
  70. if ($name&&$email&&$message)
  71. {
  72.  
  73. $querypost = mysql_query("INSERT INTO guestbook VALUES ('','$name','$email','$message','$date','$time')");
  74. echo "Please wait...<meta http-equiv='refresh' content='2'>";
  75.  
  76.  
  77. }
  78. else
  79. echo "Please fill out all fields!";
  80.  
  81. }
  82.  
  83. echo "
  84.  
  85.  
  86. <form action='guestbook.php' method='POST'>
  87. <table width='50%'>
  88. <tr>
  89. <td width='18%'>
  90. Username:
  91. </td>
  92. <td>
  93. <input type='text' name='name' maxlength='25'>
  94. </td>
  95. </tr>
  96.  
  97. <tr>
  98. <td valign='top'>
  99. Email:
  100. </td>
  101. <td>
  102. <input type='text' name='email' maxlength='35'>
  103. </td>
  104. </tr>
  105.  
  106. <tr>
  107. <td valign='top'>
  108. Your message:
  109. </td>
  110. <td>
  111. <textarea cols='20' rows='2' name='message' maxlength='250'> </textarea>
  112. <p>
  113. <input type='submit' name='submit' value='Post'>
  114. </td>
  115. </tr>
  116. </table>
  117. </form>
  118. ";
  119.  
  120. ?>
  121.  
  122.  
  123.  
Merle
 
Posts: 5
Joined: Wed Mar 03, 2010 5:17 am
Location: Tucson Arizona
Online: 0s
Karma: 0

Re: Guestbook (scrolling)

Advertisment

Advertisment
 

Re: Guestbook (scrolling)

Postby wide_load » Sun Mar 07, 2010 6:30 pm

if you put the area inside a div with fixed height and apply the style
  1. overflow-y:auto;

it will scroll in the div
Image
User avatar
wide_load
Top Contributor
 
Posts: 5617
Joined: Thu Aug 13, 2009 1:04 pm
Online: 13d 22h 25s
Karma: 45

Re: Guestbook (scrolling)

Postby Merle » Mon Mar 08, 2010 5:28 am

wide_load wrote:if you put the area inside a div with fixed height and apply the style
[syntax=css]overflow-y:auto;[/php]
it will scroll in the div


I will see if i get it to work!
thnx for now.
:roll:
Merle
 
Posts: 5
Joined: Wed Mar 03, 2010 5:17 am
Location: Tucson Arizona
Online: 0s
Karma: 0

Re: Guestbook (scrolling)

Postby Merle » Tue Mar 09, 2010 2:52 am

I don't get it!!!
I'm not getting it, i get all the time the error message for the line where the Div command is!
could someone point out the line where i should put the div command to scroll the messages from people?
:cry:
  1. <body bgcolor="black" text="yellow">
  2. <?php
  3.  
  4. //PHP Guestbook using mySQL database
  5. echo "<h1>Guestbook</h1><hr>";
  6.  
  7. //connect to the database
  8. $connect = mysql_connect("localhost","root","") or die ("Couldn't connect!");
  9. //select table
  10. mysql_select_db("**********") or die("couldn't find db");
  11.  
  12.  
  13. //use query to get ALL data
  14.  
  15. $queryget = mysql_query("SELECT * FROM guestbook") or die("Error with query");
  16.  
  17.  
  18. while ($row = mysql_fetch_assoc($queryget))
  19. {
  20.  
  21. //get row data and store in variables
  22. $id = $row['id'];
  23. $name = $row['name'];
  24. $email = $row['email'];
  25. $message = $row['message'];
  26. $date = $row['date'];
  27. $time = $row['time'];
  28.  
  29. //show data to user
  30.  
  31. echo "
  32.  
  33.  
  34. <table>
  35. <tr>
  36. <td>
  37. <b>Posted by $name ($email) on $date at $time</b>
  38. </td>
  39. </tr>
  40. <tr>
  41. <td>
  42. ".nl2br(strip_tags($message))."
  43. </td>
  44. </tr>
  45.  
  46. </table>
  47. ";
  48.  
  49.  
  50.  
  51.  
  52. }
  53.  
  54.  
  55. echo "<hr>";
  56.  
  57. if (isset($_POST['submit']))
  58.  
  59.  
  60. {
  61.  
  62.  
  63. $name = $_POST['name'];
  64. $email = $_POST['email'];
  65. $message = $_POST['message'];
  66. $date = date("Y-m-d");
  67. $time = date("H:i:s:");
  68.  
  69.  
  70. if ($name&&$email&&$message)
  71. {
  72.  
  73. $querypost = mysql_query("INSERT INTO guestbook VALUES ('','$name','$email','$message','$date','$time')");
  74. echo "Please wait...<meta http-equiv='refresh' content='2'>";
  75.  
  76.  
  77. }
  78. else
  79. echo "Please fill out all fields!";
  80.  
  81. }
  82.  
  83. echo "
  84.  
  85.  
  86. <form action='guestbook.php' method='POST'>
  87. <table width='50%'>
  88. <tr>
  89. <td width='18%'>
  90. Username:
  91. </td>
  92. <td>
  93. <input type='text' name='name' maxlength='25'>
  94. </td>
  95. </tr>
  96.  
  97. <tr>
  98. <td valign='top'>
  99. Email:
  100. </td>
  101. <td>
  102. <input type='text' name='email' maxlength='35'>
  103. </td>
  104. </tr>
  105.  
  106. <tr>
  107. <td valign='top'>
  108. Your message:
  109. </td>
  110. <td>
  111. <textarea cols='20' rows='2' name='message' maxlength='250'> </textarea>
  112. <p>
  113. <input type='submit' name='submit' value='Post'>
  114. </td>
  115. </tr>
  116. </table>
  117. </form>
  118. ";
  119.  
  120. ?>
Merle
 
Posts: 5
Joined: Wed Mar 03, 2010 5:17 am
Location: Tucson Arizona
Online: 0s
Karma: 0

Re: Guestbook (scrolling)  [SOLVED]

Postby wide_load » Tue Mar 09, 2010 6:02 pm

you want to put it around the while loop
  1. <div id="messages">
  2. <!-- while loop here -->
  3. </div>


then the css to go with this...
  1. #messages { width:600px; height:800px; overflow-y:auto; }
Image
User avatar
wide_load
Top Contributor
 
Posts: 5617
Joined: Thu Aug 13, 2009 1:04 pm
Online: 13d 22h 25s
Karma: 45


Return to Web Design

Who's online?

Users browsing this forum: No registered users and 1 guest