gravar sequencia PHP + mysql
Boa tarde nobres,
no meu sistema faço o upload de fotos com o uploadify, tudo funcionando ok
na minha mysql tenho os seguintes campos:
id - post_id - img - img_nome - pos - data
uso o codigo abaixo para fazer o up e gravar na tabela:
if (!empty($_FILES)) {
$postId = $_POST['postId'];
$img = $_FILES['Filedata']['name'];
$img_nome = $_FILES['Filedata']['name'];
$ext = substr($img, -4);
$img = $postId.'-'.md5(uniqid(time())).$ext;
$targetPath = $_SERVER['DOCUMENT_ROOT'].$_REQUEST['folder'].'/';
$m = date('m');
$y = date('Y');
if(!file_exists($targetPath.$y)){ mkdir($targetPath.$y,0755);}
if(!file_exists($targetPath.$y.'/'.$m)){ mkdir($targetPath.$y.'/'.$m,0755);}
$targetPath = $_SERVER['DOCUMENT_ROOT'].$_REQUEST['folder'].'/'.$y.'/'.$m.'/';
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetFile = str_replace('//','/',$targetPath).$img;
$imgCad = $y.'/'.$m.'/'.$img;
$timestamp = date('Y-m-d H:i:s');
$cadastra = mysql_query("INSERT INTO up_posts_gb(post_id, img_nome, img, data) VALUES('$postId', '$img_nome', '$imgCad', '$timestamp')");
}
eu precisava gravar no campo pos uma sequencia, 1,2,3....
ou seja, toda vez que eu fazer o upload para uma galeria, venha essa sequencia, sempre começando do 1
alguma luz?
Discussão (1)
Carregando comentários...