Jump to content

Stoosh

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Stoosh's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I knew that was the reason, I just didnt know how the right code to fix Thanks
  2. Thanks very much!! It's calling the data but the table is still shown, how do I remove the table when the ID link is clicked? <?php // create query $query = "SELECT * FROM enquiry"; // execute query $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); // see if any rows were returned if (mysql_num_rows($result) > 0) { // yes // print them one after another echo "<table cellpadding=10 border=1>"; while($row = mysql_fetch_assoc($result)) { echo "<tr>"; echo "<td>".$row['id']."</td>"; echo "<td>".$row['name']."</td>"; echo "<td>".$row['company']."</td>"; echo "<td>".$row['email']."</td>"; echo "<td>".$row['phone']."</td>"; echo '<td><a href="http://www.aftersunset.com.au/enquiry/test.php?id=' . $row['id'] . '">View Comments</a></td>'; echo "</tr>"; } echo "</table>"; } else { // no // print status message echo "No rows found!"; } $sql = "SELECT * FROM `enquiry` WHERE `id` = " . mysql_real_escape_string ( $_GET['id'] ); if ( mysql_query ( $sql ) ) { $query = mysql_query ( $sql ); $row = mysql_fetch_assoc ( $query ); echo $row['comments']; } else { die ( mysql_error () ); } // free result set memory mysql_free_result($result); // close connection mysql_close($connect); ?>
  3. Hello, I've started teaching myself PHP heavily after a big learning curve with design, html & css. If you have a look at http://www.aftersunset.com.au/enquiry/test.php, its just a basic query from a database, what I'm looking to do is add an extra table column with a link such as http://www.aftersunset.com.au/enquiry/test.php?id=1 which opens to a page which displays the comments or info that the user submitted which is also stored in the database (row is "comments") <?php require_once('dbconnect.php');?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <head> </head> <body> <?php // query $query = "SELECT * FROM enquiry"; // execute $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); // check for rows if (mysql_num_rows($result) > 0) { // yes // print, repeat echo "<table cellpadding=10 border=1>"; while($row = mysql_fetch_assoc($result)) { echo "<tr>"; echo "<td>".$row['id']."</td>"; echo "<td>".$row['name']."</td>"; echo "<td>".$row['company']."</td>"; echo "<td>".$row['email']."</td>"; echo "<td>".$row['phone']."</td>"; echo "</tr>"; } echo "</table>"; } else { // no // error page echo "No rows found!"; } // free result set memory mysql_free_result($result); // close connection mysql_close($connect); ?> </body> </html> This is my first PHP script handwritten so it may be a little sloppy
×
×
  • 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.