Jump to content
Killersites Forums

teke

Member
  • Posts

    7
  • Joined

  • Last visited

teke's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. hi, how can sort columns ascendenting ? anyone can help me?
  2. i returned... do you know something about countdown timer in table? any
  3. the time in days i need, anyway thanks !
  4. how can add in table a timeleft column and when the time is up ,automatically delete row if you can...
  5. hello, i try to add a new column, but i fail i add in a SQL file this CREATE TABLE `players` ( `id` int(11) NOT NULL auto_increment, `leader` varchar(32) NOT NULL, `firstname` varchar(32) NOT NULL, `lastname` varchar(32) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; in view.php like this <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>View Records</title> </head> <body> <?php /* VIEW.PHP Displays all data from 'players' table */ // connect to the database include('connect-db.php'); // get results from database $result = mysql_query("SELECT * FROM players") or die(mysql_error()); // display data in table //echo "<p><b>View All</b> | <a href='view-paginated.php?page=1'>View Paginated</a></p>"; echo "<table border='1' cellpadding='10'>"; echo "<tr> <th>ID</th> <th>Leader</th> <th>First Name</th> <th>Last Name</th> <th></th> <th></th></tr>"; // loop through results of database query, displaying them in the table while($row = mysql_fetch_array( $result )) { // echo out the contents of each row into a table echo "<tr>"; echo '<td>' . $row['id'] . '</td>'; echo '<td>' . $row['leader'] . '</td>'; echo '<td>' . $row['firstname'] . '</td>'; echo '<td>' . $row['lastname'] . '</td>'; echo '<td><a href="edit.php?id=' . $row['id'] . '">Edit</a></td>'; echo '<td><a href="delete.php?id=' . $row['id'] . '">Delete</a></td>'; echo "</tr>"; } // close table> echo "</table>"; ?> <p><a href="new.php">Add a new record</a></p> </body> </html> i remove view-paginated.php in new.php <?php /* NEW.PHP Allows user to create a new entry in the database */ // creates the new record form // since this form is used multiple times in this file, I have made it a function that is easily reusable function renderForm($leader, $first, $last, $error) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>New Record</title> </head> <body> <?php // if there are any errors, display them if ($error != '') { echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>'; } ?> <form action="" method="post"> <div> <strong>Leader: *</strong> <input type="text" name="leader" value="<?php echo $leader; ?>" /><br/> <strong>First Name: *</strong> <input type="text" name="firstname" value="<?php echo $first; ?>" /><br/> <strong>Last Name: *</strong> <input type="text" name="lastname" value="<?php echo $last; ?>" /><br/> <p>* required</p> <input type="submit" name="submit" value="Submit"> </div> </form> </body> </html> <?php } // connect to the database include('connect-db.php'); // check if the form has been submitted. If it has, start to process the form and save it to the database if (isset($_POST['submit'])) { // get form data, making sure it is valid $leader = mysql_real_escape_string(htmlspecialchars($_POST['leader'])); $firstname = mysql_real_escape_string(htmlspecialchars($_POST['firstname'])); $lastname = mysql_real_escape_string(htmlspecialchars($_POST['lastname'])); // check to make sure both fields are entered if ($leader == '' || $firstname == '' || $lastname == '') { // generate error message $error = 'ERROR: Please fill in all required fields!'; // if either field is blank, display the form again renderForm($leader, $firstname, $lastname, $error); } else { // save the data to the database mysql_query("INSERT players SET leader='$leader' firstname='$firstname', lastname='$lastname'") or die(mysql_error()); // once saved, redirect back to the view page header("Location: view.php"); } } else // if the form hasn't been submitted, display the form { renderForm('','',''); } ?> what is wrong ? please help me, Thanks ! sorry for my english ,i'm from Romania
×
×
  • Create New...