Hey there. I'm trying to display information gathered from a HTML form which is stored into a MYSQL table.
Here is the displaying code:
<?php require("menu.php");
//Connect to MYSQL server
mysql_connect("Localhost", "brave11", "police") or die(mysql_error());
//echo "<center><font color='white'>Successfully connected to MySQL!</font></center><br />";
//Connect to MYSQL database
mysql_select_db("brave11_bugs") or die(mysql_error());
echo "<center><font color='white'><h4>Successfully connected to the Bugs Database!</h4></font></center>";
// Retrieve all the data from the "example" table
$result = mysql_query("SELECT * FROM bugs")
or die(mysql_error());
// store the record of the "example" table into $row
echo "<CENTER><TABLE BORDER='2' BORDERCOLOR='#336699' CELLPADDING='2' BGCOLOR='white' CELLSPACING='2' WIDTH='100%'></CENTER>";
echo "<tr> <th>Poster</th> <th>Bug Description</th> <th>Screenshot 1</th> <th>Screenshot 2</th> <th>Screenshot 3</th> <th>Bug Type</th> <th>Priority</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
echo "<tr><td>";
echo $row['poster'];
echo "</td><td>";
echo $row['description'];
echo "</td><td>";
echo "<IMG SRC='$row['screen1']' BORDER='0'>";
echo "</td><td>";
echo $row['screen2'];
echo "</td><td>";
echo $row['screen3'];
echo "</td><td>";
echo $row['type'];
echo "</td><td>";
echo $row['priority'];
echo "</td></tr>";
}
echo "</TABLE>";
?></font></center></body></html>
Problems:
1. I want the "screen1 2 and 3" to display as images, so I did the following:
echo "<IMG SRC='$row['screen1']' BORDER='0'>";
But that doesn't work! Why? How can I fix it? Error:
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /home/brave11/public_html/home/bugs/bugs_main.php on line 26
2. The above creates a new HTML table EVERY time the script is ran (after each time the data is taken into the MYSQL table) how can I get that table creation to run just once, creating ONE table and the set amount of colloms once but allowing the rows to be created each time new data is received?
So basically, every time a new form is submitted a new set of rows are made and the new data input.
3. I want the "pri_lvl aka priority" to display in the HTML table as a certain colour depending on which radio button (urgent, medium or low) is pressed and stored. How can I achieve that?