danjesama

Members
  • Content count

    4
  • Joined

  • Last visited

Community Reputation

0 Neutral

About danjesama

  • Rank
    Newbie
  1. Hi Guys, I have a table that shows information and the status of that, being on or off. the on and off part is hard to notice and as it is the most valuable I was hoping to change it from simple text of on/off to a green/red circle. At the moment I am using a text input in a form for on/off. I have looked around and haven't found much related to this. I am having to replace the text input box with the radio button and if its clicked it will show green and if not it will show red. any suggestions on this? I will attach my code below: input form: <th>Repo Status: * <td><input type="text" name="status" value="<?php echo $status; ?>" /></td></tr> Displayed Table: echo '<td>' . $row['status'] .'</td>'; Thanks in advance
  2. Hi Guys, I have a form adds details to a table and one of them is owner email which takes in an email address. this in turn displays this email address on the form. What I am looking to do is for the form have the user just put in there username and the email address is automatically attached at the end(as all the details after@ in the email address will be the same). Then when the table is displaying the email address it just displays the username which when clicked still brings you to a new email to that email address. Images: so here it would be just username and @whatver.com is always on the form and here it just displays the username so dmurran instead of the whole email address. here is the code for the table: // display data in table echo "<table align='center' border='1' cellpadding='2' class='footable mdl-data-table mdl-js-data-table mdl-data-table--selectable mdl-shadow--4dp full-width'>"; echo "<tr> <th>ID</th> <th>Administration Console</th> <th>Product Version</th> <th>Platform</th> <th>Database</th> <th>Owner</th> <th>Status</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 '<th>' . $row['id'] . '</th>'; echo '<td><a href="'.$row['curl'].'">'.$row['curl'].'</a></td>'; echo '<td>' . $row['pversion'] . '</td>'; echo '<td>' . $row['platform'] . '</td>'; echo '<td>' . $row['dversion'] . '</td>'; echo '<td><a href="mailto:'.$row['email'].'">' . $row['email'].'</a></td>'; echo '<td>' . $row['status'] .'</td>'; echo '<td><a href="php/edit.php?id=' . $row['id'] . '">Edit</a></td>'; echo '<td><a onclick="javascript:confirmationDelete($(this));return false;" href="php/delete.php?id=' . $row['id'] . '"onclick="return confirm("Do you want to delete this?")">Delete</a></td>'; echo "</tr>"; } // close table> echo "</table>"; ?> and here is the form: <?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($curl, $pversion, $platform, $dversion, $email, $status, $error) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <link rel="stylesheet" type="text/css" href="../css/style.css"> <link href='../css/bootstrap.cs' rel='stylesheet'> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script src='../js/bootstrap.js'></script> <title>New Repo</title> </head> <body> <div id="page-wrap"> <center><a href="https://repo-project-danielmurran.c9users.io/view.php"><img src="../images/logo.png" alt="what image shows" height="90" width="300"></a></center> <h1>GCS Reproduction Environment</h1></br> <button type="button" onclick="window.location='https://repo-project-danielmurran.c9users.io/view.php'">Home</button> <hr/> <h2> Add Reproduction</h2> <?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 id="bform"> <table id="maintable" border='1' cellpadding='10'> <thead> <tr> <th>Repoduction Console URL: *<td><input type="text" name="curl" value="<?php echo $curl; ?>" /></td> </tr> <th>Product Version: *<td> <input type="text" name="pversion" value="<?php echo $pversion; ?>" /></td></tr> <th>Platform: * <td><input type="text" name="platform" value="<?php echo $platform; ?>" /></td></tr> <th>Database: * <td><input type="text" name="dversion" value="<?php echo $dversion; ?>" /></td></tr> <th>Owner Emaill: * <td><input type="email" name="email" value="<?php echo $email; ?>" /> </td></tr> <th>Repo Status: * <td><input type="text" name="status" value="<?php echo $status; ?>" /></td></tr> </table> * required <input type="submit" name="submit" value="Submit"> </div> </form> </div> </body> </html> <?php } // connect to the database include('../php/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 $curl = mysql_real_escape_string(htmlspecialchars($_POST['curl'])); $pversion = mysql_real_escape_string(htmlspecialchars($_POST['pversion'])); $platform = mysql_real_escape_string(htmlspecialchars($_POST['platform'])); $dversion = mysql_real_escape_string(htmlspecialchars($_POST['dversion'])); $email = mysql_real_escape_string(htmlspecialchars($_POST['email'])); $status = mysql_real_escape_string(htmlspecialchars($_POST['status'])); // check to make sure all fields are entered if ($curl == '' || $pversion == '' || $platform == '' || $dversion == '' || $email == '' || $status == '') { // generate error message $error = 'ERROR: Please fill in all required fields!'; // if either field is blank, display the form again renderForm($curl, $pversion, $platform, $dversion, $email, $status, $error); } else { // save the data to the database mysql_query("INSERT INTO players SET curl='$curl', pversion='$pversion', platform='$platform', dversion='$dversion', email='$email', status='$status'") 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('','','','','','',''); } ?> I tried to cut off the end of the email but it was not bringing me to the email address anymore. Any help is appreciated. Thanks!
  3. Hi guys, I have a table with a delete column with deletes individual rows from the column, I am looking to add a delete warning. Now I know you can add a javascript function but im unsure how to do this as my page is built in PHP. Here is the delete column: echo '<td data-sort-initial="Descending"><a href="delete.php?id=' . $row['id'] . '">Delete</a></td>'; Here is my delete.php file: <?php /* DELETE.PHP Deletes a specific entry from the 'players' table */ // connect to the database include('connect-db.php'); // check if the 'id' variable is set in URL, and check that it is valid if (isset($_GET['id']) && is_numeric($_GET['id'])) { // get id value $id = $_GET['id']; // delete the entry $result = mysql_query("DELETE FROM players WHERE id=$id") or die(mysql_error()); // redirect back to the view page header("Location: view.php"); } else // if id isn't set, or isn't valid, redirect back to view page { header("Location: view.php"); } ?> Thanks in advance