我需要帮助来添加变量值和数值
并且数值是从mysql数据库列获取的?
问题
当我将 std0001
插入 db 列时,函数将无法工作并移至 std0002
否则,如果 db 列中只有数字值,则函数将工作并且移至0002,003.0003
?
代码
$query = "SELECT snum val FROM students";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
$new_val = $row['val']+1;
$a='std';
for($i=0; $i <=$new_val; $i++) {
if($new_val == 0) {
$say=$a.'0'.$i;
} else if($new_val == 1) {
$say=$a.'00'.$i;
}
else
{
$say=$a.'000'.$i;
}
}
例如我想要喜欢
Std00001
Std00002
Std00003
.
.
.
.
.
.
.
So On...
最佳答案
在您的 JavaScript 中尝试此代码
var a = "00001";
/*store the value "00001" in a variable as you are getting it from a column*/
var b = "std";
var c = parseInt(a) + 1;
alert(b + c);
关于php - 如何使用 mysql 数据库列数值添加变量值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19466321/