0

I want to generate the deptno automatically.
Im using backend as mysql which allows auto-incrementation only for an integer,
not supports for varchar. So any code to do it?
Thank you.
Code blocks are created by indenting at least 4 spaces
... and can span multiple lines

<?php

$con = mysql_connect('localhost','root', ''); if (!$con) { die('Could not connect: ' . mysql_error()); }

mysql_select_db("stu", $con); $result = mysql_query("SELECT * FROM student"); while($row = mysql_fetch_array($result)) { echo $row['deptno'] . " " .$row['sname']

. " " .$row['age'];

echo "
";

}mysql_close($con); ?>

Code blocks are created by indenting at least 4 spaces
... and can span multiple lines
2
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by diafol
0

Why are you including this random piece of SQL on student? The deptno will be created in the depts table?

What exactly are you asking? How to perform an INSERT query?

0

how can i have an auto increment of department number which start with 10pit01, so on..

0

how can i have an auto increment of department number which start with 10pit01, so on..

0

how can i have an auto increment of department number which start with 10pit01, so on..

0

Why do you need to do this? Why not just have an autoincrement (integer)? If you really have to have this prefix (10pit[0]) you can attach it via SQL or php. Are you actually going to display this code? If not, I fail to see the need to use it.

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.