User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 402,953 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,834 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting

a little help

Join Date: May 2008
Location: UK
Posts: 51
Reputation: xan is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 10
xan's Avatar
xan xan is offline Offline
Junior Poster in Training

Re: a little help

  #9  
May 8th, 2008
A couple of problems with your current code:

mysql_fetch_row returns a row in a numerical array, you would need to use $row[0], $row[1] for displaying the data, to use what you are, you will need to use mysql_fetch_assoc to call the cells by the column names.

There is a slight problem here:
if (mysql_num_rows($result) > 0) {

while($row=mysql_fetch_row($result)){

echo "ID : .$row['id'] <br/>";
echo "First Name : $row['fname'] <br/>";
echo "Last Name : $row['lname'] <br/>";
echo "Phone Number : $row['phone_num'] <br/>";
echo "Extension : $row['ext'] <br/>";
echo "Title : $row['title'] <br/>";
echo "Department : $row['dept'] <br/>";
echo "Fax Number : $row['fax'] <hr>";

// Add a link with a parameter(id) and it's value.
echo '<a href="phoneupdate1.php?id='.$row['id'].'">Update</a>';
}
else { 
    // no 
    // print status message 
    echo "No rows found!";
	} 
} 

You have put it as this:
If {
While {
End While }
Else {}
End If }

It should be:
if (mysql_num_rows($result) > 0) {
  while($row=mysql_fetch_row($result)){
    echo "ID : .$row['id'] <br/>";
    echo "First Name : $row['fname'] <br/>";
    echo "Last Name : $row['lname'] <br/>";
    echo "Phone Number : $row['phone_num'] <br/>";
    echo "Extension : $row['ext'] <br/>";
    echo "Title : $row['title'] <br/>";
    echo "Department : $row['dept'] <br/>";
    echo "Fax Number : $row['fax'] <hr>";
    // Add a link with a parameter(id) and it's value.
    echo '<a href="phoneupdate1.php?id='.$row['id'].'">Update</a>';
  }
} else { 
  // no 
  // print status message 
  echo "No rows found!";
} 

I'm afraid I cant see any other problems with the actual code, I suggest you also check the database and make sure that the column names are correct (they are case sensitive) and that there is actually data in the table you are using.
Reply With Quote  
All times are GMT -4. The time now is 6:34 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC