tkessel Posted June 26, 2010 Share Posted June 26, 2010 Hi everyone! I really need some help on this. I have a form that pulls product data from a MySQL db to use. I also have two input fields for the user to enter "percent price markup" or "manual price markup" that I will need to calculate the new price. Here is the form, but I don't know how to output all of the variables in a table: <!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> <script type="text/javascript" src="js/prototype.js"></script> <script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script> <script type="text/javascript" src="js/lightbox.js"></script> <link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" /> </head> <body> <form action="output.php" method="post"> <table border="1"> <tr> <td>Image</td> <td>Name</td> <td>Cost</td> <td>Markup<br />(%)</td> <td>Manual</td> </tr> <?php require("constants.php"); $query="SELECT * FROM products"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Database Output</center></b><br><br>"; $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $product=mysql_result($result,$i,"product"); $description=mysql_result($result,$i,"description"); $pcategory=mysql_result($result,$i,"pcategory"); $image_big=mysql_result($result,$i,"image_big"); $image_thumb=mysql_result($result,$i,"image_thumb"); $price=mysql_result($result,$i,"price"); $price=number_format($price, 2, '.', ''); echo "<tr> <td><a href=\"images/$image_big\" rel=\"lightbox\"><img src=\"thumbs/$image_thumb\" width=\"129\" height=\"83\" /></a></td> <td><strong>$product</strong><br />$description</td> <td><input type=\"hidden\" name=\"price $id\" value=\"$price\" />\$$price</td> <td><input type=\"text\" name=\"markup$id\" /></td> <td><input type=\"text\" name=\"manual$id\" /></td> </tr>"; $i++; } ?> </table> <input type="submit" /> </form> </body> </html> I am new to PHP and am learning as fast as possible, but I need to complete this project as soon as possible. Thanks! Link to comment https://forums.phpfreaks.com/topic/205913-displaying-post-variables-from-a-form/ Share on other sites More sharing options...
shadiadiph Posted June 26, 2010 Share Posted June 26, 2010 try something like this <table> <?php require("constants.php"); $query="SELECT * FROM products"; $result=mysql_query($query); while($row=mysql_fetch_array($result)){ $id= $row["id"]; $description = $row["description"]; echo '<tr><td>'.$id.'</td><td>'.$description.'</td></tr>'; } mysql_close(); ?> </table> Link to comment https://forums.phpfreaks.com/topic/205913-displaying-post-variables-from-a-form/#findComment-1077550 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.