Jump to content

mySQL , PHP, Update collums .... etc.


dotti

Recommended Posts

Hokie Dokie ..

I made a navigation script about a week ago, database driven.

 

Tablename : Navigation

Collums : Id | Name | link

 

And i then made a script that inserted data into the sql database via a form ... Which worked perfectly...

Untill i said to my self "If I where to delete an entry from the table, I would have gaps in my Id collum"

 

e.g.

 

Id | Name | link

----------------

0  |test1  |blah

2  |test3  |blah

5  |test6  |blah

6  |test7  |blah

7  |test8  |blah

 

So i need a script that does the following ....

 

Displays all the "name"'s of items in the table and there "id" Then the user can change the id by typing it into a text box in a form and clicking submit ... I have had terrible problems trying to do it myself ...

 

 

Thanks in advance.

Dotti.

 

Link to comment
https://forums.phpfreaks.com/topic/53321-mysql-php-update-collums-etc/
Share on other sites

I simply want a form  that allows me to update the collum "id" .... look at my code

<table border="0" width="15%" cellspacing="0" cellpadding="0">
<br>
<?php 
include ("config.php");
database_connect();
$query = "SELECT * from navigation
          WHERE status = 1
          ORDER by id;";
$error = mysql_error();
if (!$result = mysql_query($query)) {
    print "error";
exit;
}

while($itm = mysql_fetch_object($result)){
  $name = $itm->name;
  $link = $itm->link;
  $targ = $itm->target;
  if ($link=="---"){
  print("<tr>
         <td bgcolor=0066ff>
	 <img src=images/bullet1.bmp><strong> <u>$name</u></strong>
	 </td>
	 </tr>
        ");
        }else{

  print("<tr>
         <td bgcolor=00ccff>
	 <img src=images/bullet2.bmp> <a href=".$link." target=".$target."><strong>$name</strong></a>
	 </td>
	 </tr>
        ");
}
}
?>
</table>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.