how do I loop through each row checking to see if those rows have a certain value?
Thanks
Rainloop through each row?
first you have to do a query on the db to get what you want.
$query = mysql_query("select * from table");
//then loop thourgh it with the
while($row = mysql_fetch_array($query)){
// do your vlaidation here in this loop.
}
is that what you mean? also you can search the whole db for one thing like so
$query = mysql_query("select * from table where id = 'some ID'");
like that?thats exactly what I wanted to know. So this woudl print every row...
$conn = mysql_connect("localhost", "login", "pass") or die (mysql_error()); //connects to mysql
mysql_select_db("databasename", $conn) or die (mysql_error()); //selects what data base to use
$sql = mysql_query("select * from table_name"); //creates the query
while($row = mysql_fetch_array($sql)) {
print "$row<br>\n";
}
Is $row an array or a variable?
I'm assuming its an array and the keys are the names of each column. Thatd be nice
Thanks
Rainthat would be correct. $row is the array tha tcontains all of the field names (columns).
so $row[0] is the same as $row[id] if id was the first column.nice!
Thanks a lot!
Rain
Thanks
Rainloop through each row?
first you have to do a query on the db to get what you want.
$query = mysql_query("select * from table");
//then loop thourgh it with the
while($row = mysql_fetch_array($query)){
// do your vlaidation here in this loop.
}
is that what you mean? also you can search the whole db for one thing like so
$query = mysql_query("select * from table where id = 'some ID'");
like that?thats exactly what I wanted to know. So this woudl print every row...
$conn = mysql_connect("localhost", "login", "pass") or die (mysql_error()); //connects to mysql
mysql_select_db("databasename", $conn) or die (mysql_error()); //selects what data base to use
$sql = mysql_query("select * from table_name"); //creates the query
while($row = mysql_fetch_array($sql)) {
print "$row<br>\n";
}
Is $row an array or a variable?
I'm assuming its an array and the keys are the names of each column. Thatd be nice
Thanks
Rainthat would be correct. $row is the array tha tcontains all of the field names (columns).
so $row[0] is the same as $row[id] if id was the first column.nice!
Thanks a lot!
Rain