Jump to content

PHP TO MYSQL PROBLEM


DEVILofDARKNESS

Recommended Posts

The following code works perfect with my database and gives me a list with PName and UName.

The problem is that they all have the same link? What have I done wrong?

 

<html>
<head><title>Gedichten</title>
</head>
<body>
<?php
require_once 'config.php';                // our database settings
$conn = mysql_connect($dbhost,$dbuser,$dbpass)
        or die('Error connecting to mysql');
mysql_select_db($dbname);

$query = sprintf("SELECT URL FROM liefde ORDER BY PName DESC");
$result = mysql_query($query);
while($urlgedicht = mysql_fetch_array($result)) {
$query = sprintf("SELECT PName,UName,PText From liefde ORDER BY PName DESC");
$result = mysql_query($query);
while($gedichten = mysql_fetch_array($result)) {
	print "<ul><li><a href={$urlgedicht['URL']}.htm>{$gedichten['PName']} | {$gedichten['UName']}</a></li></ul>";
}
}
?>
</body>
</html>

Link to comment
Share on other sites

I think the following code will do what you want.

$query = sprintf("SELECT PName,UName,PText,URL FROM liefde ORDER BY PName DESC");
$result = mysql_query($query);
while($urlgedicht = mysql_fetch_array($result)) {
print "<ul><li><a href={$urlgedicht['URL']}.htm>{$urlgedicht['PName']} | {$urlgedicht['UName']}</a></li></ul>";
}

 

Basically removing the second query.

 

 

Link to comment
Share on other sites

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.