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
Form submissing with PHP and JQuery/Ajax
I have searched everywhere, but cannot find a solution for this... I have worked all day trying to g
Sufficient protection from bad input?
I am writing a simple script to let people upload 'pages' of their own content, be it simply a few b
Need help with basic sql
Hi,
I am using oracle 10g, and having some small doubts related to sql , here goes the si
that old Malformed Headers problem again!!!!! HELP!!!!!!
I've read the http://www.phpfreaks.com/forums/index.php/topic,37442.0.html
I don't think my c
modifying query string with no page refresh
Hi everybody,
I've tried to get info about my problem all over the internet but i didn't find out
array_diff weirdness
I'm using the following bit of code
$diff = array_diff($pids, $pidlist);
$diff = array_va
php mailer
How can i send a mail to large no, say 50,000 reciepients using [color=#0000FF]php mailer[/color]
Simple Variable Question
Hi everyone.... again,
I am really getting into php still. Learning more every day. I love it
Filtering Tables
Hello Thanks for any help any one can give Im very new to PHP..
I need to pull data for clien
Query failed issue with php script but works fine in mssql manager!
hi i have the script below which copies data from one table to another but will only insert new data