2011-11-19 56 views
0

我目前有这个代码在页面/ div当你加载它没有任何在url栏(又名只是index.php)我将如何在一个页面加载一些PHP代码代替其他php代码

<?php echo"<h1>For all of your Citation needs!</h1> 

<div > 

<p> 

This page is for any citations you would need to make for reports or essays. Once you enter in the needed information for your sourse, it will spit out the citations in <a href='http://owl.english.purdue.edu/owl/resource/747/01/'>MLA</a> &amp; <a href='http://owl.english.purdue.edu/owl/resource/560/01/'>APA</a> format.</p> 
<p >In development is a system where your citations are stored in a database and everytime you make a new one, you will be given related reference material to help your research. Also available soon will be the ability to look up references using related fields such as:</p> 

<ul> 
<li>Authors</li> 
<li>Ttile of Work</li> 
<li>Publishing Company</li> 
<li>Journal Publisher</li> 
<li>Academic Source</li> 
<li>Something else will go here</li> 
</ul> 


</div>"; ?> 

当我点击网站上的链接来加载不同形式的数据(的index.php?形式=书),我想在该分区表单数据发生的东西了...对例如:

<?php 
switch ($_GET['form']) 
{ 
    case 'book': 
     ?> 
     <form method="POST" action="thispage.php"> 
      <input name="" type="text" value="fghfghfghfghfghfh" /> 
     </form> 
     <? 
     break; 
    case 'b': // show form b 
     ?> 
     <form method="POST" action="thispage.php"> 
      <!-- form b elements here :) --> 
     </form> 
     <? 
     break; 
    case 'c': // show form c 
     ?> 
     <form method="POST" action="thispage.php"> 
      <!-- form c elements here :) --> 
     </form> 
     <? 
     break; 
} 
?> 

是当你点击链接加载表单数据时,在页面/ div中有没有^ TH^^代码块代替另一个php代码块?

+0

另外,如果你”只是学习PHP,这是一个伟大的作者一本体面的书:http://www.amazon.com/PHP-Web-Visual-QuickStart-Guide/dp/0321733452/ –

回答

0

为您的switch语句添加“code”的第一个块作为default。在构建您的页面,但的更好的方法......

switch PHP手册:http://php.net/manual/en/control-structures.switch.php

编辑:您的代码样本,更新:

<?php 
    switch ($_GET['form']) 
    { 
     case 'book': 
      ?> 
      <form method="POST" action="thispage.php"> 
       <input name="" type="text" value="fghfghfghfghfghfh" /> 
      </form> 
      <? 
      break; 
     case 'b': // show form b 
      ?> 
      <form method="POST" action="thispage.php"> 
       <!-- form b elements here :) --> 
      </form> 
      <? 
      break; 
     case 'c': // show form c 
      ?> 
      <form method="POST" action="thispage.php"> 
       <!-- form c elements here :) --> 
      </form> 
      <? 
      break; 
     default: 
      echo "<h1>For all of your Citation needs!</h1> 

       <div > 

       <p> 

       This page is for any citations you would need to make for reports or essays. Once you enter in the needed information for your sourse, it will spit out the citations in <a href='http://owl.english.purdue.edu/owl/resource/747/01/'>MLA</a> &amp; <a href='http://owl.english.purdue.edu/owl/resource/560/01/'>APA</a> format.</p> 
       <p >In development is a system where your citations are stored in a database and everytime you make a new one, you will be given related reference material to help your research. Also available soon will be the ability to look up references using related fields such as:</p> 

       <ul> 
       <li>Authors</li> 
       <li>Ttile of Work</li> 
       <li>Publishing Company</li> 
       <li>Journal Publisher</li> 
       <li>Academic Source</li> 
       <li>Something else will go here</li> 
       </ul> 


       </div>"; 
       break; 
    } 
?> 
+0

感谢链接到SWITCH的帮助。 我将如何将其设置为默认寿命? – willkara

+0

nvm可能已经算出来了 – willkara

+0

如果没有,请参阅上文。 –

相关问题