登录 | 注册 | FAQ
Anonymous

PHP and myphpadmin

+ 发表回复

1 篇帖子 分页: 1 / 1


PHP and myphpadmin

xosraw » 周日 6月 21, 2015 2:28 am

Hi,
I am kind of new to PHP and database and looked at the lessons that is provided on html.net where i would like to display user's information off the database and each user has a link that I can click and retrieve the individual's info.
It does not work for me:
- it displays bullets list, but empty info in front
- it only updates first name, last name and email not the other fields

here are the two php pages, is there something that I am missing?????

======================= lists users off the database===============
<html>
<head>
<title>Retrieve data from the database</title>
</head>
<body>



<?php
// Connect to database server
mysql_connect("localhost", "user", "my password") or die (mysql_error ());

// Select database
mysql_select_db("my database") or die(mysql_error());

// SQL query
$strSQL = "SELECT * FROM tbl_registration ORDER BY first_name DESC";

// Execute the query (the recordset $rs contains the result)
$rs = mysql_query($strSQL);

// Loop the recordset $rs
while($row = mysql_fetch_array($rs)) {

// Name of the person
$strName = $row['first_name'] . " " . $row['last_name'];

// Create a link to person.php with the id-value in the URL
$strLink = "<a href = 'individual-info.php?id = " . $row['registration_id'] . "'>" . $strNavn . "</a>";

// List link
echo "<li>" . $strLink . "</li>";

}

// Close the database connection
mysql_close();
?>


</body>
</html>
===========================
============here is the individual info php================
<html>
<head>
<title>Retrieve data from database</title>
</head>
<body>

<dl>

<?php
// Connect to database server
mysql_connect("localhost", "legacym2_prod", "B,I2m_zBc0HO") or die (mysql_error ());

// Select database
mysql_select_db("legacym2_legacy_math_prod") or die(mysql_error());

// Get data from the database depending on the value of the id in the URL
$strSQL = "SELECT * FROM tbl_legacy_math_registration WHERE registraton_id=" . $_GET["registration_id"];
$rs = mysql_query($strSQL);

// Loop the recordset $rs
while($row = mysql_fetch_array($rs)) {

// Write the data of the person
echo "<dt>Name:</dt><dd>" . $row["first_name"] . " " . $row["last_name"] . "</dd>";
echo "<dt>Phone:</dt><dd>" . $row["phone"] . "</dd>";
echo "<dt>E-Mail:</dt><dd>" . $row["email"] . "</dd>";

}

// Close the database connection
mysql_close();
?>

</dl>
<p><a href="users-list.php">Return to the list</a></p>

</body>

</html>
=====================================

Any help is greatly appreciated!

Xosraw
头像

xosraw

  • 帖子: 1
  • 注册: 周日 6月 21, 2015 2:19 am


+ 发表回复

分页: 1 / 1