Quick Help for Newbie

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

Quick Help for Newbie

Post by AliasBDI »

I am new to PHP and need some help. I am accessing a MySQL database to pull in text inside a flash file. The text has to be formatted a particular way (as you will see below). I have a PHP page with the following code:

Code: Select all

<?php
@mysql_connect("www.website.com", "user", "pass") or die("could connect to server");
@mysql_select_db( "databaseName") or die("couldn't select db");
$query = mysql_query("select * from tableName where id='$_REQUEST&#1111;id]' ");
while ($row  =  mysql_fetch_array($query)) &#123;
$pagetext1=$row&#1111;"title"];
$pagetext=$row&#1111;"content"];
$pagetext2=$row&#1111;"link"];
&#125;
echo "vartxt=<b>&#123;$pagetext1&#125;</b><br><br>&#123;$pagetext&#125;<br><br><b>&#123;$pagetext2&#125;";
?>
When viewing the page via Internet Explorer, it reads:
vartxt=A bunch of text pulled from the database
What I need is a similar page which queries the database and gathers the text in the TITLE field and LINK field that have the same ID which is the variable passed by the prior link. And then displays them (echo) like this:
title=Title 1
And it should be a hyperlink. The text for the "Title 1" is pulled from the TITLE field while the URL for the hyperlink is pulled from the LINK field of that same record.

How would this code look? (using the code of the first page)
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post by daven »

Code: Select all

<?php
print "title=<a href="$pagetext2">$pagetext1</a>";
?>
Post Reply