/    Sign up×
Community /Pin to ProfileBookmark

[PHP]bpage.php?title=love&message=1

Hi! I’m learning PHP and I’ve been trying to experiment with variables in dealing with database.

I want to retrieve and display the content of the database input messages in this kind of URL. bpage.php?title=love&message=1

I would like the content to appear when I click at the title of the input message because it will be a link. And the URL would look something like this
bpage.php?title=love&message=1

My database table
no
name
title
message
date

here’s the code which I’ve tried to do it. The link is right but the content isn’t.
[url]http://positive0.negative0.net/pagepage.php?title=cheese&message=5[/url]

[code=php]
$result = mysql_query($query, $connect);
while ($info = mysql_fetch_array($result)) { //loops in retrieving data inputs

$nu = $info[‘no’];
$tl = “message”;
$bn = $info[‘title’]; //variable change
echo “<a href=”pagepage.php?title=”.$bn.”&”.$tl.”=”.$nu.””>”.$bn.”</a>”;
?>
<!–table border=”1″>
<tr><td>Title : <a href=”<?=$info[‘title’]?>”><?=$info[‘title’]?></a></td></tr>
<tr><td>Name : </td></tr>
<tr><td>Message : </td></tr>
</table–>
<br>
<?
}
MySql_close ($connect);
?>
[/code]

thanks in advanced!

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@sneakyimpDec 20.2006 — when something doesn't work, it is helpful to have an error message.

AND

before you can query a database, you have to connnect to it:

http://php.net/mysql_connect

AND

you have to select your database:

http://php.net/mysql_select_db
Copy linkTweet thisAlerts:
@MichaelttkkauthorDec 20.2006 — database connection and retrieve is working. What I can't is the kind of link with the content being displayed when I click on the link at the title.

I couldn't figure it out what kind of syntax/tag/or command I should use or experiment to begin with.

http://positive0.negative0.net/pagepage.php
Copy linkTweet thisAlerts:
@sneakyimpDec 20.2006 — your links link to the same page is the listing. from what i can tell from your incomplete code, there is nothing on that page to show anything different if a query string is there.
Copy linkTweet thisAlerts:
@jignesh1Dec 20.2006 — see like the code u r trying to work with it is working
×

Success!

Help @Michaelttkk spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...