首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >从SQL数据库中添加网站内容

从SQL数据库中添加网站内容
EN

Stack Overflow用户
提问于 2013-09-25 19:56:25
回答 1查看 197关注 0票数 0

我对PHP非常陌生,所以对某些人来说,这可能是一个愚蠢的问题,但我的网站目前已被分解为包含,并且我设法建立了一个数据库连接,但我希望"about“页面中的内容来自SQL数据库,而不是静态HTML。我的问题是,如何编写PHP以从数据库获取内容并将其显示在相关的标记中?

以下是指向该站点的链接:http://midway-media.net/3/about.php

这是我目前的代码:

代码语言:javascript
运行
复制
<?php include_once "includes/scripts.php"; ?>
<?php include_once "includes/header.php";?> 
<?php
    $db_host = "localhost";
    $db_user = "root";
    $db_pass = "";
    $db_name = "camelhorse";
    $db_error_one= "<h1>Could not connect to database</h1>";
    $db_error_two= "<h1>Database 'camelhorse' is not available</h1>";
    @mysql_connect ($db_host,$db_user,$db_pass) or die ($db_error_one);
    @mysql_select_db("$db_name") or die ("$db_error_two");
?>
<img id="logo_full_name" src="images/camelhorst_logo_full.png" alt="Camelhorse Creative Studio">
<article>
    <img src="images/long_line_single_column.png" style="margin:10px auto 0px auto;">
    <h1>ABOUT OUR COMPANY</h1>
    <p>Camelhorse is a Creative Agency is multi disciplinary creative partner, specializing in Brand Development and with sub divisions in web development, communication design and photography. We provide effective solutions for various marketing and communication requirements.<br><br>
Companies today are looking for creative partners that will supply them with tangible results, ensuring their brand or products succeed against their competition in this tough and competitive economic environment. We offer clients the edge in their respective industries, by truly understanding their brand through extensive market related research, and strategically positioning their brand or products correctly in the market. We are able to make brands and products stand out from the clutter and help them reach consumers in the most effect way.<br><br>
Camelhorse Creative Agency offers a complete solution from conceptualization of an idea to production, and supplying a finished product to our clients when it comes to Brand Development, Brand Activation, Point-of-Sale, Digital Implementation, Tactical and Strategic development. Contact us today and let see what we can do for your brand.</p>
    <img src="images/three_column_grid_line.png" alt="line">
    <h2>MISSION</h2>
    <p>Camelhorse’s mission is to provide the best creative service in the industry is a fun and humoristic way we approach business seriously and aspire to be the most creative and dynamic media house with one stop in house services for all your branding needs.</p>
    <h2>VISION</h2>
    <p>We see ourselves a industry leading creative agency in the near future offering the most contemporary designs and development techniques. We aspire to this daily with a dedicated team.</p>
</article>
<?php include_once "includes/footer.php";?>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-25 20:01:20

您熟悉SQL吗?如果您知道如何使您的查询,以获取您想要的信息。您可以简单地将其查询到php变量:

代码语言:javascript
运行
复制
$variable1 = mysql_query("Your SQL query goes here");

然后在你的html中,在你想要的任何地方:

代码语言:javascript
运行
复制
<?php echo $variable1; ?>

它应该将变量的内容(实际上是查询)打印到html中。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19014073

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档