how do i display all records of a field using php in a mysql database -


so want records of specific field in table using mysql database

so far tried echos first ever record in field

$query = ("select txtpath,txtname txtdocs subject='$ref'"); $result = mysql_query($query);   $count = mysql_num_rows($result); //iterate on rows while($row = mysql_fetch_assoc($result)){     //iterate on fields     foreach($row $key => $val){         //generate output         echo $key . ": " . $val . "<br />";     } } 

also yes have more 1 record in database

edit: added 1 more row can have total of 3 rows, it's showing me 2 out of 3 records now.

no need use loop inside loop:

while($row = mysql_fetch_assoc($result)) {     echo $row["txtname"] . ": " . $row["txtpath"]. "<br/>";  } 

update 1:

if value if $ref english query must return 3 records not two. need debug further ny checking column value maybe have space around column value " english".

update 2:

further more execute select query in phpmyadmin , check how many rows return.

select txtpath,txtname txtdocs subject="english"; 

side note:

please use mysqli_* or pdo instead of mysql_* deprecated , not available in php 7.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -