dscbxou1900343 2013-09-25 19:56
浏览 50
已采纳

从SQL数据库添加网站内容

I am very new to PHP so this might be a silly question to some but my website is currently broken up into includes and I have managed to establish a database connection but i would like the content in the "about" page to come from a SQL database and not be static HTML. My question is how would I actually go about writing the PHP to get the content from the database and have it displayed in the relevant tag?

Here is a link to the site: http://midway-media.net/3/about.php

This is my code at the moment:

<?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";?>
  • 写回答

1条回答 默认 最新

  • drsxobip501258 2013-09-25 20:01
    关注

    Are you familiar with SQL? If you know how to make your query to pull the information you want. You can simply query it to a php variable:

    $variable1 = mysql_query("Your SQL query goes here");
    

    Then in your html, where ever you want that text:

    <?php echo $variable1; ?>
    

    That should print out the contents of the variable (and in effect, the query), into your html.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