Jump to content

extremeshannon

Members
  • Posts

    10
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

extremeshannon's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for the reply. I have been trying to figure out how to accomplish this with the least amount of code. If you could post an example that would be awesome. Thanks
  2. Hello everyone, I am trying to display my Columns from the top down. I want my Column names on the left and the data moving to the right. Column Record1 Redcord2 Record3 C1 Data Data Data C2 Data Data Data C3 Data Data Data C4 Data Data Data C5 Data Data Data This what I am using and it is traditional left to right output with each record below the next. if (!$result) { $message = 'ERROR:' . mysql_error(); return $message; } else { $i = 0; echo '<html><body><table><tr>'; while ($i < mysql_num_fields($result)) { $meta = mysql_fetch_field($result, $i); echo '<td>' . $meta->name . '</td>'; $i = $i + 1; } echo '</tr>'; $i = 0; while ($row = mysql_fetch_row($result)) { echo '<tr>'; $count = count($row); $y = 0; while ($y < $count) { $c_row = current($row); echo '<td>' . $c_row . '</td>'; next($row); $y = $y + 1; } echo '</tr>'; $i = $i + 1; } echo '</table></body></html>'; mysql_free_result($result); } mysql_close ($link); ?> Thanks for the help Shannon
  3. Thanks everyone turn on register_globals did the trick. This is on a Ubuntu desktop running LAMP. I am hoping the book moves forward with some better practices and stat using _get and _post.
  4. Thanks everyone for the feed back. I have decided not to continue with this book. I have found mistakes and things just not working. I have been wondering how the info was suppose to be passed between all the scripts. Any suggestions on a book for PHP/MSQL Thanks
  5. Thanks for the help. I am trying to follow the book as close as possible. and the book has shortcuts like <? I did change this to <?php and plan on using that in my code. I did change the quotes did not see that this time must have copied that to make sure I was typing correct. The page is URL encoding (I believe this is what it is doing) hiUser2.php?"userName"=Shannon but the page is not changing. I have tried this on my website I have running and on my localhost and get the same results. Thanks again
  6. This is a simple php program and it doesn't work the way it is suppose to. The page see's $username as empty. I have not been able to fix it. I am reading a book and following all the code but anything passing variables to another page or with in the page is not working for me. any help would be great. <html> <head> <title>Hi User</title> </head> <body> <h1>Hi User</h1> <? if (empty($userName)){ print <<<HERE <form> please enter you name: <input type = “text” name = “userName”> <br> <input type = "submit"> </form> HERE; }else{ print "<h3>Hi There, $userName !</h3>"; }//end ?> </body> </html>
  7. Ok I have been going through the tutorials and this is what I have come up with. I have has many syntax errors and plain old errors that I have worked through. I have put the code for one of my add pages here to get some feed back. It works with inputting 1 field only at this time. I have not had success getting multiple fields. I was hoping to get the page to print "Student add success!!!!!!!!!!!!" when the add is success. It prints out error but the add was completed. I would like some feed back so I know if I am on the right track. This is a basic page I am have not got into error checking, or string checking. Right now I want a table with input fields and a button to add a person to the database. When I get that working and understand it I plan on adding more to it. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>DaDz Add Skydiver</title> </head> <body> <h1>Far North Skydive Center in Alaska</h1> <h3>Add Student</h3> <?php if ( isset( $lName ) ) { // check user input here! $dberror = ""; $ret = add_to_database( $lName ); if ( ! $ret ) print "Error: $dberror<BR>"; else print "Student add success!!!!!!!!!!!!"; } else { Write_form(); } // Function add Last Name to Database function add_to_database($lName, $fname){ // database connection info $conn = mysql_connect("localhost", "dbuser", "dbpass") or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db('dbname',$conn) or trigger_error("SQL", E_USER_ERROR); if($_POST['lName']) { // little bit of cleaning... $lname = mysql_real_escape_string($_POST['lName']); // insert new name into table $sql = "INSERT INTO skydiver (skynum, lName) VALUES ('','$lName')"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); } // end if }// End Function function Write_form() { echo <<<TABLE <form action = '{$_SERVER['PHP_SELF']}' method = 'post'> <table border = '0'> <tr> <td>First Name</td> <td><input type="text" name="fName"></td> <td><input type="checkbox" name="chkId">Check ID</td </tr> <tr> <td>Last Name</td> <td><input type="text" name="lName"></td> <td><input type="checkbox" name="chkWaiverVideo">Waiver Video Complete</td> </tr> <tr> <td></td> <td align = 'center'><input type = 'submit' value = 'ADD'></td> <td></td> </tr> </table> </form> TABLE; }// end Write_form function ?> </body> </html>
  8. Thank you for the response. I will go through the tutorials and start coding.
  9. Hello everyone, I am a hobbyist with programming. I have been playing with Php, sql, html for several years. I am building a program to organize my club. I am starting out fairly simple and hope in a year for it to be powerful. If anyone can point in the right direction to find out how I can do several things I can get my first version done this week maybe. Here are the things I am trying to accomplish. 1.) a page that I can view records with a First record, previous Record, next Record, last record buttons. The page will pull the information from a table or tables out of my mysql database. I would like to have an update button so I can update records as I go through them and to be able to search buy typing in first name or last name. I know there are functions that will help me and I have been trying to figure out what classes on php.net 2.) Last question for now. All my pages that deal with mysql I have included all the connection information. I was thinking about making a class and add using a class on the pages to open the connection. Not sure if this would be easy, or the best way. Thanks in advance. I am new and I am not looking for the exact code just place to start. I really want to learn php and sql to be able to build my own applications and fix them.
×
×
  • 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.