"Marcel Brekelmans" <ma****@marcel-art.com> wrote in message
news:29******************************@giganews.com ...
.....
$oCursor = mysql_query("SELECT ID from tblName WHERE Name='Jane'");
if (!$oCursor)
{
$bGo = false;
}
else
{
$aRow = mysql_fetch_array($oCursor);
}
results in:
count($aRow) = 2;
$aRow[0] = 1;
$aRow[1] = '';
Am I missing something, doing something wrong, a wrong PHP setting?
Hoi Marcel
This is the function I use:
function getdata($sql) {
$result = @mysql_query($sql) or die("Error: " . mysql_error()." sql was
".$sql);
$ret = array();
while($row = mysql_fetch_assoc($result)) {
$ret[] = $row;
}
mysql_free_result($result);
return $ret;
}
then, in my code, I used:
$sql = "SELECT ID from tblName WHERE Name='Jane'";
$data = getdata($sql)
foreach ($data as $ds) {
echo $ds["Name"];
}
Once you use it a few times, it just makes life really easy, especially
because you refer to fields by name rather than position (e.g.$ds[0]).
Having said that, I am not sure what you are doing wrong ;-) I think that
you only fetch one row. A better way to do this is
while($row = mysql_fetch_row($query)) {
}
Note the single "is teken".
- Nicolaas