Page 1 of 1

For Every Row In mySQL Database

Posted: Tue Jul 20, 2010 10:09 am
by Quazel
How do I make php run a script for every row in a sql database and stop when there is no more rows.

Re: For Every Row In mySQL Database

Posted: Tue Jul 20, 2010 5:00 pm
by JakeJ
$qry = mysql_query("SELECT something FROM table");

While($row = mysql_fetch_array($qry) {
echo $row['something'];
}

Re: For Every Row In mySQL Database

Posted: Tue Jul 20, 2010 8:14 pm
by kurbot
too elaborate alittle more:

Code: Select all

function MyFunction($parm1 = '', $parm2 = '', $etc = ''){
// Do Something

}

$qry = mysql_query("SELECT something FROM table");

While($row = mysql_fetch_array($qry) {
  echo $row['fieldname']; // would echo data from the data field
  MyFunction($parm1, $parm2, $etc); // Would Call a Script/Function | Parms are OPTIONLA
}