Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $personid = ($_POST['personid']) ? $_POST['personid'] : $_GET['personid'];
  4.  
  5.  
  6. if (empty($personid)) {
  7. echo 'Please enter some search parameters';
  8. } else {
  9.  
  10. $sql = "SELECT * FROM persons WHERE 1=1";
  11.  
  12. if ($personid)
  13. $sql .= " AND personid='" . mysqli_real_escape_string($mysqli,$personid) . "'";
  14.  
  15. $total_records = mysqli_num_rows(mysqli_query($mysqli,$sql));
  16.  
  17. $sql .= " ORDER BY surname";
  18.  
  19. $loop = mysqli_query($mysqli,$sql)
  20. or die ('cannot run the query because: ' . mysqli_error($mysqli));
  21.  
  22. echo "<table border='1' cellpadding='10'>";
  23. echo "<tr> <th>Name</th> <th>Address</th> <th>City</th> <th>Province</th> <th>Postal Code</th> <th>Phone Number</th> <th>Email</th> <th></th></tr>";
  24.  
  25. while ($record = mysqli_fetch_assoc($loop)) {
  26. echo "<tr>";
  27. /* echo '<td>' . $record['firstname'] . $record['surname'] .'</td>';*/
  28. echo "<td><a href="person.php?$record[personid]">$record[firstname] $record[surname]</a></td>";
  29. echo '<td>' . $record['address'] . '</td>';
  30. echo '<td>' . $record['city'] . '</td>';
  31. echo '<td>' . $record['province'] . '</td>';
  32. echo '<td>' . $record['postalcode'] . '</td>';
  33. echo '<td>' . $record['phone'] . '</td>';
  34. echo '<td>' . $record['email'] . '</td>';
  35.  
  36. echo ("<td><a href="records.php?$record[personid]">Edit</a></td>");
  37.  
  38. echo "</tr>";
  39.  
  40.  
  41. }
  42. echo "</table>";
  43.  
  44.  
  45. $_SESSION['animals']=$loop;
  46.  
  47. echo "<center>" . number_format($total_records) . " search results found</center>";
  48.  
  49.  
  50.  
  51. }
  52.  
  53. ?>
  54. <a href="passthru.php" target="_blank">Click here to see if sessions work</a>
  55.  
  56. <?php
  57. session_start();
  58.  
  59. echo "The results";
  60.  
  61.  
  62.  
  63. while ($record = mysqli_fetch_assoc($_SESSION['animals'])) {
  64. echo "<tr>";
  65. echo "<td><a href="person.php?$record[personid]">$record[firstname] $record[surname]</a></td>";
  66. echo '<td>' . $record['address'] . '</td>';
  67. echo '<td>' . $record['city'] . '</td>';
  68. echo '<td>' . $record['province'] . '</td>';
  69. echo '<td>' . $record['postalcode'] . '</td>';
  70. echo '<td>' . $record['phone'] . '</td>';
  71. echo '<td>' . $record['email'] . '</td>';
  72.  
  73. echo ("<td><a href="records.php?$record[personid]">Edit</a></td>");
  74.  
  75. echo "</tr>";
  76.  
  77.  
  78. }
  79.  
  80. $loop = mysqli_query($mysqli,$sql)
  81.  
  82. $html = "<table>";
  83. while ($record = mysqli_fetch_assoc($loop)) {
  84. $html .= $record['something'];
  85. // Likewise add other variables to html string.
  86.  
  87. }
  88. $html . = "</table>";
  89. $_SESSION['animals'] = $html
  90.  
  91. $rows = array();
  92. while ($record = mysqli_fetch_assoc($loop)) {
  93. $rows[] = $record;
  94. }
  95. $_SESSION['animals'] = $rows;
  96.  
  97. if (!isset($_SESSION['basket'])){
  98. $_SESSION['basket'] = array();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement