Greetings

i make a code to show spacific fields of a table is there anyway to make all fields with its records appear ?

this is my code

<?php
$db_host = "localhost";
$db_username = "root";
$db_pass = "";
$db_name = "el";


@mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect"); 
@mysql_select_db("$db_name") or die ("No database found");
echo"you are connected to the DB<br>";

$show= "SELECT * FROM sutdent_info";

$res= mysql_query($show);

while ($show =mysql_fetch_array($res))

{

$filed1 =$show[Name];
$filed2 =$show[ID];


echo "Name: $filed1   $filed2<br>  ";

}



?>

thank You

Recommended Answers

All 4 Replies

There are numerous ways. For example, you can use the mysql_field_name() function. Or you can alter your script. In the loop, do

foreach($show as $key => $value)
  echo "$key: $value\t";
echo "\n";

sorry but i don't think i understand you

i'm new to php would you explain more....

Member Avatar for diafol

Did you try the code?

i had some troubles understanding it but i fixed it :)

thank you everyone

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.