473,324 Members | 2,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

How to make display links from mysql database???

Hi i have the following problem and i am breaking my mind on it:
I have a mysql database with (id,title,topic,body) in the database i have
stored some documents.
How can i display a link with only the title of the document stored?(easy
one) but...
I want to view the whole document in the same page!
Let me explain in code:

<?php
$ip = "localhost";
$user = "kostas";
$password = "kostas";
$basename = "test";
$table ="docs";
$db = mysql_connect($ip, $user, $password);
mysql_select_db($basename,$db);
$result1= mysql_query("SELECT * FROM $table ORDER BY id DESC LIMIT 5 ");
$myrow = mysql_fetch_array($result1);
$title = $myrow["title"];
$intro = $myrow["intro"];
$body = $myrow["body"];
?>

So i want the five latest entries to be as links in a blank page and each
time a link is pressed i want to show the whole corresponding document
(title,intro,body) in the same page.
Thanks a lot
ka******@ee.duth.gr
Jul 17 '05 #1
1 7994
Kostas wrote:
Hi i have the following problem and i am breaking my mind on it:
I have a mysql database with (id,title,topic,body) in the database i have
stored some documents.
How can i display a link with only the title of the document stored?(easy
one) but...
I want to view the whole document in the same page!
Let me explain in code:

<?php
$ip = "localhost";
$user = "kostas";
$password = "kostas";
$basename = "test";
$table ="docs";
$db = mysql_connect($ip, $user, $password);
mysql_select_db($basename,$db);
$result1= mysql_query("SELECT * FROM $table ORDER BY id DESC LIMIT 5 ");
// if you don't need * choose your fields more judiciously
$myrow = mysql_fetch_array($result1);
// comment line above :-)
while ($myrow = mysql_fetch_array($result1)) {
$title = $myrow["title"];
$intro = $myrow["intro"];
$body = $myrow["body"];
echo '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $myrow['id'] . '">' . $title . '</a>';
// at this time I'm only using id and title from the DB
} // end while
?>

So i want the five latest entries to be as links in a blank page and each
time a link is pressed i want to show the whole corresponding document
(title,intro,body) in the same page.
Thanks a lot
ka******@ee.duth.gr


and wherever you want the body displayed add:

<?php
if (isset($_GET['id']) && is_valid($_GET['id'])) {
// the is_valid() function I leave up to you
// select body from $table where id=$id
echo $body;
}
?>
--
--= my mail address only accepts =--
--= Content-Type: text/plain =--
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Chris Krasnichuk | last post by:
hello, Does anyone know how I make php work on "my" computer? I made a mistake in my last post so I fixed it here. Chris
7
by: AF | last post by:
I am a real novice to php and MySQL, with about a week's worth of reading and self tutoring. I have an urgent need to publish a database of information and need some guidance on how to do this. ...
7
by: WindAndWaves | last post by:
Hi Gurus I am keen to make a search page on a website, but I have absolutely zero experience with PHP. I am going to hire an expert, but I thought that it may pay to try it a bit first myself...
4
by: Dave Moore | last post by:
Hi All, I hope you can give me a few pointers on this issue. I'd like visitors to my website to be able to enter text to be viewed on the site - a bit like a bulletin board or forum. I can do...
3
by: ozarks | last post by:
I want to setup a database symbolic link within Windows XP to a network drive which has significanlty more space available and can't seem to get it working. Here is my setup.... - I am running...
0
by: onearth | last post by:
Hello I managed to use SQL EXPRESS easily, however with MySql 5 or 4 I can't find any document explainning me how to use it :( The error i get is: The IListSource does not contain any data...
24
by: Phil Latio | last post by:
Let's say I have a simple web application running with just two MySQL tables. The tables structure is as follows: Table: category category_id (PK) category_name parent_category (FK)...
11
by: fishmonger1972 | last post by:
Hi! I'm a librarian with a little PHP knowledge.. I'm trying to make a catalog from scratch for my library. I don't like the look of the current catalog so I'm trying to make a custom PHP/MySQL...
5
by: mramsay | last post by:
HI, I'm having alot of problems trying to figure out how to create drop down links from a hyperlink on my homepage. I have a hyperlink called Programs (this is for a community centre) When...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.