Jump to content

jpiercemaine

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jpiercemaine's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. OK, try this: untested // Grab the profile data from the database $query = "SELECT * FROM loaninfo WHERE user_id = '" . $_SESSION['user_id'] . "'"; $data = mysqli_query($dbc, $query); $loans = array(); if (mysqli_num_rows($data) <> 0) { // This section is to pull loan info from the database while ($row = mysqli_fetch_array($data)) { //Use the unique loan id as the arrays key $loans[$row['loanid']]=$row; } } // Delete selected loans from database if($_POST["delete"]){ $posted=$_POST["delete"]; //loop through delete button array (in your case 1) foreach($posted as $k=>$v) { if (isset($loans[$k])) { //if loanid exists in the loans array $query = "DELETE FROM loaninfo WHERE loan_id = " . $k . ";"; mysqli_query($dbc, $query); } } foreach($loans as $k=>$v) { echo "<table border=\"1\" align=\"left\">"; // Echo database values to table echo "<tr><td><input class='text' name='currency" . $k . "' id='currency" . $k . "' type='text' value='" . $loans[$k]['currency'] . "' /></td></tr>"; echo "<tr><td><input class='text' name='balance" . $k . "' id='balance" . $k . "' type='text' value='" . $loans[$k]['balance'] . "' /></td></tr>"; echo "<tr><td><input class='text' name='rate" . $k . "' id='rate" . $k . "' type='text' value='" . $loans[$k]['rate'] . "' /></td></tr>"; echo "<tr><td><input class='text' name='term" . $k . "' id='term" . $k . "' type='text' value='" . $loans[$k]['term'] . "' /></td></tr>"; echo "<tr><td><input class='text' name='period" . $k . "' id='period" . $k . "' type='text' value='" . $loans[$k]['period'] . "' /></td></tr>"; echo "<tr><td><input class='text' name='date" . $k . "' id='date" . $k . "' type='text' value='" . $loans[$k]['date'] . "' /></td></tr>"; echo "<tr><td align='center'><input class='text' type='submit' name='delete[" . $k . "]' value='Delete' /></td></tr>"; echo "</table>"; ) // End FOR loop
  2. I don't use the preview portion but I use Aptana Studio..... FREE and allows you to have multiple files open from multiple ftp connections (saving to correct server upon ctrl+s... bonus for me and reason i dropped dreamweaveer)
  3. Why can't you use the loan_id from the original select statement and use it as the key of the array? Maybe concat the name of the submit button with _$k. When form is posted split the name of the posted submit button?
×
×
  • 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.