Hello Everyone,
I am learning PHP and devoloping a php free ebook website.
I got stuck at this: how to add a date field so the ebook will be shown/posted at that spacific date.
When u access my new book section, u will see the date when these books were added.
I want to be able to control that. I have read some articles but got confused about it, hope some one can help.
the code for my control section (add/delet/edit category):
To add a book
<td width="66%" bgcolor="#A4D0D0" align="center">
<font face="Tahoma" size="2"><span lang="ar-kw">add book
</span></font></td>
</tr>
<tr>
<td width="66%" align="center"><form method="POST" action="control.php">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td width="25%" align="center">
<font face="Tahoma" size="2">Title</font></td>
<td width="75%">
<input type="text" name="title" size="50" dir="rtl"></td>
</tr>
<tr>
<td width="25%" align="center">
<font face="Tahoma" size="2">Author</font></td>
<td width="75%">
<input type="text" name="name" size="50" dir="rtl"></td>
</tr>
<tr>
<td width="25%" align="center">
<font face="Tahoma" size="2">Editor</font></td>
<td width="75%">
<input type="text" name="des" size="50" dir="rtl"></td>
</tr>
<tr>
<td width="25%" align="center">
<font face="Tahoma" size="2"><span lang="ar-kw"> exe</span></font></td>
<td width="75%">
<input type="text" name="zip_file" size="50" dir="ltr" value=""></td>
</tr>
<tr>
<td width="25%" align="center">
<font face="Tahoma" size="2"><span lang="ar-kw">PDF</span></font></td>
<td width="75%">
<input type="text" name="pdf_file" size="50" dir="ltr" value=""></td>
</tr>
<tr>
<td width="25%" align="center">
<font face="Tahoma" size="2"><span lang="ar-kw">Word</span></font></td>
<td width="75%">
<input type="text" name="word_file" size="50" dir="ltr" value=""></td>
</tr>
<tr>
<td width="25%" align="center">
<font face="Tahoma" size="2">Photo</font></td>
<td width="75%">
<input type="text" name="pic" size="50" dir="ltr" value=""></td>
</tr>
<tr>
<td width="25%" align="center">
<font face="Tahoma" size="2">section</font></td>
<td width="75%">
<select size="1" name="catid" dir="rtl">
<?
$query = mysql_query("SELECT id,title FROM myCat");
while($data=mysql_fetch_array($query)) {
echo "<option value=\\"$data[id]\\">$data[title]</option>";
}
?>
</select></td>
</tr>
</table>
<p>
<input type="hidden" name="do" value="<? echo $do; ?>">
<input type="submit" value="add" name="B1"><br> </p>
</form>
</td>
to edit a book:
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="97%" id="AutoNumber1">
<tr>
<td width="66%" bgcolor="#A4D0D0" align="center">
<font face="Tahoma" size="2"><span lang="ar-kw"> edit a book</span></font></td>
</tr>
<tr>
<td width="66%" align="center"><form method="POST" action="control.php">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td width="25%" align="center">
<font face="Tahoma" size="2">Title</font></td>
<td width="75%">
<input type="text" name="title" size="50" dir="rtl" value="<? echo $data[title]; ?>"></td>
</tr>
<tr>
<td width="25%" align="center">
<font face="Tahoma" size="2">Author</font></td>
<td width="75%">
<input type="text" name="name" size="50" dir="rtl" value="<? echo $data[name]; ?>"></td>
</tr>
</tr>
<tr>
<td width="25%" align="center">
<font face="Tahoma" size="2">Editor</font></td>
<td width="75%">
<input type="text" name="des" size="50" dir="rtl" value="<? echo $data[des]; ?>"></td>
</tr>
<tr>
<td width="25%" align="center">
<font face="Tahoma" size="2"><span lang="ar-kw">exe</span></font></td>
<td width="75%">
<input type="text" name="zip_file" size="50" dir="rtl" value="<? echo $data[zip_file]; ?>"></td>
</tr>
<tr>
<td width="25%" align="center">
<font face="Tahoma" size="2"><span lang="ar-kw">Word</span></font></td>
<td width="75%">
<input type="text" name="word_file" size="50" dir="rtl" value="<? echo $data[word_file]; ?>"></td>
</tr>
<tr>
<td width="25%" align="center">
<font face="Tahoma" size="2"><span lang="ar-kw">PDF</span></font></td>
<td width="75%">
<input type="text" name="pdf_file" size="50" dir="rtl" value="<? echo $data[pdf_file]; ?>"></td>
</tr>
<tr>
<td width="25%" align="center">
<font face="Tahoma" size="2">Photo</font></td>
<td width="75%">
<input type="text" name="pic" size="50" dir="rtl" value="<? echo $data[pic]; ?>"></td>
</tr>
<tr>
<td width="25%" align="center">
<font face="Tahoma" size="2">Section</font></td>
<td width="75%">
<select size="1" name="catid" dir="rtl">
<?
$query = mysql_query("SELECT id,title FROM myCat");
while($data=mysql_fetch_array($query)) {
echo "<option value=\\"$data[id]\\">$data[title]</option>";
}
?>
</select><font face="Tahoma" size="1">* catagory:</font></td>
</tr>
</table>
<p>
<input type="hidden" name="do" value="<? echo $do; ?>">
<input type="hidden" name="old_cida" value="<? echo $old_cida; ?>">
<input type="hidden" name="myfile" value="<? echo $myfile; ?>">
<input type="submit" value="done" name="B_save_me"><br> </p>
</form>
</td>
</tr>
</table>
The Code for listing the ebooks:
<tr>
<td width="42%" align="center" bgcolor="#DADADA">
<b>
<span lang="ar-kw">
<font face="Arial" color="#008000">
title</font></span></b></td>
<td width="22%" align="center" bgcolor="#DADADA">
<b>
<span lang="ar-kw">
<font face="Arial" color="#008000">
Author</font></span></b></td>
<td width="20%" align="center" bgcolor="#DADADA">
<b>
<span lang="ar-kw">
<font face="Arial" color="#008000">
Editor</font></span></b></td>
<td width="10%" align="center" bgcolor="#DADADA">
<b>
<font face="Arial" color="#008000" size="2"><span lang="ar-kw">
Date</span></font></b></td>
</tr>
<?
while($data = mysql_fetch_array($query)) {
$date = Format_Date($data[date]);
echo "
<tr>
<td width='35%' align='center' height='30'>
<p align='right'><b><font face='Arial' size='2'>
<span lang='ar-kw'> </span><span lang='en-us'><img border='0' src='images/paper.gif' width='6' height='9'></span><span lang='ar-kw'>
</span><span lang='en-us'>
<font face='Arial' size='3'><b><span lang='en-us'>
<a href=open.php?cat=$cat&book=$data[id] style=\\"text-decoration: none\\">$data[title]</a></span></font></b></td>
<td width='25%' align='center' height='30'>
<font face='Arial' size='2'><b><span lang='en-us'>
<a href='search.php?do=all&u=$data[name]' style=\\"text-decoration: none\\">$data[name]</a></span></b></font></td>
<td width='15%' align='center' height='30'>
<font face='Arial' size='2'><b><span lang='en-us'>
<a href='search.php?do=all&u=$data[des]' style=\\"text-decoration: none\\">$data[des]</a></span></b></font></td>
<b><font size='2'>
<td width='15%' align='center' height='30'></font>
<font face='Arial' size='1'>
<span lang='en-us'>$date</span></font></b></td>
</tr>";
Thank you so much.