I am fetching some data from MySQL which I print into a table. I have a function to "X out" the content after the first 2 up to the last 2 digits of a number.
Now I am trying to use that function on every number in the row 'code' where the MySQL result is used=''
before printing it.
Example: Data from mysql row 'code' and 'used':
code = 123456789 & used = 'n' result=123456789
code = 123456789 & used = '' result=12XXXXX89
This is my code for fetching, creating the table and also for the function to "X out" the middle digits:
<?php
$sql="SELECT * FROM table";
$result=mysql_query($sql);
// Count table rows
$count=mysql_num_rows($result);
?>
<?php function blankit($word) {
return substr($word, 0,2). str_repeat("X",strlen($word)-4) . substr($word, strlen($word)-2,strlen($word));
}
?>
<?php while($rows=mysql_fetch_array($result, MYSQL_ASSOC)){ ?>
<tr class="first">
<td class="tc"><font face="Arial, Helvetica, sans-serif"><? echo $rows['id']; ?></font></td>
<td class="tc"><font face="Arial, Helvetica, sans-serif"><? echo $rows['code']; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo $rows['date']; ?></font></td>
<td class="tc"><font face="Arial, Helvetica, sans-serif"><? echo $rows['ip']; ?></font></td>
<td class="tc"><input name="checkbox[]" type="checkbox" class="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td>
</tr>
<?php
}
?>