Hi! I am currently working on my thesis and I don't have any idea on how can I view the records stored in 3 mysql tables. Can someone please give me some code regarding on this. The records should be displayed in a table form then when you click a name, it will be linked on a page that will display all records of that name. I think this has to do something with the "SELECT * FROM <table_name>" command. Any help will be appreciated. Help me please. Thank you!

Recommended Answers

All 6 Replies

Member Avatar for diafol

I would advise you to learn SQL (MySQL) by checking out some basic tutorials. That is one part of the issue. So do you have any idea at all? This is your thesis. What have you been taught on this course if you can't make simple calls to a DB?

Would writing a script for you invalidate your thesis as it would be plagiarism / cheating? In addition, how much are you prepared to pay for a custom script?

You provide absolutely no details of your tables, requirements etc. What is your current understanding of SQL and PHP?

Please read the house rules and the sticky in the php forum which has some great advice: sticky

I'm sorry but so far this is my code and I am not getting any results, I am trying to connect to my database named purchase

<html>
<head>
    <title><?php echo $firname: ?> <?php $famname: ?>s Profile</title>
</head>
<body>
<?php
    if (isset($_GET['username'])){
        $username = $_GET['username'];
        mysql_connect("localhost", "root", "root") or die ("Could not connect to the server");
        mysql_select_db("purchase") or die ("That database could not be found!");
        $userquery = mysql_query("SELECT * FROM purchase WHERE username='$username'") or die ("The query could not be completed.");

        while($row = mysql_fetch_array($userquery, MYSQL_ASSOC)){
            $dbusername = $row['username'];
            $firname = $row['firname'];
            $midname = $row['midname'];
        }

?>
<h2><?php echo $firname: ?><?php echo $midname: ?>Profile</h2><br/>
<table>
    <tr><td>Firstname:</td><td><?php echo $firname: ?></td></tr>
    <tr><td>Middlename:</td><td><?php echo $midname: ?></td></tr>
</table>

<?php
} else die ("Please specify a username.");
?>
</body>
</html>

You really should go to www.php.net and look at the function definitions. The PHP site is one of the best available for learning the language.

Even on a cursary look at you code there a major structural problems.

Member Avatar for diafol

OK this is a bit of a problem

1) You're using deprecated code (mysql functions)
2) You have a while loop for some reason, but I assume usernames are unique, so there should only ever be a single record at most. So no need for loop.
3) HTML and PHP mixed up all over the place - aim to separate as much of the PHP as possible. Place above the DTD and just have echo placeholders.
4)

<title><?php echo $firname: ?> <?php $famname: ?>s Profile</title>

That can't possibly work as those variables aren't initialized yet.

There are other issues, but you really need to gain some sort of grasp of basic php. You can only do that from studying tutorials and other resources. Sorry can't/won't write scripts for you. If it didn't work, you'd have no idea how to fix it. So, my advice would be to learn basic PHP.

could be out of topic, but i strongly suggest PDO

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.