Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. <?php
  2. {
  3. $user=$_SESSION['username'];
  4. $pass=$_SESSION['password'];
  5. }
  6. $con = mysql_connect("localhost","****","*****");
  7. var_dump($con);
  8.  
  9. if (!$con)
  10. {
  11. die('Could not connect: ' . mysql_error());
  12. }
  13.  
  14. mysql_select_db("****", $con);
  15. $result = mysql_query("select * from `order` WHERE username='$user'");
  16.  
  17. while ($row = mysql_fetch_array($result))
  18. {
  19. $html_table = '<table border="1 cellspacing="0" cellpadding="2""><th>Company Symbol&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th>Amount&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </th><th>Actual Stockprice&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th>Old Stockprice&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th>Cost&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th>Profit/loss&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><tr>';
  20. foreach($result as $row) {
  21. $html_table .= '<tr><td>' .$row['company']. '</td><td>' .$row['amount']. '</td><td>' .$row['stock']. '</td></tr>';
  22. }
  23.  
  24.  
  25. $html_table .= '</tr></table>';
  26.  
  27.  
  28. $html_table = str_replace('<tr></tr>', '', $html_table);
  29.  
  30. echo $html_table;
  31.  
  32.  
  33. }
  34.  
  35. ?>
  36.  
  37. echo '<table border="1" cellspacing="0" cellpadding="2">';
  38. echo '<th>Company Symbol</th><th>Amount</th><th>Actual Stockprice</th><th>Old Stockprice</th><th>Cost</th><th>Profit loss</th><tr>';
  39. while ($row = mysql_fetch_array($result)) {
  40. echo '<tr>';
  41. foreach($row as $value) {
  42. echo "<td>$value</td>";
  43. }
  44. echo '</tr>';
  45. }
  46. echo '</table'>;
  47.  
  48. foreach($row as $a_variable_name_that_is_not_result) {
  49. //stuff
  50. }
  51.  
  52. $html_table = '<table border="1" cellspacing="0" cellpadding="2"><th>Company Symbol&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th>Amount&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </th><th>Actual Stockprice&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th>Old Stockprice&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th>Cost&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th>Profit/loss&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><tr>';
  53. while ($row = mysql_fetch_array($result))
  54. {
  55. $html_table .= '<tr><td>' .$row['company']. '</td><td>' .$row['amount']. '</td><td>' .$row['stock']. '</td></tr>';
  56. }
  57.  
  58. $html_table .= '</tr></table>';
  59.  
  60. mysql_query("select * from `order` WHERE username='$user'");
  61.  
  62. while ($row = mysql_fetch_array($result))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement