I have been trying some pre-written PHP scripts that render a results table from a mySQL table query (adodb-pager, ez_results, etc)
These produce nice formatted tables with navigation through the multiple pages.
My question is:
I would like one column of the results on these tables (ie a NAME field) to also be a LINK to another page, so that a user could query a database table and then CLICK on one of the results to get to a more detailed page.
I am trying to learn PHP and have not really sean this implemented.
Does anyone know if one of these canned scripts could be adapted to do this? Or how I would write the code?
Thanks again to all the Pros who answer questions from newbies like me...
--Tim
How do you link from mySQL results?
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Not quite sure what you mean but heres my jab @ it
The braceted "yourlink" is what the field name is
Code: Select all
<?php
// Connect to the database server
$dbcnx = @mysql_connect("localhost", "username", "password");
if (!$dbcnx) {
echo( "Unable to connect to the database server at this time."
);
exit();
}
if (! @mysql_select_db("your_db") ) {
echo( "<p>Unable to locate the " . "database at this time.</p>" );
$result = @mysql_query("SELECT * FROM your_row");
while ( $row = mysql_fetch_array($result) ) {
$yourlink= $row["yourlink"];
echo "<a href="http://www.yourdomain.com/$yourlink">This is a link</a>";
}
?>Code: Select all
<?php
$yourlink= $row["yourlink"];
?>parse error
phenom,
First, is the second piece of php code to be included on the same page?, or is that just for reference to explain what the ["yourlink"] is?
In either case I get a Parse error for the last line of code (the line with the ?>)
help???
First, is the second piece of php code to be included on the same page?, or is that just for reference to explain what the ["yourlink"] is?
In either case I get a Parse error for the last line of code (the line with the ?>)
help???
Code: Select all
while ( $row = mysql_fetch_array($result) ) {
$yourlink= $row["yourlink"];yourlink = downloads
yourlink = uploads
yourlink = baseball
And so on..
parse error;'
NOte that not everthing has been closed.
{
{
{
}
?
?>
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Code: Select all
<?php
<?php
// Connect to the database server
$dbcnx = @mysql_connect("localhost", "username", "password");
if (!$dbcnx) {
echo( "Unable to connect to the database server at this time."
);
exit();
}
if (! @mysql_select_db("your_db") ) {
echo( "<p>Unable to locate the " . "database at this time.</p>" );
} // ADDING A CLOSING BRACKET
$result = @mysql_query("SELECT * FROM your_row");
while ( $row = mysql_fetch_array($result) ) {
$yourlink= $row["yourlink"];
echo "<a href="http://www.yourdomain.com/$yourlink">This is a link</a>";
}
That should fix the parse error
?>Phenom
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Code: Select all
<?php
<?php
// Connect to the database server
$dbcnx = @mysql_connect("localhost", "username", "password");
if (!$dbcnx) {
echo( "Unable to connect to the database server at this time."
);
exit();
}
if (! @mysql_select_db("your_db") ) {
echo( "<p>Unable to locate the " . "database at this time.</p>" );
} // ADDING A CLOSING BRACKET
$result = @mysql_query("SELECT * FROM your_row");
while ( $row = mysql_fetch_array($result) ) {
$yourlink= $row["yourlink"];
echo "<a href="http://www.yourdomain.com/$yourlink">This is a link</a>";
}
?>Btw the 2nd bit of code was just a reference, you do not need to add again
#*@( sorry for the double post.
Phenom