I've got a script that displays a MySQL table in HTML format. The code goes like this:
Code: Select all
<?php
// open the MySQL connection
mysql_connect("host_name_here", "username_here", "password_here") or die(mysql_error());
mysql_select_db("database_name_here") or die(mysql_error());
// Get all the data from the "table_name_here" table
// ORDER BY id DESC should arrange the entries by the ID Number in reverse order. LIMIT 30 should return only the last 30 entries
$result = mysql_query("SELECT * FROM table_name_here ORDER BY ID DESC LIMIT 30")
or die(mysql_error());
// Start generating the HTML table on-the-fly
echo "<table width='100%' border='1' cellspacing='1' cellpadding='1'>";
// generate the table headers and format in accordance with CSS definitions
// Field7 is the ID field so no need to display here
echo "<tr class='link ind_1' align='center'> <th>Field 1</th> <th> Field 2</th> <th> Field 3</th> <th> Field 4</th> <th> Field 5</th> <th> Field 6</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table except field "ID"
echo "<tr align='center'><td>";
echo $row['Field1'];
echo "</td><td>";
echo $row['Field2'];
echo "</td><td>";
echo $row['Field3'];
echo "</td><td>";
echo $row['Field4'];
echo "</td><td>";
echo $row['Field5'];
echo "</td><td>";
echo $row['Field6'];
echo "</td></tr>";
}
echo "</table>";
?>
Here's the part I don't know how to go about. I want this second script to display the complete row. 'Field1' is a Date, and 'Field2' is a name. What I want is when I click on the name, it's going to bring me to that second script which displays everything else for that particular name (or row).
I hope I'm making sense here. Any kind of help will be much appreciated. If you could show me a snippet of some code, or point me to a tutorial of some kind that would be great. As I said, I'm still learning. Thanks!