Hello all. well i am doing a database query (using e107 db class), which pulls on average 20-30 rows. I want each row to be extracted, then i want to preform a function called fixdos on each row. I am doing this because when i first started writing the program, i saved the date in this format: 2005-02-01 – but now i want to change those into a unix time stamp. So i have created a temporary column called tempdos. the script grabs the dos, uses the mktime(), then it is supposed to put it back into tempdos. It works, but only for the first row it encounters. Is there something in PHP that doesn’t allow this, or is there a fix for it?
Heres my code, Again, I am using e107s db class functions:
<?php
require_once(“../class2.php”);
require_once(HEADERF);
if(IsSet($_POST[‘doit’])){
$sql -> db_Select(“visits_dvl”, “visit_id, dos”, “dos<‘2004-04-07’ ORDER by dos ASC”);
while($row = $sql -> db_Fetch()){
extract($row);
$tmp = explode(“-“, $dos);
$udate = mktime(0,0,0,$tmp[1],$tmp[2],$tmp[0]);
fixdos($visit_id, $udate);
echo $visit_id.” “.$dos.” “.$udate.”<br/>”;
}
}
$dbr = “
<div style=’text-align:center’>
<form method=’POST’ action = ‘”.e_SELF.”‘>
<input type=’hidden’ name=’doit’ value=’Y’>
<table width=’300px’>
<tr>
<td style=’text-align:center’>Preform database repair</td>
</tr>
<tr>
<td style=’text-align:center’><input type=’submit’ value=’execute’></td>
</tr>
</table>
</form>
</div>”;
echo $dbr;
function fixdos($vi, $d){
global $sql;
$sql -> db_Update(“visits_dvl”, “tempdos='”.$d.”‘ WHERE visit_id='”.$vi.”‘”);
}
?>