Site Cloner PHP Script
Bargain Hunter PHP Script
Job Hunter PHP Script
Site Login and Access Control PHP Script

PHP Integers From Database

When you grab a row from a loop with php, the rows come back at you with strings. However, using the (int) cast is a method to convert the number string into an integer. For example, say you wanted to add an integer into a json function or use it for mathematical purposes. You simple add the (int) in front of the number string to make it an integer.

Read below for details.

$command = "SELECT * FROM tablename ";
$result = mysqli_query($db, $command);

while ($row = mysqli_fetch_assoc($result)) {
        $myid = row['id']; // this is a string if the column is varchar
	$id = (int)$myid;
	$id2 = (int)trim($myid);	
	}