Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




How To Make Display Links From Mysql Database?


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"];
?>




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Display Links From Database, Constructs And Expressions
My users need to enter links into a MySQL text field (along with their text) to a file on the server.

For example; the file <a href="somefile.pdf"> somefilea is really big.However, I also want to calculate the file size for them.

I've used some of your code to do this, <?php getFileSize('somefile.pdf') ?>, so that the user would enter their text as; the file size <?php getFileSize('cover.pdf') ?> is really big.However, I've been told that putting PHP code in the database field is both problematic and requires the use of eval().

But, I've also been told that I can use something like:
the file {link:somefile.pdf} is really big.Then, when the text appears on the page a script looks through the text and constructs an html link from the text {link:somefile.pdf}.

But ... how? What would that script look like, any clues?

Mysql Php Display Row And Links
i have a script which shows news on my webpage when a user clicks a link from my rss feed. but if the news has any links within it it will not link them why is this? i think i need to change this row Code:

Make Data Safe To Input To Mysql Database
I'm just wondering what kind of things I should do to make sure that inputs from a form are safe to put into a mysql table?

I'm currently using ereg() on an input to make sure that only numbers are entered, but on other forms I've got thiongs such as names and other details. How do I make sure that they're not going to break my table?

How Do You Make Links Like: Something?id=3
Does anyone know where i can find a tutorial about how to make dynamic pages wtih id links.

Make Links Active
Im just wondering if there is anyway to automatically make any urls in my page content, into clickable links. Basically I have a small forum I built, and I want to make any URL the user enters, into a clickable link. So if I had www.google.com as plain text, then it would make it into a clickable link.

Trying To Display Image From Mysql Database
I have a mysql db, that holds images.
Images are encoded using base64_decode/encode, etc. Image data seems
fine.
I have a view.php page that is supposed to show the image, and an
image.php page that accesses
the database, retrives the image data, and then (theoretically) prints
the decoded data to the page.
below is the view.php page code: problem area the img tag src no
worky.

