Any ideas?
I am trying to echo results from the DB but I am only seeing the first line. I have more than 1 record in the db?
Any help or suggestions would be great, Thanks.
Code:<?php // query db and echo from database $sql = "SELECT * FROM `comments` ORDER BY ID ASC"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { $row = mysql_fetch_assoc($result); echo "<h2>" . $row['Name'] . "</h2>"; // echo "<h2>" . $row['Time'] . "</h2>"; // echo "<p>" . $row['Comment'] . "</p>"; // } else { echo "Something is wrong!"; } } ?> <div class="comment"> <?php //initilize PHP if($_POST['submit']) //If submit is hit { //convert all the posts to variables: $name = $_POST['name']; $email = $_POST['email']; $comment = $_POST['comment']; //Insert the values into the correct database with the right fields //mysql table = news //table columns = id, title, message, who, date, time //post variables = $title, $message, '$who, $date, $time $result=MYSQL_QUERY("INSERT INTO comments (ID,Name,Email,Time,Comment)". "VALUES ('NULL', '$name', '$email', 'NULL', '$comment')"); //confirm echo "Query Finished"; } ?> <form id="sendcomment" name="sendcomment" method="post" action=""> <?php //if (isset($missing) && in_array('name', $missing)) { ?> <span class="warning">Enter your name.</span> <?php //} ?> <label><abbr title="Enter your name."><font color="#FF0000"><sup>*</sup></font>Name:</abbr> <input type="text" name="name" id="name" maxlength="35" /> </label> <?php // if (isset($missing) && in_array('email', $missing)) { ?> <span class="warning">Enter your email address.</span> <?php //} ?> <label><abbr title="Enter your email address."><font color="#FF0000"><sup>*</sup></font>Email:</abbr> <input type="text" name="email" id="email" maxlength="40"/> </label> <?php //if (isset($missing) && in_array('tel', $missing)) { ?> <span class="warning">Enter your contact no.</span> <?php //} ?> <!-- <label><abbr title="Enter your contact no."><font color="#FF0000"><sup>*</sup></font>Tel.:</abbr> <input type="text" name="time" id="time" maxlength="25" /></label> --> <label><abbr title="Enter your comment."><font color="#FF0000"><sup>*</sup></font>Your Comment:</abbr></label> <textarea name="comment" id="comment" cols="0" rows="7"></textarea> <input type="submit" name="submit" id="submit" class="submit" value="Send" title="Send" /> <input type="reset" name="reset" id="reset" class="reset" value="Reset" title="Reset" /> </form>



Reply With Quote

Bookmarks