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
45
Other forums
type check while uploading
Hi Everyone,
How can I check the exact type of a file while uploading on my site?
Here
LIMIT $start, 10... how to pass last value queried into next page with GET??
Ok I know how to display the first or last 10 results of a query...
$result = mysql_query(&q
There was a problem with the request. (Code: 0)
Any Idea what could cause this? I get it randomly at best. But with both IE and FF. It derives from
Sessions work for me and not others?
I'm having a bit of bad luck with sessions. In the past they have worked fine for me, but this time
How to sum these output values
Hi
I need sum the month totals
SELECT region_name, area_name
,SUM (CASE WHEN S
The repetition structure: the while statement not working
New programming student, have assignment as follows:
A restaurant has 4 lunch combos for custom
code help - pagination
Hi all, I have this code, basically a user logs into my site and they get this page.
The pro
Data Function is Its Not working IN IE8
This is my first time to use formums. I hope i can get solution for this problem.
view plaincopy to
Curly Bracket Delimeters.
I'd always believed that the starting and ending delimeters in preg_ functions had to be the same ch
MYSQL INSERT ID NOT WORKING
Code: $id = mysql_insert_id();
header("Location: ./?view=$id");
Why $id pulling blan