Have code here for displaying data but ... need help ...
Posted: Sun Sep 08, 2002 9:34 pm
This bit of code displays member names in a <li> list </ul>, and when you click on a member name in the list, it shows you the data (name, address, city, state, zip) from a Mysql database at the bottom of the same list page; in other words, on the same page. Click on any name, you get the data info at the bottom of the same page, etc. I need it to display the data on another page or window instead of at the bottom of the <li> list page. Can anyone help me correct this code so it will do that?
Much appreciate any help. Thanks,
Al
- - -
<?php
function list_member()
{
$db_name = "database";
$table_name = "Table";
$connect = @mysql_connect("localhost", "database", "password");
if( !$connect )
{
echo "Couldn't connect to database";
exit;
}
$db = @mysql_select_db($db_name, $connect);
if( !$db )
{
echo "Couldn't select database";
exit;
}
$sql = "SELECT id, Name FROM $table_name";
$result = @mysql_query($sql,$connect);
while ($row = mysql_fetch_assoc($result))
{
$id = $row['id'];
$Name = $row['Name'];
echo "<li><a href=\"$PHP_SELF?action=showmember&id=$id\">$Name</a>";
}
echo "</ul>";
mysql_close( $connect );
}
function member_details ( $id )
{
$db_name = "database";
$table_name = "table";
$connect = @mysql_connect("localhost", "database", "password");
if( !$connect )
{
echo "Couldn't connect to database";
exit;
}
$db = @mysql_select_db($db_name, $connect);
if( !$db )
{
echo "Couldn't select database";
exit;
}
$sql = "SELECT * FROM $table_name WHERE id='$id'";
$result = @mysql_query($sql,$connect);
while ($row = mysql_fetch_assoc($result))
{
$Name = $row['Name'];
$Address = $row['Address'];
$City = $row['City'];
$State = $row['State'];
$Zip = $row['Zip'];
}
echo"
<h3>$Name</h3>
<strong>Address: </strong>$Address <br>
<strong>City: </strong>$City<br>
<strong>State: </strong>$State<br>
<strong>Zip: </strong>$Zip<br>
mysql_free_result($result);
mysql_close ($connect);
}
?>
<html>
<head>
<title>Members List</title>
</head>
<?php
list_member();
switch( $action )
{
case "showmember":
member_details( $id );
break;
default:
echo "Some instructions here";
break;
}
?>
<h4><strong><br> Choose another member<br></strong></a></h4>
<br>
</body>
</html>
Much appreciate any help. Thanks,
Al
- - -
<?php
function list_member()
{
$db_name = "database";
$table_name = "Table";
$connect = @mysql_connect("localhost", "database", "password");
if( !$connect )
{
echo "Couldn't connect to database";
exit;
}
$db = @mysql_select_db($db_name, $connect);
if( !$db )
{
echo "Couldn't select database";
exit;
}
$sql = "SELECT id, Name FROM $table_name";
$result = @mysql_query($sql,$connect);
while ($row = mysql_fetch_assoc($result))
{
$id = $row['id'];
$Name = $row['Name'];
echo "<li><a href=\"$PHP_SELF?action=showmember&id=$id\">$Name</a>";
}
echo "</ul>";
mysql_close( $connect );
}
function member_details ( $id )
{
$db_name = "database";
$table_name = "table";
$connect = @mysql_connect("localhost", "database", "password");
if( !$connect )
{
echo "Couldn't connect to database";
exit;
}
$db = @mysql_select_db($db_name, $connect);
if( !$db )
{
echo "Couldn't select database";
exit;
}
$sql = "SELECT * FROM $table_name WHERE id='$id'";
$result = @mysql_query($sql,$connect);
while ($row = mysql_fetch_assoc($result))
{
$Name = $row['Name'];
$Address = $row['Address'];
$City = $row['City'];
$State = $row['State'];
$Zip = $row['Zip'];
}
echo"
<h3>$Name</h3>
<strong>Address: </strong>$Address <br>
<strong>City: </strong>$City<br>
<strong>State: </strong>$State<br>
<strong>Zip: </strong>$Zip<br>
mysql_free_result($result);
mysql_close ($connect);
}
?>
<html>
<head>
<title>Members List</title>
</head>
<?php
list_member();
switch( $action )
{
case "showmember":
member_details( $id );
break;
default:
echo "Some instructions here";
break;
}
?>
<h4><strong><br> Choose another member<br></strong></a></h4>
<br>
</body>
</html>