Advertisement
Guest User

Untitled

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