I want to add new rows to my table each time I enter information to my table. But first, I automatically have to open new columns.
$Connection=mysqli_connect('localhost','root','','database');
$Query="ALTER TABLE `koli_stok_hareketleri`
ADD `uretilen_koli` INT(11) NOT NULL AFTER `koli_adet`,
ADD `tarih` VARCHAR(100) NOT NULL AFTER `uretilen_koli`;";
$Execute=mysqli_query($Connection,$Query)
or die("Bad Query: $Query");
if($Execute){
$_SESSION["SuccessMessage"]= " Works";
} else {
$_SESSION["ErrorMessage"]= "Doesnt Work";
}
What I need to do is: checking last inserted column here: 'tarih' and then make two new columns as 'uretilen_koli1' and 'tarih1' then go on with the same system as user adds new information like 'uretilen_koli2' and 'tarih2'
What is the way of producing new columns regarding to the last column number/value automatically ?
$Connection=mysqli_connect('localhost','root','','database');
$ViewQuery="SHOW COLUMNS FROM koli_stok_hareketleri";
$result=mysqli_query($Connection,$ViewQuery);
while($ColumnNames=mysqli_fetch_array($result)){
$LastColumnName = $ColumnNames['Field'];
$_SESSION["ErrorMessage"]= "$LastColumnName";
}
I can get the last column with this way but now I need to loop it.