Hi Everyone,
Is it just me, or something is BADLY wrong with some MySQL functions?
Is there some rule in which order to call mysql functions?
I made following routine:
<!--- code start -->
<?php
function prikazi_masku($tablica, $key_field, $key_value) {
global $mycon_id;
$data = mysql_query("SELECT * FROM $tablica WHERE $key_field='" .
$key_value . "'", $mycon_id);
if(!$data) {
echo("MySQL Error: " . mysql_error() . "<br>");
return 0;
};
if(mysql_affected_rows()==0) {
echo('No data.<br>');
return 0;
};
echo("<table border=1 bgcolor=#e0e0e0 bordercolor=#e0e0e0
cellspacing=1 cellpadding=3>");
echo("<tr bgcolor=#800080>");
// First field and its value I show in different color
$meta = mysql_fetch_field ($data);
$data_row = mysql_fetch_array ($data);
// Here I want to get number of fields
$n = mysql_num_fields($data);
echo("<td><b><font color=white>$meta->name</td>");
echo("<td><b><font color=white>$data_row[0]</td></tr>");
$i = 1;
// Now I show fields from index 1 to the last field
while ($i < $n) {
$meta = mysql_fetch_field($data);
echo("<tr><td>$meta->name</td><td>$data_row[i]</td></tr>");
$i++;
};
echo("</table>");
return 1;
};
?>
<!-- code end -->
Table I tried to show has 7 fields; first row (first field) show OK, but the
rest ARE EMPTY!!!
I tried to change the order of functions or anything, but it seems that
after first acces of mysql_fetch_field something happens to $data_row?!?
Can someone explain this and help me work out with it?
TIA
Davor
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]