Jump to content

Recommended Posts

I am trying to display the name and email address from MySQL, in a form so it can be changed.  It pretty much works, but I only get the email address.  Here is the code:

 

<?php

 

$sql = "select * from subscribers";

 

$result = mysql_query($sql);

$num_rows=mysql_num_rows($result);

echo "<div align=right class=FormTitle>Total No. of Customers : " . $num_rows."</div>";

$sno = 0;

$noofrecord = mysql_num_rows($result);

if ($start == "" && $end == "")

{

$start = 1;

$end = 20;

}

 

while($row=mysql_fetch_array($result))

{

if ($id == $end)

{

break;

}

   

$id++;

 

    $id = $row["id"];

    $email = $row["email"];

$name = $row["name"];

 

 

 

echo "<tr class=TableFields><td>$email<td>$name</td>";

echo "<td class=LinkText align=center><a href=newsmailerlist.php?action=2&email=$email>Edit</a></td>";

echo "<td class=LinkText align=center><a href=newsmailerlist.php?action=3&email=$email>Delete</a></td>";

 

}

 

?>

 

Could someone tell me what I have wrong i this code, so that I can get the name as well.

 

Thank you

LadyDee

Link to comment
https://forums.phpfreaks.com/topic/146964-having-aproblem-with-code/
Share on other sites

Are you sure the name of the column is "name" and not "Name" or something else?

 

while($row=mysql_fetch_array($result))
   {
   if ($id == $end)
   {
break;
   }
     
    $id++;
   
   echo '<pre>';
   print_r($row);
   echo '</pre>';
    /*$id = $row["id"];
    $email = $row["email"];
   $name = $row["name"];
   
   

echo "<tr class=TableFields><td>$email<td>$name</td>";
echo "<td class=LinkText align=center><a href=newsmailerlist.php?action=2&email=$email>Edit</a></td>";
echo "<td class=LinkText align=center><a href=newsmailerlist.php?action=3&email=$email>Delete</a></td>";*/

}

 

The code above will show you what the proper array keys are.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.