Jump to content

Recommended Posts

Posted

Hi all

I have a database of some users, but serial number was missing in the output form.

Now I want to add the serial number, but have problem.

When I made the database, I made 4 test entries to check if it works or not, when that worked then I deleted those entries.

Now when I use:

  echo "" . $row['id'] . "";

It works properly, but it starts form 5 and so on. And I want it to start form 1.

I also want my database to be ordered by names.

$result = mysql_query("SELECT * FROM my_table ORDER BY id") 
or die(mysql_error());  

Any suggestion!

 

Thanks

Posted

I suggest you "DROP" the database and start with a new install.

The auto-increment primary key does not need to start at one. That is a human consideration.

The Database only needs a unique value. And to answer your next concern, the index key does not need to be consecutive. If you delete a key, the DB will know about it and handle the list properly.

Posted

Simply let the Database management system handle the 'keys'.

They do not need to be starting at '1' or they do not need to be consecutive.

The DBMS will handle them just fine with missing elements.

Posted (edited)

hi all

i did it, with another code

 

see the red code, i added :

 

<?php

// Make a MySQL Connection

 

// Get all the data from the "example" table

$result = mysql_query("SELECT * FROM schooldb ORDER BY regname")

or die(mysql_error());

 

echo "

 

echo "

S

Name

DoB

Domicile

Phone

Country

City

Position

Organization

Profession

Education

Email ";

 

 

$ctr = 1;

 

// keeps getting the next row until there are no more to get

while($row = mysql_fetch_array($result))

{

echo "

 

echo "

" . $ctr . "";

echo "

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

echo "

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

echo "

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

echo "

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

echo "

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

echo "

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

echo "

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

echo "

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

echo "

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

echo "

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

echo "

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

 

 

echo "

";

$ctr++;

}

echo "

";

?>

Edited by fazlionline

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...