Page 1 of 1

Quick Help for Newbie

Posted: Thu Jan 16, 2003 6:40 pm
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)

Posted: Mon Jan 20, 2003 4:11 pm
by daven

Code: Select all

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