Advertisement
Guest User

Untitled

a guest
Jul 7th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.87 KB | None | 0 0
  1. <?php session_start();
  2.  
  3. if(!session_is_registered(myusername)){
  4. header("location:main_login.php");
  5. }
  6.  
  7. require_once('calendar/classes/tc_calendar.php');
  8. header ( "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
  9. header ("Pragma: no-cache");
  10. ?>
  11.  
  12. <html>
  13. <head>
  14. <script language="javascript" src="calendar/calendar.js"></script>
  15. <link href="calendar/calendar.css" rel="stylesheet" type="text/css">
  16.  
  17. <style type="text/css">
  18. body
  19. {
  20. background-color:#d0e4fe;
  21. }
  22. h1
  23. {
  24. color:orange;
  25. text-align:center;
  26. }
  27. p
  28. {
  29. font-family:"Times New Roman";
  30. font-size:20px;
  31. }
  32. form
  33. {
  34. width: 400px; text-align:center; border: 0px solid #5a698b
  35. }
  36.  
  37. </style>
  38. </head>
  39.  
  40. <body>
  41.  
  42. <?php
  43.  
  44. $hostname = "localhost";
  45. $dbuser = "thestory_carl";
  46. $dbpassword = "carl";
  47. $dbname = "thestory_mancstore";
  48.  
  49.      mysql_connect($hostname, $dbuser, $dbpassword)
  50.      or die("Unable to connect to the server!");
  51.  
  52.      mysql_select_db($dbname)
  53.      or die("Unable to connect to the database");
  54.         $fields_array=array(); $num_fields=0; $num_row=0;
  55.  
  56.         $sql="select fname,sname,customerid from customer ";
  57.  
  58.     // find position of "FROM" in query
  59.         $fpos=strpos($sql, 'from');
  60.  
  61.         // get string starting from the first word after "FROM"
  62.         $strfrom=substr($sql, $fpos+5, 50);
  63.  
  64.         // Find position of the first space after the first word in the string
  65.         $Opos=strpos($strfrom,' ');
  66.  
  67.         //Get table name. If query pull data from more then one table only first table name will be read.
  68.         $table=substr($strfrom, 0,$Opos);
  69.  
  70.            // Get result from query
  71.             $result=mysql_query($sql);
  72.             $num_row=mysql_numrows($result);
  73.  
  74.             if($num_row >0)
  75.             {
  76.                     //Get number of fields in query
  77.                     $num_fields=mysql_num_fields($result);
  78.  
  79.          
  80.  
  81.            # get column metadata
  82.            $i = 0;
  83.  
  84.              //Set table width 15% for each column
  85.             $width=10 * $num_fields;
  86.  
  87.             print('<br><table width='.$width.'% align="center"><tr>');
  88.             print('<tr><th colspan='.$num_fields.'></th></tr>');
  89.  
  90.              while ($i < $num_fields)
  91.              {
  92.  
  93.               //Get fields (columns) names
  94.             $meta = mysql_fetch_field($result);
  95.  
  96.             $fields_array[]=$meta->name;
  97.  
  98.            //Display column headers in upper case
  99.        print('<th><b>'.strtoupper($fields_array[$i]).'</b></th>');
  100.  
  101.                     $i=$i+1;
  102.                     }
  103.  
  104.             print('</tr>');
  105.  
  106.  
  107.                    //Get values for each row and column
  108.                 while($row=mysql_fetch_row($result))
  109.                 {
  110.                  print('<tr>');
  111.  
  112.                         for($i=0; $i<$num_fields; $i++)
  113.                         {
  114.                         //Display values for each row and column
  115.                         print('<td align = center>'.$row[$i].'</td>');
  116.  
  117.                         }
  118.  
  119.                 print('</tr>');
  120.                 }
  121.  
  122.     }
  123.  
  124.  
  125. ?>
  126.  
  127. <h1><b>Add Item</b></h1>
  128. <form id="form1" name="form1" method="post" action="insertnewitem.php">
  129. <div align="center">
  130.  
  131. <?php
  132. $host="localhost"; // Host name
  133. $username="thestory_carl"; // Mysql username
  134. $password="carl"; // Mysql password
  135. $db_name="thestory_mancstore"; // Database name
  136. $tbl_name="users"; // Table name
  137.  
  138. $link = mysql_connect($host, $username, $password);
  139. mysql_select_db($db_name);
  140.  
  141. $query = "SELECT customerid FROM customer";
  142. $result = mysql_query($query);
  143. print "Customer ID: <SELECT name=item>";
  144. while ($line = mysql_fetch_array($result))
  145. {
  146. foreach ($line as $value)
  147. {
  148. print "<OPTION value='$value'";
  149. }
  150. print ">$value</OPTION>";
  151. }
  152. mysql_close($link);
  153. print "</SELECT>";
  154.  
  155.  
  156. ?>
  157.  
  158.  
  159. <br>
  160. <div align="center">
  161. Type: <input type="text" name="type" /><br>
  162. <table border="0" cellspacing="0" cellpadding="2">
  163. <tr>
  164. <td>Collection Date:</td>
  165. <td><?php
  166. $myCalendar = new tc_calendar("date5", true, false);
  167. $myCalendar->setIcon("calendar/images/iconCalendar.gif");
  168. $myCalendar->setPath("calendar/");
  169. $myCalendar->setYearInterval(2000, 2015);
  170. $myCalendar->dateAllow('2008-05-13', '2015-03-01');
  171. $myCalendar->setDateFormat('j F Y');
  172. $myCalendar->writeScript();
  173. ?></td>
  174. </tr>
  175. </table>
  176.  
  177. <table border="0" cellspacing="0" cellpadding="2">
  178. <tr>
  179. <td>Release Date:</td>
  180. <td><?php
  181. $myCalendar = new tc_calendar("date6", true, false);
  182. $myCalendar->setIcon("calendar/images/iconCalendar.gif");
  183. $myCalendar->setPath("calendar/");
  184. $myCalendar->setYearInterval(2000, 2015);
  185. $myCalendar->dateAllow('2008-05-13', '2015-03-01');
  186. $myCalendar->setDateFormat('j F Y');
  187. $myCalendar->writeScript();
  188. ?></td>
  189. </tr>
  190. </table>
  191.  
  192.  
  193. <p>
  194. <input type="submit" name="Submit" value="Submit" />
  195. </p> <br>
  196.  
  197. <br>
  198. </form>
  199. <form action="snapshot.php" method="post">
  200. <div align="center">
  201. <input type="submit" value = "Back"/><br><br>
  202. </form>
  203.  
  204. </body>
  205. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement