我有6個不同的字段的表單來輸入日期(day1
到day6
)和6個不同的字段中輸入該特定日期(dtls1
到dtls6
)的細節。這些所有數據都將轉到數據庫。還有一個頁面顯示所有這些數據。選擇是根據日期。代碼如下:檢索從同一個表相同的數據兩次
$today = date('D, d M, Y');
$sql = "SELECT * FROM tables WHERE day1 = '$today' AND org = 'green'";
if($_POST!=""){
$mydate = mysql_real_escape_string($_POST['datepicker']);
if($mydate!=""){
$sql = "SELECT * FROM tables WHERE day1 = '$mydate' AND org = 'green'";
}
}
$string = nl2br($string);
$num_results_per_page = 2;
$num_page_links_per_page = 5;
$pg_param1 = ""; // Ex: &q=value
$result=mysql_query($sql);
$row = mysql_fetch_array($result);
pagination($sql, $num_results_per_page, $num_page_links_per_page, $pg_param);
if($pg_error == '')
{
if(mysql_num_rows($pg_result) > 0)
{
while($data = mysql_fetch_assoc($pg_result))
{
echo "<table width=585 height=203>
<tr>
<td height=10 colspan=3 align=left valign=top></td>
</tr>
<tr>
<td height=17 colspan=3 align=center valign=middle class=text6>". $data['pgmtitle'] .".</td>
</tr>
<tr>
<td height=17 colspan=3 align=center valign=middle class=text8>". $data['org'] .".</td>
</tr>
<tr>
<td height=21 colspan=3 align=center valign=middle class=text19>". $data['programdtls1'] ." OR</td>
</tr>
<tr>
<td width=190 height=32 align=left valign=top class=text3>". $data['venue'] ."</td>
<td width=11 rowspan=2 align=left valign=top><div class=box2></div></td>
<td width=368 rowspan=2 align=left valign=top class=text7>
<b>Contact:</b> ". $data['contactperson'] ."
<br/><b>Phone:</b> ". $data['contactnumber'] ."
<br/><b>E-mail ID:</b> ". $data['email'] ."
<br/><b>Website:</b> ". $data['website'] ."</td>
</tr></table><br/>"
echo "</br>". $pagination_output;
}
else
{
echo '<p class="text11">No events listed for this day.</p>';
}
}
else
{
echo $pg_error; //display any errors, you can remove this if you want.
}
?>
此代碼工作正常。問題是我想顯示是否有任何內容(programdtls2到programdtls6)。事情是,與programdtls2我想顯示場地,聯繫人,聯繫電話等與programdtls1相同。像...
echo "<table width=585 height=203>
<tr>
<td height=10 colspan=3 align=left valign=top></td>
</tr>
<tr>
<td height=17 colspan=3 align=center valign=middle class=text6>". $data['pgmtitle'] .".</td>
</tr>
<tr>
<td height=17 colspan=3 align=center valign=middle class=text8>". $data['org'] .".</td>
</tr>
<tr>
<td height=21 colspan=3 align=center valign=middle class=text19>". $data['programdtls2'] ."</td>
</tr>
<tr>
<td width=190 height=32 align=left valign=top class=text3>". $data['venue'] ."</td>
<td width=11 rowspan=2 align=left valign=top><div class=box2></div></td>
<td width=368 rowspan=2 align=left valign=top class=text7>
<b>Contact:</b> ". $data['contactperson'] ."
<br/><b>Phone:</b> ". $data['contactnumber'] ."
<br/><b>E-mail ID:</b> ". $data['email'] ."
<br/><b>Website:</b> ". $data['website'] ."</td>
</tr></table><br/>"
表結構
"id_user INT NOT NULL AUTO_INCREMENT ,".
"org VARCHAR(100) NOT NULL ,".
"pgmtitle VARCHAR(100) NOT NULL ,".
"category VARCHAR(32) NOT NULL ,".
"relation VARCHAR(75) NOT NULL ,".
"venue VARCHAR(75) NOT NULL ,".
"hr VARCHAR(30) NOT NULL ,".
"min VARCHAR(30) NOT NULL ,".
"time VARCHAR(30) NOT NULL ,".
"day1 VARCHAR(30) NOT NULL ,".
"day2 VARCHAR(30) NOT NULL ,".
"day3 VARCHAR(30) NOT NULL ,".
"day4 VARCHAR(30) NOT NULL ,".
"day5 VARCHAR(30) NOT NULL ,".
"day6 VARCHAR(30) NOT NULL ,".
"city VARCHAR(35) NOT NULL ,".
"others VARCHAR(35) NOT NULL ,".
"contactperson VARCHAR(128) NOT NULL ,".
"contactnumber VARCHAR(128) NOT NULL ,".
"email VARCHAR(64) NOT NULL ,".
"programdtls1 VARCHAR(150) NOT NULL ,".
"programdtls2 VARCHAR(150) NOT NULL ,".
"programdtls3 VARCHAR(150) NOT NULL ,".
"programdtls4 VARCHAR(150) NOT NULL ,".
"programdtls5 VARCHAR(150) NOT NULL ,".
"programdtls6 VARCHAR(150) NOT NULL ,".
"nature VARCHAR(50) NOT NULL ,".
"resentry VARCHAR(50) NOT NULL ,".
"confirmcode VARCHAR(32) ,".
"PRIMARY KEY (id_user)".
")";
這可能
請格式化您的文章。 – 2011-06-03 08:59:19
你可以列出你的表結構 – ejrowley 2011-06-03 09:50:10
其完全無法理解你在找什麼 – dynamic 2011-06-03 10:00:18