Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $personid = ($_POST['personid']) ? $_POST['personid'] : $_GET['personid'];
- if (empty($personid)) {
- echo 'Please enter some search parameters';
- } else {
- $sql = "SELECT * FROM persons WHERE 1=1";
- if ($personid)
- $sql .= " AND personid='" . mysqli_real_escape_string($mysqli,$personid) . "'";
- $total_records = mysqli_num_rows(mysqli_query($mysqli,$sql));
- $sql .= " ORDER BY surname";
- $loop = mysqli_query($mysqli,$sql)
- or die ('cannot run the query because: ' . mysqli_error($mysqli));
- echo "<table border='1' cellpadding='10'>";
- 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>";
- while ($record = mysqli_fetch_assoc($loop)) {
- echo "<tr>";
- /* echo '<td>' . $record['firstname'] . $record['surname'] .'</td>';*/
- echo "<td><a href="person.php?$record[personid]">$record[firstname] $record[surname]</a></td>";
- echo '<td>' . $record['address'] . '</td>';
- echo '<td>' . $record['city'] . '</td>';
- echo '<td>' . $record['province'] . '</td>';
- echo '<td>' . $record['postalcode'] . '</td>';
- echo '<td>' . $record['phone'] . '</td>';
- echo '<td>' . $record['email'] . '</td>';
- echo ("<td><a href="records.php?$record[personid]">Edit</a></td>");
- echo "</tr>";
- }
- echo "</table>";
- $_SESSION['animals']=$loop;
- echo "<center>" . number_format($total_records) . " search results found</center>";
- }
- ?>
- <a href="passthru.php" target="_blank">Click here to see if sessions work</a>
- <?php
- session_start();
- echo "The results";
- while ($record = mysqli_fetch_assoc($_SESSION['animals'])) {
- echo "<tr>";
- echo "<td><a href="person.php?$record[personid]">$record[firstname] $record[surname]</a></td>";
- echo '<td>' . $record['address'] . '</td>';
- echo '<td>' . $record['city'] . '</td>';
- echo '<td>' . $record['province'] . '</td>';
- echo '<td>' . $record['postalcode'] . '</td>';
- echo '<td>' . $record['phone'] . '</td>';
- echo '<td>' . $record['email'] . '</td>';
- echo ("<td><a href="records.php?$record[personid]">Edit</a></td>");
- echo "</tr>";
- }
- $loop = mysqli_query($mysqli,$sql)
- $html = "<table>";
- while ($record = mysqli_fetch_assoc($loop)) {
- $html .= $record['something'];
- // Likewise add other variables to html string.
- }
- $html . = "</table>";
- $_SESSION['animals'] = $html
- $rows = array();
- while ($record = mysqli_fetch_assoc($loop)) {
- $rows[] = $record;
- }
- $_SESSION['animals'] = $rows;
- if (!isset($_SESSION['basket'])){
- $_SESSION['basket'] = array();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement