Advertisement
Guest User

Untitled

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