25 Feb 2016

One Gmail Account = Multiple Test Email Addresses


Don't know about you but a lot of what I do requires having access to multiple email addresses (testing websites that require signup etc). To aide my development I have a few email accounts I use - a Gmail, a Hotmail, a Yahoo and a Google Apps one (my main account). That's only four addresses though, which can be quite limiting at times.
In steps Gmail. If you have a Gmail account then you have access to "infinite" email addresses using that one account.
The Gmail account I use for general testing is:
myname@gmail.com (I left a t off on purpose)
But I could also use any of the following:
myname+1@gmail.com

myname+2@gmail.com

myname+3@gmail.com

myname+123456789@gmail.com, etc etc,.

You get the idea. You can tack a + sign and then any random string after it to invent a new email address. Obviously it still delivers to your Gmail account and it lets you signup to a website over and over as a "different" user.


17 Feb 2016

Simple PHP pagination example using MySql database

<?php
$num_rec_per_page=10;
mysql_connect('localhost','root','');
mysql_select_db('apex1');
if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; };
$start_from = ($page-1) * $num_rec_per_page;
$sql = "SELECT * FROM student LIMIT $start_from, $num_rec_per_page";
$rs_result = mysql_query ($sql); //run the query
?>
<table>
<tr><td>Name</td><td>Phone</td></tr>
<?php
while ($row = mysql_fetch_assoc($rs_result)) {
?>
            <tr>
            <td><?php echo $row['Name']; ?></td>
            <td><?php echo $row['Phone']; ?></td>          
            </tr>
<?php
};
?>
</table>
<?php
$sql = "SELECT * FROM student";
$rs_result = mysql_query($sql); //run the query
$total_records = mysql_num_rows($rs_result);  //count number of records
$total_pages = ceil($total_records / $num_rec_per_page);

echo "<a href='pagination.php?page=1'>".'|<'."</a> "; // Goto 1st page

for ($i=1; $i<=$total_pages; $i++) {
            echo "<a href='pagination.php?page=".$i."'>".$i."</a> ";
};
echo "<a href='pagination.php?page=$total_pages'>".'>|'."</a> "; // Goto last page
?>