0

Okay, so I'm not sure why this is happening, but I have a table full of data and I got the edit link working for the top of the stack, but when I want to edit another entry, it keeps pulling in the info from the top ID. Is this because PHP/MySQL work with push and pop methods?


Here is my loop for the data output:

while($info = mysql_fetch_array( $data )) 
{ 
$id=$info['ID'];

Print "<tr>";
Print "<th>Time</th>";
Print "<th>Client</th>";
Print "<th>Number</th>";
Print "<th>Address</th>";
Print "<th>Issue</th>";
Print "<th>Notes</th>";
Print "<th>Status</th>";
Print "<th>Charge</th>";
Print "<th>Edit</th>";
Print "<th>Print</th>";
Print "<tr>";
Print "<th> " .$info['Time'] . "</th>";
Print "<th> ".$info['Client'] . " </th>"; 
Print "<th> " .$info['Number'] . "</th>";
Print "<th>" .$info['Address'] . "</th>";
Print "<th>" .$info['Issue'] . "</th>";
Print "<th>" . $info['Notes'] . "</th>";
Print "<th>" .$info['Status'] . "</th>";
Print "<th>$" .$info['Charge'] . "</th>";
Print '<th><a href="https://www.1fixcomputermedic.com/update.php?id=$id" target="_blank">Edit</a></th>';
Print '<th><a href="" target="_blank">Print</a></th>';
Print "</tr>";
}

Any ideas?

2
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by computerfox
0

checklogin.php

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db($db_name);
// username and password sent from form 
$Username=$_POST['Username']; 
$Password=$_POST['Password'];

// To protect MySQL injection (more detail about MySQL injection)
$Username = stripslashes($Username);
$Password = stripslashes($Password);
$Username = mysql_real_escape_string($Username);
$Password = mysql_real_escape_string($Password);

$sql="SELECT * FROM $tbl_name WHERE username='$Username' and password='$Password'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){{
// Register $myusername, $mypassword and redirect to file "login_success.php"
$_SESSION['Username'] = $Username;
$_SESSION['Password'] = $Password;


mysql_select_db(gancsosa_crystalworks);

echo "\n";

mysql_select_db("gancsosa_crystalworks") or die(mysql_error()); 
$data = mysql_query("SELECT* FROM inprogress")
or die(mysql_error()); 

//Put data into right tables
 
mysql_query("SELECT* FROM inprogress");
mysql_query("INSERT INTO complete SELECT* FROM inprogress WHERE Status='Y' ");
mysql_query("DELETE  FROM inprogress WHERE Status='Y' ");


mysql_query("SELECT* FROM complete");
mysql_query("INSERT INTO inprogress SELECT* FROM complete WHERE Status='N' ");
mysql_query("DELETE  FROM complete WHERE Status='N' ");

//Take out duplicates
mysql_query("DELETE FROM inprogress WHERE NUMBER='0' ");

Print "<br><br>";

Print "Inprogress<br><br>";

Print "<pre>      Time           Client      Number        Address                           Issue                       N S  C</pre><br>";

$data = mysql_query("SELECT* FROM inprogress") 
or die(mysql_error());

Print "<table border cellpadding=7>"; 

while($info = mysql_fetch_assoc( $data )) 
{ 
$id=$info['ID'];

Print "<th> " .$info['Time'] . "</th>";
Print "<th> ".$info['Client'] . " </th>"; 
Print "<th> " .$info['Number'] . "</th>";
Print "<th>" .$info['Address'] . "</th>";
Print "<th>" .$info['Issue'] . "</th>";
Print "<th>" . $info['Notes'] . "</th>";
Print "<th>" .$info['Status'] . "</th>";
Print "<th>$" .$info['Charge'] . "</th>";
Print '<th><a href="https://www.1fixcomputermedic.com/update.php?id=$id" target="_blank">Edit</a></th>';
Print '<th><a href="" target="_blank">Print</a></th>';
Print "</tr>";

$id++;
} 

Print "</table>"; 

Print "<br>";
Print "<br>";

$query="TRUNCATE TABLE inprogress";

if($Username=="adminabel"||$Username=="adminrich"){

Print '<input type="submit" name="reset" value="Reset">';

if(isset($_POST['reset'])){
mysql_query("TRUNCATE TABLE inprogress");
}
}

Print "<br><br><br>Complete<br><br>";
Print "<pre>      Time          Client  Number    Address                           Issue                       Notes          S  C</pre><br>";

$data = mysql_query("SELECT* FROM complete") 
or die(mysql_error()); 

Print "<table border cellpadding=6>"; 
while($info = mysql_fetch_assoc( $data )) 
{ 

$id=$info['ID'];


Print "<tr>";
Print "<th> " .$info['Time'] . "</th>";
Print "<th> ".$info['Client'] . " </th>"; 
Print "<th> " .$info['Number'] . "</th>";
Print "<th>" .$info['Address'] . "</th>";
Print "<th>" .$info['Issue'] . "</th>";
Print "<th>" . $info['Notes'] . "</th>";
Print "<th>" .$info['Status'] . "</th>";
Print "<th>$" .$info['Charge'] . "</th>";
if($Username=="adminabel"||$Username=="adminrich"){
Print '<th><a href="https://www.1fixcomputermedic.com/update.php?id=$id" target="_blank">Edit</a></th>';
}
Print "</tr>";

} 
Print "</table>"; 
}

Print "<br><br>";

$query2="TRUNCATE TABLE complete;";

if($Username=="adminabel"||$Username=="adminrich"){

Print '<input type="Submit"  name="reset2" value="Reset">';

if(isset($_POST['reset2'])){
mysql_query("TRUNCATE TABLE complete");
}

}

}
else {
Print "Wrong Username or Password\r\n";

Print "Please try again....<br><br>";
Print '<a href="https://www.1fixcomputermedic.com/login.php">CLICK</a>';

}

everything else works great, well cept for this and cookies. i've never really worked with cookies and this was working for a bit, but i'm not sure what happened.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.