How to write the simplest query result statement

Source: Internet
Author: User
I don't have PHP, but now there's only PHP space,
Want a function, very simple one,

Two columns (A & B) in the data table
Implementation: I enter a value in the text box, in the database query a column of the value of the B column corresponding to the value and return to the page.

The amount ... Can a great God help write a more complete sentence? That includes the database Connection statements section.


Reply to discussion (solution)

error_reporting (0);
$conn =mysql_connect ("localhost", "root", "root");//fill in the database connection information
mysql_select_db ("test");//fill in the database name
$valA = $_post["ValA"];
if ($valA! = "") {
$sql = "SELECT * FROM Test where a=". $valA;
$result =mysql_query ($sql);
while ($arr =mysql_fetch_array ($result))
{
echo $arr ["B"]. "
";
}
}else{
?>

}
?>

? is outsourcing, since you do not want to?

You?? function doesn't??, Bai? You're done.

error_reporting (0);
$conn =mysql_connect ("localhost", "root", "root");//fill in the database connection information
mysql_select_db ("test");//fill in the database name
$valA = $_post["ValA"];
if ($valA! = "") {
$sql = "SELECT * FROM Test where a=". $valA;
$result =mysql_query ($sql);
while ($arr =mysql_fetch_array ($result))
{
echo $arr ["B"]. "
";
}
}else{
?>

}
?>
Thank you, thank you very much

? is outsourcing, since you do not want to?
Gaga, you use. NET will, helpless know logic is not become PHP, to ask for the next PHP big god ...

error_reporting (0);
$conn =mysql_connect ("localhost", "root", "root");//fill in the database connection information
mysql_select_db ("test");//fill in the database name
$valA = $_post["ValA"];
if ($valA! = "") {
$sql = "SELECT * FROM Test where a=". $valA;
$result =mysql_query ($sql);
while ($arr =mysql_fetch_array ($result))
{
echo $arr ["B"]. "
";
}
}else{
?>

}
?>


echo $arr ["B"], B replace with the column name of my column?

Well, yes, a is replaced with your conditional field name, B is replaced with the field name you want to get the result

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.