first id from db not showing


Posted on 16th Feb 2014 07:03 pm by admin

I have a php script which displays the content of a mysql table as a html table with sorting, delete/update button, etc. the problem is I can't make it show the first value inserted in the db, it only shows from the second id onwards, example:

instead of :

ID Surname Name
1 Test John
2 Test Anna

it shows:

ID Surname Name
2 Test Anna
3 Test Jorge

omitting the first id in the db

"index.php"
Code: <?php
include("connect.php");

$result = mysql_query("SELECT * FROM contact");
$id = mysql_result($result,$i,"id");

echo "<table border='1' class='rowstyle-alternate'>
<tr>
<th> </th>
<th> </th>
<th class='sortable-numeric'>ID</th>
<th class='sortable-text'>Surname</th>
<th class='sortable-text'>Name</th>
<th class='sortable-numeric'>Phone1</th>
<th class='sortable-numeric'>Phone2</th>
<th class='sortable-text'>Location</th>
</tr>";

while ($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>" . "<a href="delete.php?id=$id">Delete</a>" . "</td>";
echo "<td>" . "<a href="update.php?id=$id">Update</a>" . "</td>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['surname'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['phone1'] . "</td>";
echo "<td>" . $row['phone2'] . "</td>";
echo "<td>" . $row['location'] . "</td>";
echo "</tr>";
}
echo "</table>";

mysql_close();
?>

"delete.php"

Code: <?php
$id = $_GET['id'];
?>
<html>
<head>
<title>Do you want to delete this?</title>
</head>
<body>
<div align="center">
<h2>Do you want to delete this?</h2>
<h2><a href="deleted.php?id=<?php echo "$id" ?>">Yes</a> - <a href="index.php">No</a></h2>
</div>
</body>
</html>

No comments posted yet

Your Answer:

Login to answer
154 Like 45 Dislike
Previous forums Next forums
Other forums

Error when call dll from oracle
Hi all, please help me!

I have dll write C language, I want call it from oracle procedur

Word filter problem
Hello,

im trying to make a filter for words inputted in to my website but i want to store the

C - Reading a file into a byte array
Hi,

I'm trying to read a file into a byte array in C. I have to use C as this is for a loadru

admin with my register system?
Hey i wana make it so i can make a admin level on my register system , I'm kinda new to php to im no

Multi image upload
I have a gallery to build and want to build a dynamic upload form to allow for $var number of fields

turning an array into a string then poping it into a db
Hi im just wondering how you get a requested array into a single string then pop it into the db so f

Using loop to count number of entries
I'm writing a program that must ask user to type in numbers. After each entry, the program has to re

Text file to .Dat file Conversion in PHP
Hi All,
Could anybody provide code for Text file to .Dat file Conversion in PHP.

Tha

phpmailer class & pop.gmail.com?
Code: <?php
$mail->IsSMTP();
$mail->Host = "pop.gmail.com";

I think i'm using the syntax incorrectly
Hi Everyone!

I'm new to this forum and a newbie with PHP - I'm glad I found this site - I hop

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash