Jump to content

BrianM

Members
  • Posts

    217
  • Joined

  • Last visited

    Never

Everything posted by BrianM

  1. So if I want a variable to equal a post value I do <?php $var = $_POST['some_name']; ?> ?
  2. Which in turn are the same, except 0 requires a function to properly operate?
  3. 0 (zero) and "" (empty field) are both the same thing, so you can use either??
  4. How do I prevent a script from running and inserting values from text fields into a database based upon whether or not all fields are complete? Because when I do it, it gives an error like it should if all fields aren't filled in, but it still inserts the values into the database for the fields that contained content. Would I do something like... <?php if (isset($_POST['some_name'])) { if (empty($_POST['some_name'])) echo 'You have to fill in all fields to complete installation!'; } else { ... ?> Is it the else part that keeps it from running unless all the fields are filled in??
  5. Is there an alternate method to setting blank spaces in between table cells other than having to use over and over, like so <td><b>Site name: </b></td> EDIT: Better yet, is there a PHP function used to repeat a single HTML code like that multiple times? Maybe something like, some_function(string, x) where x represents how many times to repeat the string. EDIT: Guess I didn't look hard enough, did a Google search where I found it not even 10 seconds later... str_repeat(string,repeat)
  6. I'm surprised, it actually works! Thanks for the suggestion.
  7. I just figured out how to increase/decrease the text box size, but am still curious as to whether it is possible to change the default text-type in a text box.
  8. How can I increase and decrease the default size of a text box to make it visually longer/shorter? <input type="text" /> And another thing, is there a way to set a default text-type for the text that appears inside of a text box?
  9. OOOOOO I did that when I wrote my user registration script to insert the values into the database. Makes a whole lot more sense now, thanks!
  10. So use a variable to store both queries and then do mysql_query($var); ??
  11. Well I got all of that working just fine, now for one last problem, and my website is done! I'm trying to insert to values into a row under two fields, ProjectNumber and Date. The first field, ProjectNumber, is inserting just fine, as well as Date, but instead of inserting the current date on the same row, which is what I want it to do, it creates and inserts the date on a new row... here is my code, I really would appreciate any help with this, like I said, after I finish this piece here, I'm complete done with my first web site! <?php mysql_select_db("reports") or die(mysql_error()); $insert_three = "CREATE TABLE `".$_POST['projectnumber']."` ( ID mediumint(9) not null auto_increment, PRIMARY KEY(ID), ProjectNumber mediumtext not null, Date mediumtext not null, Report mediumtext not null )"; mysql_query($insert_three, $mysql_connect) or die(mysql_error()); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (ProjectNumber) VALUES ('".$_POST['projectnumber']."')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (Date) VALUES ('".date("m-d-y")."')"); ?> <?php mysql_query("INSERT INTO `".$_POST['projectnumber']."` (ProjectNumber) VALUES ('".$_POST['projectnumber']."')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (Date) VALUES ('".date("m-d-y")."')"); ?> Like I said, the second query, the date, wont insert on the same row, it creates a second row and inserts the date there. :\ Anyone know how to fix this, I even tried closing the connection to the database and reopening, but that didn't work.
  12. So my best bet is to store each table inside of a table?
  13. Heres what I have -- <?php echo "<table border='1' cellpadding='0' cellspacing='0'> <tr> <th> Report Date </th> <th> Report Preview </th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td><center><a href='view/index.php?table=" . $row['date'] . "'>" . $row['date'] . "</a></center></td>"; echo "<td><center>" . $row['report'] . "</center></td>"; echo "</tr>"; } echo "</table>"; ?> And when I add in $result = mysql_query("SHOW TABLES FROM reports"); I get these errors: Notice: Undefined index: date in C:\Program Files\Apache Group\Apache2\htdocs\mps\view_rdata.php on line 92 Notice: Undefined index: date in C:\Program Files\Apache Group\Apache2\htdocs\mps\view_rdata.php on line 92 Notice: Undefined index: report in C:\Program Files\Apache Group\Apache2\htdocs\mps\view_rdata.php on line 93
  14. Is there a command to pull up all the tables listed in one database, maybe that would help me. And I will write something similar to what you suggested and give it a try.
  15. This would and will be extremely useful. But, every time a new clients information is submitted to the database a new table is created, so how would I inform/update the page that displays the tables to show the new entry without having to edit the code? Your code would be a great help though if I could figure this out.
  16. Also, while I take screen shots and write up another more informative paragraph, can anyone help me out with this... if it makes any since at all. How do I use a PHP/MySQL command to say: SELECT * FROM `all tables in a selected database here, instead of just one table` is there any way to select multiple tables from one database like that. That may be one solution to my problem, possibly.
  17. Would you like an image/screen shot of the page to show as an example of what I'm trying to accomplish, would that help any?
  18. Alright, well here is the code for my first table -- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>MPS - View Client Data</title> </head> <?php $mysql_hostname = "localhost"; $mysql_username = "brian"; $mysql_password = ""; $mysql_database = "mps"; $mysql_connect = mysql_connect("$mysql_hostname", "$mysql_username", "$mysql_password") or die(mysql_error()); mysql_select_db("$mysql_database") or die(mysql_error()); if (isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $password = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM mps_login WHERE username = '$username'") or die(mysql_error()); while($info = mysql_fetch_array($check)) { if ($password != $info['password']) { header("location: http://www.game-zero.org/mps/index.php"); } { ?> <body> <p>Menu</p> <br /> <a href="http://www.game-zero.org/mps/home.php">Home</a> | <a href="http://www.game-zero.org/mps/index.php">Login</a> | <a href="http://www.game-zero.org/mps/register.php">Register</a> | <a href="http://www.game-zero.org/mps/logout.php">Logout</a> <br /><br /> <p>View Client Data</p> <br /> <a href="http://www.game-zero.org/mps/create_cdata.php">Create Client Data</a> | <a href="http://www.game-zero.org/mps/view_cdata.php">View Client Data</a> | <a href="http://www.game-zero.org/mps/view_rdata.php">View Report Data</a> <br /><br /> <?php mysql_select_db("$mysql_database") or die(mysql_error()); mysql_query("ALTER TABLE mps_cdata ORDER BY projectnumber"); $result = mysql_query("SELECT * FROM mps_cdata"); echo "<form action='http://www.game-zero.org/mps/search_projects.php' method='post'> <table border='0'> <tr><td>Search Projects:</td><td> <input type='text' name='search' maxlength='60'> <input type='submit' name='search_projects' value='Search'> </td></tr> </table> </form> <br />"; echo "<table border='1' cellpadding='0' cellspacing='0'> <tr> <th> Project Number </th> <th> Project Name </th> <th> Client Name </th> <th> Client Address </th> <th> Client Office Phone </th> <th> Client Fax </th> <th> Client Cell </th> <th> Client Email </th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td><center><a href='view/index.php?table=" . $row['projectnumber'] . "'>" . $row['projectnumber'] . "</a></center></td>"; echo "<td><center>" . $row['projectname'] . "</center></td>"; echo "<td><center>" . $row['clientname'] . "</center></td>"; echo "<td><center>" . $row['clientaddress'] . "</center></td>"; echo "<td><center>" . $row['clientofficephone'] . "</center></td>"; echo "<td><center>" . $row['clientfax'] . "</center></td>"; echo "<td><center>" . $row['clientcell'] . "</center></td>"; echo "<td><center>" . $row['clientemail'] . "</center></td>"; echo "</tr>"; } echo "</table>"; mysql_close($mysql_connect); ?> </body> </html> <?php } } } else { header("location: http://www.game-zero.org/mps/index.php"); } ?> That displays each row from a table inside a database in the one table of a page that I want just fine. How am I suppose to display something similar to that, where it displays multiple rows from a database inside an HTML table on a page, but instead of each row displaying on the page coming from inside a new row from one table, it needs to select a new row from a new table that is created each time new information is submitted.
  19. Thanks you very much for you help, suggestions and assistance. Problem solved!
  20. How do I enter the current date in this format -- mm-dd-yy -- in this query? mysql_query("INSERT INTO `".$_POST['projectnumber']."` (Date) VALUES ('".echo date(m-d-y)."')"); That is what I have right now, and is not working :|
  21. That's weird, it works now, but does the "or die(mysql_error());" really make that big a difference. I thought it was only used if I wanted to see why something doesn't work or debug purposes. Educate me, please.
  22. To start things off, here is the code -- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>MPS - Send Client Data</title> </head> <?php $mysql_hostname = "localhost"; $mysql_username = "brian"; $mysql_password = ""; $mysql_database = "mps"; $mysql_connect = mysql_connect("$mysql_hostname", "$mysql_username", "$mysql_password") or die(mysql_error()); mysql_select_db("$mysql_database") or die(mysql_error()); $insert_one = "INSERT INTO mps_cdata (projectnumber, projectname, clientname, clientaddress, clientofficephone, clientfax, clientcell, clientemail) VALUES ('".$_POST['projectnumber']."','".$_POST['projectname']."','".$_POST['clientname']."','".$_POST['clientaddress']."','".$_POST['clientofficephone']."','".$_POST['clientfax']."','".$_POST['clientcell']."','".$_POST['clientemail']."')"; if (!mysql_query($insert_one, $mysql_connect)) { die(mysql_error()); } mysql_select_db("$mysql_database") or die(mysql_error()); $insert_two = "CREATE TABLE `".$_POST['projectnumber']."` ( ID tinyint not null auto_increment, PermitProcess varchar(40) not null, Required char(3) not null default 'N/A', SubmittalDate varchar(10) not null default '00-00-0000', CommentsReceivedDate1 varchar(10) not null default '00-00-0000', ResubmitDate1 varchar(10) not null default '00-00-0000', CommentsReceivedDate2 varchar(10) not null default '00-00-0000', ResubmitDate2 varchar(10) not null default '00-00-0000', CommentsReceivedDate3 varchar(10) not null default '00-00-0000', ResubmitDate3 varchar(10) not null default '00-00-0000', CommentsReceivedDate4 varchar(10) not null default '00-00-0000', ResubmitDate4 varchar(10) not null default '00-00-0000', ApprovalDate varchar(10) not null default '00-00-0000', PermitNumber varchar(10) not null default 'N/A', CoCReqDate varchar(10) not null default '00-00-0000', CoCSubmittalDate varchar(10) not null default '00-00-0000', primary key (ID) )"; mysql_query($insert_two, $mysql_connect); mysql_select_db("$mysql_database") or die(mysql_error()); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (PermitProcess) VALUES ('COUNTY PRE-APP MEETING')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (PermitProcess) VALUES ('FDOT PRE-APP MEETING')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (PermitProcess) VALUES ('ERP PRE-APP MEETING')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (PermitProcess) VALUES ('COUNTY PRELIMINARY PLAT APPROVAL')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (PermitProcess) VALUES ('REZONING APPROVAL (BY OTHERS)')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (PermitProcess) VALUES ('COUNTY CONSTRUCTION PLAN APPROVAL')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (PermitProcess) VALUES ('FDOT DRIVEWAY CONNECTION PERMIT')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (PermitProcess) VALUES ('FDOT DRAINAGE CONNECTION PERMIT')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (PermitProcess) VALUES ('FDOT UTILITY PERMIT')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (PermitProcess) VALUES ('NOTICE TO R/W USERS')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (PermitProcess) VALUES ('FDEP/ECUA SANITARY SEWER PERMIT')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (PermitProcess) VALUES ('FDEP/ECUA POTABLE WATER PERMIT')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (PermitProcess) VALUES ('SEPERATE UTILITY APPROVAL')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (PermitProcess) VALUES ('FDEP/ERP STORMWATER PERMIT')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (PermitProcess) VALUES ('FDEP DREDGE & FILL PERMIT')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (PermitProcess) VALUES ('COE DREDGE & FILL PERMIT')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (PermitProcess) VALUES ('NPDES PERMIT')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (PermitProcess) VALUES ('ADEM PERMIT')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (PermitProcess) VALUES ('FINAL PLAT')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (PermitProcess) VALUES ('FDEP/ERP CERTIFICATION OF COMPLETION')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (PermitProcess) VALUES ('ERP REQUEST FOR CONVERSION TO OP. PERMIT')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (PermitProcess) VALUES ('NPDES NOTICE OF TERMINATION')"); mysql_query("INSERT INTO `".$_POST['projectnumber']."` (PermitProcess) VALUES ('ADEM NOTICE OF TERMINATION')"); // change database for new report mysql_select_db("reports") or die(mysql_error()); $insert_three = "CREATE TABLE `".$_POST['projectnumber']."` ( ID mediumint(9) not null auto_increment )"; mysql_query($insert_three, $mysql_connect); ?> Your entry has been added to the database. Return <a href="http://www.game-zero.org/mps/home.php">home</a> or <a href="http://www.game-zero.org/mps/view_cdata.php">view client data</a>. <body> </body> </html> The part which isn't working for me is where I added in the comment // change database for new report This little snippet wont work... // change database for new report mysql_select_db("reports") or die(mysql_error()); $insert_three = "CREATE TABLE `".$_POST['projectnumber']."` ( ID mediumint(9) not null auto_increment )"; mysql_query($insert_three, $mysql_connect); But everything above it works just fine. Anyone see anything wrong with the code, what do I need to fix? =/
  23. Here that is -- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>MPS - Create Report</title> </head> <?php mysql_connect('localhost', 'brian', '*') or die(mysql_error()); mysql_select_db('mps') or die(mysql_error()); if (isset($_POST['report_submit'])) { $sql = "INSERT INTO mps_reports (date, report) VALUES ('".$_POST['report_date']."', '".$_POST['report_text']."')"; $insert = mysql_query($sql); } ?> <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="text" name="report_date" value="<?php echo date("F j, Y"); ?>" /> <br /> <textarea name="report_text" cols="50" rows="8"></textarea> <br /> <input type="submit" name="report_submit" value="Send" /> </form> </body> </html> Would it also help to do something like, varchar(10000) - on the report field - since it allows letters, numbers and special characters? Of course replacing 10000 with something a little more suitable for what I need, being higher or lower.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.