What am i missing (having stolen the idea for this from the web!!!!
thanks,
eric
/************************************************** *****************/
<html>
<head>
<title>Get The Image</title>
<link rel="stylesheet" type="text/css" href="css/csssmall.css" />
</head>
<body>
<center><img src="testimage/Sunset.jpg" width="300" border="1"
alt="Image of Sunset"></center>
<p class="para-color"><?php echo 'Beautiful Image' ?></p>
<br>
<center><img src="image.php?img=3" width="200" border="1" alt="Image of
Thelma Todd"></center>
<p class="para-color"><?php echo ''Nother Beautiful Image' ?></p>
</body>
</html>
/************************************************** ****************/

below is the image.php code:
/************************************************** ********************
<?php
$dbhost = 'localhost'
$dbuser = 'auser'
$dbpass = 'apassword'
$dbcnx = @mysql_connect($dbhost,$dbuser,$dbpass);

if (!$dbcnx)
{
echo( "connection to database server failed!");
exit();
}
if (! @mysql_select_db("portfolio") )
{
echo( "Image Database Not Available!" );
exit();
}
?>
<?php
$img = $_REQUEST["img"];
?>

<?php
$result = @mysql_query("SELECT * FROM images WHERE id=" . $img . "");

if (!$result)
{
echo("Error performing query: " . mysql_error() . "");
exit();
}
while ( $row = @mysql_fetch_array($result) )
{
$imgid = $row["id"];
$encodeddata = $row["sixfourdata"];
$title = $row['title'];
}
?>
<?php
//echo $encodeddata;print??
echo base64_decode($encodeddata);
//echo $prefix . $encodeddata;
?>
/************************************************** ***********************

How To Make Data Pulled Into Links?
i seem to be having trouble trying  to make the hacks that are pulled down into a link for exammple when you select a category it loads all the hacks that are associated with that category, now i need those hacks linkable so that they have there own page for example this will be the link hacks.php?hacksid=hacksid (hacksid being what ever that hack id is) Code:

How To Connect To Mysql Database And Display It In Flash?
i made a code for news that get the data in php and store it in database, then display it using flash.. how to do this..

#news database fields:
newstitle
newsbody
newsdate


#variables:
$newstitle=$_POST['title'];
$newsbody=$_POST['body'];
$newsdate=date("Y-m-d");

Display Items From A Mysql Database In A Table
I am trying to display items from a mysql database in a table but I need it to start a new table row each time multiples of 3 rows of the database table have been displayed like the following example:

item 1   item 2   item3
item 4   item 5   item 6

Does anybody know how I can make this work using php.

How To Display Mysql Database Information In Multiple Pages?
how to display mysql database information in multiple pages? i would like to display all my member with consist of 400 people and i wan it list in mulitiple pages, and contain a "delete tick" for me,and when i click the member, can redirect me to member detail imformation. it just similiar to email pages of yahoo inbox.

How To Automatically Make URLs Posted In A Forum Active Links?
I've been working on modifying a forum script for some time now and its almost ready to go. You can test it at http://www.designlaunchpad.com/forum if you like. The one additional feature I want to implement is the automatic creation of a link when someone posts a URL in their message. Most forums have this, is it that tough to add in? I'm pretty comfortable editing PHP and understanding what is happening where but I suck at authoring it. I checked the manual at php.net and tried searching this forum and google but keep running into dead ends. So can someone offer me some suggestions or point me toward some help?

Display Top Links Script
I am a relative newb to PHP programming although I have done a few nifty things with it. My newest undertaking is, I would like to display the top 5 or 10 links used on my website on the index page.

What would be the best way about doing this? I have awstats installed, and I thought pulling something out of there might be the best way. What about parsing directly from the Apache log?

List Contents Of A Folder, Make List Of Links
Does anyone know how I can write a script that:

- reads in all the files in a particular directory
- displays the file names in a html list and makes a link of them:
<ul>
<li><a href="filelocation1">filename 1</li>
<li><a href="filelocation2">filename 1</li>
<li><a href="filelocation3">filename 1</li>
</ul>

etc.?

So basically it creates a list of links with the contents in that directory,
so you can download them from there.

Storing Database Resource Links
Could anyone explain to me why the following code fails?

// =====Begin sample code=====

global $blog;

define("dbHost", "localhost");
define("dbUser", "ney");
define("dbPassword", "xxx");
define("dbDatabase", "blog");

function dbConnect()
{
// Stores the database resource link in the global array
$blog["db"] = mysql_connect(constant("dbHost"),
constant("dbUser"),
constant("dbPassword"))
or die("DB connection error: " . mysql_error());
mysql_select_db('blog')
or die("Error selecting blog database: " . mysql_error());
}

function dbDisconnect()
{
// Closes the connection represented by the resource link stored
// in the global array
mysql_close($blog["db"]);
}

dbConnect();
..
..
..
dbDisconnect();

// =====End sample code=====

Upon runtime, PHP produces the following warning:

Warning: mysql_close(): supplied argument is not a valid MySQL-Link
resource in /home/ney/Blog/db.php on line 22

How To Make A New Database?
I want to make a new database with several tables, so I did the following:

<?php
CREATE DATABASE bedrijf;
CREATE TABLE werknemers
(voornaam varchar(15),
achternaam varchar(20),
leeftijd tinyint(3),
adres varchar(30),
woonplaats varchar(20),
land varchar(20));
?>

What is wrong with this, and do you know another way to make a new database?
Is there a site that explains all about myadmin?


Previous And Next Links And Displaying Database Information
I would like to display a listing of files on a web page as follows:

If there is only one file: display the section name and then display the
current file.

If there is more than one file (for the first page): display the section
name, the current file and a few archive files.

If there is more than a page full (for each additional page): display the
section name, and the next set of archive files.

This is the code I have been working with (it's a bit ugly, suggestions are
welcome). For some reason the second page of listings skips the first item.
1st page lists items 0 through 4, second page skips item 5 and starts
displaying item 6.

function display_table($sec_id, $num_item){
GLOBAL $link;
$updir = "../uploads/"; //maybe this should be a GLOBAL variable???
if (isset($_GET['start'])){$start = $_GET['start'];}else{$start = 0;}
//GLOBAL $start;
//query DB
$query_total = "SELECT file_id
FROM files
WHERE file_section_id =" . $sec_id ;
$query = "SELECT file_id, file_meeting_date, file_meeting_time,
file_title, file_modified, file_section_id, sec_name, sec_id,
sec_disp_archive
FROM files f, section s
WHERE f.file_section_id =" . $sec_id . " AND f.file_section_id = s.sec_id
ORDER BY file_modified DESC LIMIT " . $start . "," . $num_item;
$result = mysqli_query( $link, $query ) or die(mysqli_error($link));
$result_total = mysqli_query( $link, $query_total ) or
die(mysqli_error($link));
$num_rows = mysqli_num_rows($result_total);
//print $query;
//create hyperlinks and display table
//display current file
/* print "START: " . $start . "NUMBER: " .$num_item . " ROWS: " .
$num_rows;*/
/*$obj = mysqli_fetch_object($result);*/
if ($num_rows > 1){ //Display current and archive files
//only display current table if start is not set (not on page 1)
$obj = mysqli_fetch_object($result);//Call DB
$content = "<div id ='MainContent'><p><b>" . $obj->sec_name .
"</b></p><table width=ï`%' border=&#391;'>";
if (!isset($_GET['start'])||$_GET['start']==0){
//for 1st item display file info
$content.= "<tr><td colspan=&#393;' align='center'>Current</td></tr>";
$content.= "<tr bgcolor='#CCCCCC'><td width=&#3933;%'>Meeting Date</td><td
width=&#3933;%'>Meeting Time</td><td width=&#3934;%'>File</td></tr>";
$content .= "<tr><td>" . date("F jS,
Y",strtotime($obj->file_meeting_date)) . "</td><td>" . date("g:i
A",strtotime($obj->file_meeting_time)) . "</td><td><a href='" . $updir .
$obj->file_title . "'>" . "View Current File" . "</td><tr>";
$content .="</table>";
print "START: " . $start . "NUMBER: " .$num_item . " ROWS: " . $num_rows;
//DEBUG

How To Make A Database Connection Available To All Pages?
How can I make a database connection available to all the pages in my
application? I tried doing it with session but it doesn't seem to work.

here's what a did:

Can I Make A Forum Site Using PHP And Without SQL Database
Hi guys, I know I'm on the wrong forum. I really like to make a forum
website but can I do it with PHP alone? Btw, thank you to all the
persons who answered my previous question.

Mysql Data Links...
I have a mysql query... The data i get out of the query is listed in a table.
I want each row(or the first column on each row) to be a link that links directly to a "edit" page for the row. How do i do that? My main problem is to make one unique link for each row that actually links to something.

Database Display
I am calling all fields from a table, just to many to call the ones i need. I would like to drop the first 2 from being shown, how can I do that by the code below or do I need to rewrite completely?

while ($line = mysql_fetch_array($store_data, MYSQL_ASSOC))
{
     foreach ($line as $data)
     {
          echo $data . ', ';
     }
}

MySQL Creating Links From Query
As I am still learning PHP could someone tell tell me how to achieve the following?

Display only the first four records from a sql query and have 'next page' links and number of pages so users can navigate the next four records and so on. The usual navigation you find on search engines.

I have the query and the num_rows function, I just need to know how to implement it.

Display Database Record
i have a php script that read from mysql and display then in textbox.
I have problem with the way textbox display the data.

<input type=text name="package_name" size=20 maxlength=10
value='.$package['package_name'].'>

when the package_name is 'china tour' it will only show china in the
text box. How can i show all the content of the record?

Display A Div Only If A Value In Database Is Equal To 1
Im trying to get a div to to only display if the the row in the database called "stock" is equal  to "1" if it is equal to "0 " then do not display the specific div.
Here is the code:

Display Then Update Sql Database
I have an html drop down list that I have populated from a sql database, a selection is made and the information on the selection retrieved from the database and output in text forms on another page. I want to be able to edit or add data and then update the database. Code for the second page is below.

I have echo'd the post variable and it does make it through. From what I understand the post variable is being removed when I submit the second form and so it all fails. How can i sustain the variable from the first page? Code:

Image Display From Database
i have one problem in my programming.there is a table containing some details of the product with its image.. in view section in my php page ,i need to show this image and the rest of the fields in the table in a row...

How To Connect To Database And Display It In Flash?
how can i connect to mysql database and display the data in flash?

Don't Display Duplicate Database Entries?
I have a restaurants database that has a lot of restaurants listed with the same name in the same city with only the category changed. This is the code that I have that displays the list of restaurants. Can someone tell me what to add to it so that it will only display one of each restaurant of a certain name? PHP Code:

Display The Latest Database Entry?
how I can display the latest database entry? PHP Code:

How To Display Data From Database In Different Web Pages?
When we get data from database by use mssql_query(),suppose the data is very large ,it has many rows, and we want display the data in different web pages like many search engines do, my question is how to do that using the same result without call mssql_query() again?

Display Randomized Questions From A Database?
I would like to store 300 questions in a MySQL database, and configure a webpage to display them in groups of 50 at random, then store the responses. Could anyone recommend a script or strategy to do this please?

How Do I Display All Database Entries Between Two Dates
I have two dates in a form " startdate" and enddate"

when i display the results i would like to show all results between, and including the two dates. how do i do this... this is my current query:

My Variables:

$userid = $_GET['idr'];
$fromdate = $_GET['fromdate'];
$todate = $_GET['todate'];

The query:

$result = mysql_query("SELECT date, status, time, notes FROM timeclock WHERE userid='".$userid."' ORDER  BY time");

Display Entry From Database To Browser
I can't display entry from database to browser, what's wrong with my code? Thank you for your kind attention. Code:

Function To Display Form From Database!
I'm trying to write a function which gets all the client names from a table and displays them in a drop down list. My function is displaying a form with nothing in! Code:

Make A Table In MySQL
How do I make a PHP script that is able to make tables with fields? I want to be able to have a HTML form submit the fields. I just want to know the PHP scriptlet that will make a table.

Storing Some Html Text In Database & Display Them
i have some text in HTML format ..i just want to store HTML text in database and retrive and display them as a HTML ...

Display Results From A Database On Multiple Pages
I am new to PHP and Mysql but am really determined to learn these techniques. I have some script that reads and displays results from the databse onto a page. However, I really wish to limit the number of results that are displayed to 10 per page and then have the next/privious links under the results. With these results, the results under the email field should be hyperlinked so that the person viewing the results should double click on the email link and send the person an email. How can i do that? I have to learn this technique.

The code is:-

PHP Function To Display A Database / Table Structure?
My webhosts cpanel is down for maintenence, including phpMyAdmin, and I need to view my database structure... Is there any function in PHP to display the database structure (like the "Export" function in PHPMyAdmin)?

Submit/Approve/Display Content In Database In PHP?
I want a page where users can submit an image, text, and links and then what is submitted goes to an administration page where such submitted can be approved or declined. And then another page where all the things that have been approved go into a table where the image, text, and links are displayed in a numbered fashion. Here are some picture examples of what I mean: Code:

Mysql_pconnect Make Mysql Too Many Connections
mysql_pconnect -> too many connections -> increase mysql max_connections -> take up more memory -> slower?!

there's many static file: html/images and dyn file: *.php
a php page is loaded, then images is requested, and then keep-alive idle, so most of mysql thread is idling...

what can i do to optimize?

Limit A Database Field To Displaying Only One Time And Still Display All?
I have a data table with a field that contains the exact same text (example "some text") on several different rows. How can I display all my rows without getting duplicates of this field; I only want to display this field once. I tried to use a LIMIT, but this is not what I needed. Code:

INSERT Into Mysql Alway Make Two Entries
I code some site and because Im a freak I made my own session-handling.
When a user open up my site it will check if there is a ssid in the url
if not generate one. this will be done by a function generate_ssid() and works fine.
next step is to register the ssid in the table session
this will be done by the following code:
******************************
function ssid_register($ssid,$login,$uid,$admin){

$connect = mysql_connect( $GLOBALS["db_host"],
$GLOBALS["db_user"],
$GLOBALS["db_password"])
or die($GLOBALS["db_error"]);
mysql_select_db($GLOBALS["db_name"],$connect) or die($GLOBALS["db_error"].'<br>ErrorCode s.001-con');
$result = mysql_query("INSERT INTO session SET ssid='$season',ip='$rip'",$connect);
echo ($rs);
return;
}
********************************
I redesigned the INSERT INTO part into all possible syntax but everytime I look into the db, there are two entries with two DIFFERENT ssids.
The only way it works correct is to dont use a variable on the first place.
Means if I use ssid='godhelpmetofindaworkingsolution' it works great but is not realy what I want.

As told above a "INSERT INTO session (ssid) VALUES ($ssid)" also has the effect of two new db-entries.

Display Database Output In Mutli Column Html Table
I am building an HTML form using data from a mysql query. The data to be displayed on the form is 1 column from the db - but multiple rows. Because there are many rows (well, only about 100+) in the table I want to be able to put 2 or 3 (space permitting) rows from the result on each row of the HTML table with a checkbox beside each entry from the db table. The idea is that the user will scroll down the list and check up to 4 or 5 boxes before submitting the form and I didn't want them to have to scroll ALLLL the way to the bottom (100+ rows). I understand how to get data from a db table and put it into an html table, but I cannot figur out how to put more than 1 row from the result on to the same row of the html table.

I hope I haven't confused anyone reading this -- If I am way off base with what I am trying to do please give me alternatives. I am trying to avoid paginating the data for a couple reasons a) clicking a next and/or prev button is more hassle than just scolling down a list and b) the data in the column being displayed is only about 35 - 40 characters and it seems to be if i only placed one result row on each html table row, there would be a lot of wasted space.

What To Use In PHP To Make User Input Safe For MySQL Query?
I believe that you want to escape certain characters in a query, like quotes, backslash, semi-colon, etc. Is there a function in PHP to do all this for you and make the string safe to use as a query string?

Cannot Make Connection To Local MySQL Server From Within Dreamweaver.
I am using OS X and Dreamweaver MX. I am trying to make a connection
to the MySQL Server from within Dreamweaver using the Applications
panel and clicking on the "+". A window opens asking for:
Connection Name: Apress
MySQL Server: localhost
User Name: apress
Password: xxxxxx
Database (Select):
When I click select so the Dreamweaver can browse to the databases in
MySQL the connection is not being made because Dreamweaver cannot find
the MySQL Server. I think that "localhost" is wrong even though I am
using the APRESS book: PHP Dreamweaver MX 2004 and it says to use
localhost. MySQL and PHP are on my local machine. I am NOT using a
remote machine. I used phpMyAdmin to create the databases.

Optimizing MySQL To Make Site Load Quicker
I recently coded a site that is based mainly off of mysql. I currently query the database 4 times in two for() loops I'm not sure how to change it, because I see no other way. I can't put the queries outside of the loops because in the loop it queries something different every time.

I want some help optimizing it! However, I don't want to post all my code here, because it's basically the main part of my site, and I don't want others copying me.

How To Make MYSQL Query To Sort The Articles By Date ??
I am developing a site using PHP and MYSQL where i can post articles. Each Article has features like author, date, data etc... I want to find out top 5 recent articles.

I store the date of an article in database as  $timeStamp = Date("F j, Y");

when i make a query to retrieve the latest article by date as:

$result = mysql_query("SELECT * FROM postData ORDER BY postDate DESC LIMIT 0, 5");

it doesn't give any output...

Upload Image, Make New Random Filename, Add New Name In MySQL
below you will find my code. In this page I have established a database connect already. the file uploads perfectly with my new name. My real question is how can I put my new file name in my database form my variable $newName. What would be the proper code to do this? Code:

Easy Way To Make "pages" From A Database List
If I list all the rows in a database and "LIMIT 20", how do I make it so I can go to, the next 20 rows? Say if I have 50 rows, and only want to show 20 per a page?

What Is Indexing In Mysql And How It Will Be Useful And How We Can Retrieve Database Content Easily From A Database Table Containing About 5lakhs Datas
I need to select data from a database table containing huge amount of
data. Now I am storing data using one primary key and I am just using
simple select statement, and this process gives me the output but it is
taking long to execute the query. As much I had heared I want to use
some indexing or cluster indexing which might help me but I am not so
familiar with these things.


Copyright © 2005-08 www.BigResource.com, All rights reserved