iammudassir Posted November 25, 2012 Share Posted November 25, 2012 i have "perosn" table in database "geotex" with 3 fields dept name and agedate in table like this dept name agemale abc 33male xyz 2female 123 25 i create a table like thisperson.php field1 [dept] field2[name] field3[age]field1 [dept] field2[name] field3[age]field1 [dept] field2[name] field3[age]field1 [dept] field2[name] field3[age] and i have a button with name of "select" now i want to run a sql query select * from person where dept = maleand want to disply result like male in field1 abc in field2 33 in field 3male in field1 xyz in field2 2 in field 3 when i run php code with isset = post[select]then run above query and problem starts from here i use while ($result = mysql_fetch_array($run)) {echo $name = $result ['name'];} // this echo shows both abc and xyz but i wanna show abc name using array position } some body says use foreach but i dont have idea how to use foreach Link to comment Share on other sites More sharing options...
justsomeguy Posted November 26, 2012 Share Posted November 26, 2012 It's kind of hard to understand what you're asking for, but it might be this: while ($result = mysql_fetch_array($run, MYSQL_NUM)){ for ($i = 0; $i < count($result); $i++) { echo $result[$i] . ' in field ' . ($i + 1) . '<br>'; }} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now