I am new to PHP and to the board. I'm sure I'm asking something that has been posted here a million times. I just don't know where to begin to search for the answer to my problem.
Below is the code that I have written so far. it works just as it should, the problem I am having is that I want to be able to update a value associated with the data that I am pulling from the database.
how can I make a second column in my table that has a input box for each row returned?
I think if I can get that part figured out I can work out the rest of the code to actually update the information. I just cant seem to figure out a way around this issue so that I can get to the next part of the code.
Thanks in advance,
P
<html>
<head>
</head>
<body>
<? include 'config.php'; ?>
<?
if (!($connect)) // If no connect, error and exit().
{
echo("<p>Unable to connect to the database server.</p>");
exit();
}
if (!(@mysql_select_db($db_name))) // If can't connect to database, error and exit().
{
echo("<p>Unable to locate the $db_name database.</p>");
exit();
}
// create query
$query = "SELECT * FROM smg_stocks";
// 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 border=1 cellpadding=3 cellspacing=0>";
while($row = mysql_fetch_row($result)) {
echo "<tr>";
echo "<td align=center>".$row[1]."</td>";
echo "</tr>";
}
echo "</table>";
}
else {
// no
// print status message
echo "No rows found!";
}
// free result set memory
mysql_free_result($result);
// close connection
mysql_close($connect);
?>
</body>
</html>