Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php session_start();
- if(!session_is_registered(myusername)){
- header("location:main_login.php");
- }
- require_once('calendar/classes/tc_calendar.php');
- header ( "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
- header ("Pragma: no-cache");
- ?>
- <html>
- <head>
- <script language="javascript" src="calendar/calendar.js"></script>
- <link href="calendar/calendar.css" rel="stylesheet" type="text/css">
- <style type="text/css">
- body
- {
- background-color:#d0e4fe;
- }
- h1
- {
- color:orange;
- text-align:center;
- }
- p
- {
- font-family:"Times New Roman";
- font-size:20px;
- }
- form
- {
- width: 400px; text-align:center; border: 0px solid #5a698b
- }
- </style>
- </head>
- <div align="center">
- <?php
- $hostname = "localhost";
- $dbuser = "thestory_carl";
- $dbpassword = "carl";
- $dbname = "thestory_mancstore";
- mysql_connect($hostname, $dbuser, $dbpassword)
- or die("Unable to connect to the server!");
- mysql_select_db($dbname)
- or die("Unable to connect to the database");
- $fields_array=array(); $num_fields=0; $num_row=0;
- $sql="select fname,sname,customerid from customer ";
- // find position of "FROM" in query
- $fpos=strpos($sql, 'from');
- // get string starting from the first word after "FROM"
- $strfrom=substr($sql, $fpos+5, 50);
- // Find position of the first space after the first word in the string
- $Opos=strpos($strfrom,' ');
- //Get table name. If query pull data from more then one table only first table name will be read.
- $table=substr($strfrom, 0,$Opos);
- // Get result from query
- $result=mysql_query($sql);
- $num_row=mysql_numrows($result);
- if($num_row >0)
- {
- //Get number of fields in query
- $num_fields=mysql_num_fields($result);
- # get column metadata
- $i = 0;
- //Set table width 15% for each column
- $width=10 * $num_fields;
- print('<br><table width='.$width.'% align="center"><tr>');
- print('<tr><th colspan='.$num_fields.'></th></tr>');
- while ($i < $num_fields)
- {
- //Get fields (columns) names
- $meta = mysql_fetch_field($result);
- $fields_array[]=$meta->name;
- //Display column headers in upper case
- print('<th><b>'.strtoupper($fields_array[$i]).'</b></th>');
- $i=$i+1;
- }
- print('</tr>');
- //Get values for each row and column
- while($row=mysql_fetch_row($result))
- {
- print('<tr>');
- for($i=0; $i<$num_fields; $i++)
- {
- //Display values for each row and column
- print('<td align = center>'.$row[$i].'</td>');
- }
- print('</tr>');
- }
- }
- ?>
- <body>
- <h1><b>Add Item</b></h1>
- <form id="form1" name="form1" method="post" action="insertnewitem.php">
- <?php
- $host="localhost"; // Host name
- $username="thestory_carl"; // Mysql username
- $password="carl"; // Mysql password
- $db_name="thestory_mancstore"; // Database name
- $tbl_name="users"; // Table name
- $link = mysql_connect($host, $username, $password);
- mysql_select_db($db_name);
- $query = "SELECT customerid FROM customer";
- $result = mysql_query($query);
- print "Customer ID: <SELECT name=item>";
- while ($line = mysql_fetch_array($result))
- {
- foreach ($line as $value)
- {
- print "<OPTION value='$value'";
- }
- print ">$value</OPTION>";
- }
- mysql_close($link);
- print "</SELECT>";
- ?>
- Type: <input type="text" name="type" /><br>
- <table border="0" cellspacing="0" cellpadding="2">
- <tr>
- <td>Collection Date:</td>
- <td><?php
- $myCalendar = new tc_calendar("date5", true, false);
- $myCalendar->setIcon("calendar/images/iconCalendar.gif");
- $myCalendar->setPath("calendar/");
- $myCalendar->setYearInterval(2000, 2015);
- $myCalendar->dateAllow('2008-05-13', '2015-03-01');
- $myCalendar->setDateFormat('j F Y');
- $myCalendar->writeScript();
- ?>
- </td>
- </tr>
- </table>
- <table border="0" cellspacing="0" cellpadding="2">
- <tr>
- <td>Release Date:</td>
- <td><?php
- $myCalendar = new tc_calendar("date6", true, false);
- $myCalendar->setIcon("calendar/images/iconCalendar.gif");
- $myCalendar->setPath("calendar/");
- $myCalendar->setYearInterval(2000, 2015);
- $myCalendar->dateAllow('2008-05-13', '2015-03-01');
- $myCalendar->setDateFormat('j F Y');
- $myCalendar->writeScript();
- ?></td>
- </tr>
- </table>
- <p>
- <input type="submit" name="Submit" value="Submit" />
- </p> <br>
- <br>
- </form>
- <form action="snapshot.php" method="post">
- <input type="submit" value = "Back"/><br><br>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement