473,624 Members | 2,606 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("SE LECT * FROM $table ORDER BY id DESC LIMIT 5 ");
$myrow = mysql_fetch_arr ay($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,bo dy) in the same page.
Thanks a lot
ka******@ee.dut h.gr
Jul 17 '05 #1
1 8002
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("SE LECT * FROM $table ORDER BY id DESC LIMIT 5 ");
// if you don't need * choose your fields more judiciously
$myrow = mysql_fetch_arr ay($result1);
// comment line above :-)
while ($myrow = mysql_fetch_arr ay($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,bo dy) in the same page.
Thanks a lot
ka******@ee.dut h.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
11654
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
3360
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. This question might be more suited to a MySQL newsgroup, but since php and MySQL seem to have become almost married to one another, and since getting the data out and displaying it is where my problem seems to lie, I thought I would start with...
7
2181
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 (I do want to learn how to do it). What I have is a search page (HTML) and an access database. Now, can someone give me some clues or links on where to start. I prefer not to install the whole PHP thing on my own computer, but just to
4
1419
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 this for regular text easily by simply populating a 'TEXT' field within my MySQL database and grabbing it back when rendering the site using PHP. However, I'd also like visitors to be able to put in URL links or email items that can be clicked. How...
3
3787
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 MySQL 4.1.7 - I have tried this with both the 'mysqld-max' and 'mysqld-max-nt' servers - Per the MySQL manual (section 7.6.1.3) I setup a 'foo.sym' file in
0
1025
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 sources. on the line GridView1.DataBind(); I guess i missed using SQLDataSource Control... i do not know what to do with it to make it work with MySql.
24
4654
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) //references category_id in this table Table: link link_id (PK)
11
3583
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 implementation. I can do everything I need to do except, I don't completely understand a detail. Ideally I could write this: <a href="catalogrecord.php?recordnum=4">Tom Sawyer</a>
5
2902
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 the Programs hyperlink is selected I would like a drop down of link from my programs mysql table to be displayed. So far, it takes my mysql data and puts it as link but on it's own. I'm not sure how to put it under my Programs hyperlinks. Also...
0
8179
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8685
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8631
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8490
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7174
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6112
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4184
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.