Hi, I am trying to create code where new column will be added (step_status). If the column exist a new number would be added to the name (step_status1, step_status2 and so on). The code below does not work ... I get the message about the duplicating columns.
/ check if column step_status exist if does add 1 /
$sql="SELECT * FROM all_tickets";
$result=mysql_query($sql);
if ($row = mysql_fetch_array($result)) {
$bTrue = true;
$i=1;
while ($bTrue) {
if (!isset($row['step_status' . $i])) {
$bTrue = false;
$columname = 'step_status' . $i;
}else {
$i++;
}
}
$sql = "alter table all_tickets add column $columname enum ('0','1')";
}
Thanks for help.