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




Displaying Block Of Text From MySQL Database


I would like to create a details.php page that displays all my products. I understand how to get the title, price, description etc from mySQL. But my problem is how do I get a list of data? For example say I want to display the features of a product in point form (list). What is the best way to do this? How do most common websites do this? Code:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Displaying Information From A Database In A Text Field,
I am trying to create an admin page, but before I get anywhere near that, I need to understand how to get data froma database to show up in appropriate form fields *text, textarea, etc...*

I am able to get content from my database to show up in my template, now I want to create a page that allows a user to click on a link for which they want to edit the information (name, and bio) So I want that page to show up with a simple form, a text field displaying the name, and a textarea displaying the bio information, so that they can modify it and save it to the database. how do you get the information to show up in the form fields? Code:

Displaying Text From MySQL
I am working on a very simple news page for a website. I've setup a simple form that writes news to my database and the data is then displayed on my news page. I have gotten everything to work successfully but the content in the article loses all its paragraph formatting when I try to display it. I can use break tags to make the formatting show up but there has to be an easier way.

This is the code I am using now, which I found on a tutorial somewhere and then tried to modify to work for my site: Code:

Displaying Text Pulled From A MySQL DB
I have a web edit, delete and update script set up. its all working pretty much as i need except for one thing, the editing function.

When an admin clicks edit beside an entry that page is resubmitted using $PHP_SELF and a variable is set. A check is then carried out in each form field to see if this variable is set, if it is set then a query is carried out and it enters the value of the query result for a table field as the value for the form field. You can see this in the code below.

My problem is this: when the values of the DB are echoes out into the form fields they dont display correctly or they just display the first word until they reach the first space and then nothing else. PHP Code:

Displaying First 50 Characters Of A Mysql Text Field?
I have been searching for hours on the php website for a function that
will allow me to display just the first 50 chars of a mysql text field
in a results table, but i'm having no luck. I need it to create a
results page for a site i'm creating in php.


Reading And Displaying A Date From A MySql Database
I've just started using php, and although I am very impressed by it,
there are some things with which I am confounded!

What I'm trying to do is read in a Date from a mySql database and then
display it on screen (the Date is in the usual yyyy-mm-dd format).

If I use SQL on phpadmin
SELECT Date
FROM details
WHERE details.Name = "Paul Lee"
LIMIT 0 , 30

The result comes up 2005-01-01, so this seems to work.
But if I use the following:

$db = mysqli_connect("localhost","root","");
@mysqli_select_db($db, "personnel") or die ( "Unable to select
database" );
$query = 'SELECT Date FROM details WHERE details.Name = "Paul Lee"
LIMIT 0, 30'

$result=mysqli_query($db, $query);

echo "<br>";

echo $result;

mysqli_close($db);

I get "Object id #2" displayed on screen.
I have tried to use the explode function to separate the months, year
and day using the "-" as a delimeter, but this doesn't work, and I
can't seem to get the other php date/time functions to work either.

Removing Block Of Text
Is there anyway with PHP you could remove a whole block of text???

Say if I had three lines of text and I wanted to strip those three lines out, but the only problem is, it might appear at the top or bottom of the page...How would I do this??

Displaying Data From Mysql Database In A Drop Down List On Form.
I'm trying to do is display data from two different mysql tables from the same database in a drop down list on a html form. I have a fixtures table with the player1(userid), player2(userid), gameid, game, score1 and 2, what I want is to use the userid to get the players first name and surname from the members table (as it is a unique id), I need to do this bit before displaying it in the drop down. I think i need 2 querys to do this but when I have tried it it just echo's a blank value or the userid not the forname and surname that I want. I'm using the fetch_array function but just can't see where I'm going wrong, Code:

Split Text Block Into Paragraphs
I have this large text block, but I would like to split it into
smaller ones by a number of characters. It needs to _split at whole
words_, and not just randomly in the middle of a word.

What's the best way to do this?

Making Mailto Links In A Block Of Text
Can anyone give me an idea where to start, I know I have to do some type of pattern matching. Basically I have an infomation field being displayed from a MySQl database and sometimes this field contains email addresses.

I would like to search for the email address (which I reckon I could do with preg() but how then do I add the required html to make the link live? Is it a case of searching for the string (pattern) and then if it is there taking the string assigning it to a variable say $pattern and adding it to:

$link="<mailto:"".$pattern."">".$pattern."</a>" and replacing
$pattern with $ link?

Converting Text Database To MySQL
I have a file 849 lines long with records in, each record takes up 4 lines and records are seperated with <-nrbrk-> Code:

Submitting Text For Use In A Mysql Database
This question has been bugging me for month. I have a website where people can enter stuff into a mysql database. Some of this
information will already be shown in some textareas and input boxes, the user may change it and then hit submit. All the values are
then passed to a mysql database, overriding the existing values (after the old ones have been backed-up).

All of this works marvellous, apart from characters like &, ' and ". To make it even worse, some of the original text already
contains &039; and other numeric character codes.

Any values from the database are displayed by retrieving them from the DB

[simplified of course]

mysql_quer(...)
$row = ...
$Vold1 = $row[x];
$Vold2 = $row[y];
etc...

<INPUT VALUE=$Vold NAME="x">
<TEXTAREA>$Vold</TEXTAREA NAME="y">

Any values that are submitted are processed as follows:

$V1 = trim(stripslashes(htmlentities(trim($_POST["x"])))))
$V1 = trim(stripslashes(htmlentities(trim($_POST["y"])))))

then $V is inserted into the table using a mysql query.

Text With Quote To Insert In A Mysql Database
i have a text field in a mysql database, how can i insert text with quote ( ' ).

Uploading Info From A Text File Into A MySQL Database
what would the PHP and SQL code be to say basically: make a new row and put this in the field, what comes after each comma goes in a new field, and each new line should be a new row.

I have a huge text file that i don't have a way to upload directly into a MySQL database because my webhost isn't allowing it for some reason.

Displaying Text
I am just screwing around a little and trying to display some text to the screen via a link to the text in a mysql db.

Displaying Text In PHP
I am trying to display a field in a database which is of type text in this fashion:

Code: echo $row['thearticle'];

However, the character ' is shown as ' i.e: "Britain's" will be displayed as Britain's . Do you what I need to do to solve this?

PHP Block Inside A PHP Block?
I want to include my logout session in my members page so it would be members.php?process=logout

the problem is, its not logging the user out. Code:

Displaying Long Text
I have a MSSQL 2000 database with survey data, the data field that contains the long data is varchar (8000). When I display the data it truncates the data to 255 characters including spaces. The following code is something like this:

while($Results=mssql_fetch_array($SQL_Query) {
echo $Results[0]."<br />";

}

Is there something that I am missing?

Displaying Records From Text File
I have the following Code which reads in information from a text file: PHP Code:

Displaying Text With Include File.
Given this html code page;
======begin
<html>
<body>
<!--#include file="outing.1.shtml"-->
<form action="form.php" method="GET">
<input type="hidden" name="op" value="ds">
<table width="468" border="0" cellspacing="0" cellpadding="0">
<tr>
<input type="hidden" name="id[1]" value="1">
<td>Name<input name="name[1]" type="text" size="30"></td>
<td>Email<input name="email[1]" type="text" size="60"></td>
<td>Phone<input name="phone[1]" type="text" size="15"></td>
</tr>
</table>
<input type="submit" name="submit" value="submit">
</form>

</body>
</html>
===========end
and this php code page;
==========begin
form.php
<?php
if($_GET["op"] == "ds") {
foreach ($_GET["name"] as $key=>$value) {
echo $_GET["name"][$key] ."-". $_GET["email"][$key] ."-".
$_GET["phone"][$key] ."-". $_GET["id"][$key];

$fp=fopen("outing.1.shtml","a");
fwrite($fp,$_GET["name"][$key] ."-". $_GET["email"][$key] ."-".
$_GET["phone"][$key]);
fclose($fp);
}
}
?>
========end

Both of these are on my IP server, EV1.

I would like the contents of 'outing.1.shtml' to be displayed hence
the <!--#include file="outing.1.shtml"--in the HTML code.

Displaying Contents Of A Text File?
I'm trying grab the content of a text file and print it a web page. I believe that I should be using something along the lines of "file" or "fopen", but I'm not having any luck. Any thoughts or tips?

Displaying Text/html In Web POP Email
is it possible that message from web POP mail ( through sockets) appears as html (or text) if it is sent as html, not to appear like source file of the html document? I use web POP mail which is not mine and it displays without problem emails sent as text/plain but shows complete source with all tags if the email is sent as text/html, in other words, it´s useless and very hard to read for user.

Text File Displaying On Screen
I have a file that downloaded a CSV file for the user based upon some
information gathered from the Database. My file was working fine until
recently (I believe that my hosting company did something when they
upgraded to PHP5). Everytime a user tries to download the file, it
displays the contents on the screen. Here is what I have for my file
handling. Am I missing anything obvious?

when called, $filecontent is displayed to the screen...

$downloadfile=$shownic."AttendeeRoster".time().".csv";
header("Content-disposition: attachment; filename=$downloadfile");
header("Content-type: text/css; charset=UTF-8");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".strlen($filecontent));
header("Pragma: no-cache");
header("Expires: 0");
echo $filecontent;

Displaying Text While Page Is Loading
i'm trying to display text while a page is loading using a method
similar to the following:

<?
ob_end_flush();
echo 'AAA<br>'
flush();
sleep(10);
echo 'BBB'
?>

in this script, AAA and BBB appear at the same time - when the page has
fully loaded - which is not what i want (i want AAA to appear and then
10 seconds later, BBB to appear). pursuant to the suggestions on
php.net's entry for flush, i've also tried the following to no avail:

<?
echo 'AAA<br>'
ob_flush();
flush();
sleep(10);
echo 'BBB'
?>



Displaying Text Fields On User Input
How would I echo a particular amount of text fields depending on how many the user selects from a drop down menu that I have already created. For example say the user selects 4 or whatever other number from a drop down menu how would I echo 4 or whatever the amount of text fields for a user to input text into? An example would be an airline website were you select how many people are travelling and then it echo fields for those people to enter their names.

Displaying From Database!
I'm trying to display products that are pulled form a database in a certain way using only DIV tags I would like the products to display across the page in rows of 4, however when i use div tags it is just putting one on each row.. whats the best way to display in a row of 4? here is an example script of what im using to experiment with: Code:

Displaying Php Chart Text On My Host Using An Uploaded Font
Hi im trying to get a chart to display using php. I get an error at the
moment when i use the function (or any requiring an uploaded font to be
used):

imagettftext($image, 6, 0, 0, $initial_point, $colorRed, 'Verdana',
$initial_value);

The error stems from the loading of the verdana ('Verdana') font file
which IS uploaded and works locally but for some reason the script cant
find the file on your site so its returning an error. Does anyonw know
what what might be the cause of this? For example I am using a mac to
work locally and then uploading to the php server which is linuz might
i need to use diferent fonts or something on the server?

Not Displaying First Record In Database
this code is not showing up first record in database:
the table should start off by clan id = 1 and clan name = name1
page: PHP Code:

Displaying Content From Database
need some simple help with displaying content from a mySQL database using PHP. i want to know how to write a php script to display the latest entry in a table to an html page. and also how to adapt the script to display the latest x amount of entries.

Displaying Date From A Database
All I need to do is change the date so it reads, for example, May 1999 when it's displayed on the page. Code:

Problem Displaying Image From Database
I used the code below to pull out an image from a mysql database
but nothing shows on the page and there was no error message to
indicate any problem.What could be wrong.The image is actually in the
database with all the details:

<?php
if(isset($_GET[loginid]))
{
$con=mysql_connect("localhost","name","pass");
if(!$con)
{
die('Could not connect to database:'.mysql_error());
}
mysql_select_db("datab",$con);
$id = $_GET[loginid];
$query = "SELECT name, type, size, content " .
"FROM image WHERE id= '$id'";
$result = mysql_query($query) or die('Error, query failed');
$file=mysql_fetch_array($result);
$name=$file['name'];
$type=$file['type'];
$content=$file['content'];
header('Content-length: '.strlen($content));
header("Content-type: $type");
header("Content-Disposition: inline; filename=$name");
echo $content;
}
mysql_close($con)
?>

Displaying Values From A Database From An Include
I've got a URL going to a template, e.g. www.mydomain.com/product.php?id=product_a

where the template is product.php the tag after the ? refers to the product that should be displyed in the template, in this case product_a

Inside the template (product.php) I've got:-

<? $url = $id.".htm"; include("$url"); ?>

This works fine so far. How ever I've also got an include inside the the template (product_a.php), called product_info.php, which is another php file that displays the product version and the platforms that it sits on. so in the the include (product_info.php) I have:-

<?php

$db = mysql_connect("localhost", "username", "password");
mysql_select_db("DATABASE",$db);
$result = mysql_query("SELECT version FROM table1 WHERE id = id",$db);

do { if ($myrow[0] != "") { echo "$myrow[0]n"; } }

while ($myrow = mysql_fetch_array($result));?>

however this displays all the version numbers within the table (for every product)

I just want it to display the version number of the value of $id (www.mydomain.com/product.php?id=product_a)

Displaying Image Stored In Database
The user can browse and upload an image and the image is stored successfully in a seperate binary table (with userid and bin_data, filesize, filename, filetype). The photo is displayed properly when I point my broswer to a script called fileshow.php:
PHP Code:

Problem Displaying One Column Of One Row From A Database With PHP.
I have a small script with PHP that queries a MySQL database to pull
out one row, where I want to be able to access each of the columns
separately. I have tried several different variations and am able to
get the entire row to print, but when I attempt to access the
individual columns I get an error. Here is what I have so far:

if (isset($_POST['memberNo'])):
$link = mysql_connect('...','...','...');
mysql_select_db("...");

//Perform a test query
$query = "SELECT * FROM users WHERE 'id' = " . $_POST['memberNo'];
$result = mysql_query($query) or die(mysql_error());

$line = mysql_fetch_assoc($result);
print $line;

//Close connection
mysql_close($link);

The point of this code is to retrieve the user information to validate
the login information sent in the previous form. I do not get an
error with this code, but it also does not print anything. I know
there is an entry in the database that matches data sent in the
$_POST['memberNo'] variable, it is the only entry in the database.

Changing the 'print $line;' to 'print $line["id"];' does not display
anyting either.

Displaying Database And Getting Unwanted Results...
I want to display everyone in the database, but only if the 'level' field is larger than 0.  Well, this works fine for most of the database... but if the last entry in the database is 0, then it prints it anyways.

Is there anyway around this?  I tried adding an if statement before the last bit where I echo out the table rows, but it was killing the entire table, or still showing the same results. Code:

Displaying Results From Database In A Particular Format
How do I display results from a database in a particular format.  For example the following text in this format including the lines in stored in the database:

Quote“Hello,

Welcome to the news for 11/06/07.

Thanks”
When I echo the results using the usual, <? echo $row_news[‘news’]; ?> it doesn’t echo the information in the database in the format it is stored for example it will display like this.  Quote“Hello, Welcome to the news for 11/06/07. Thanks”  How do I get it to display in the format it in displayed in the database?

Displaying Database Information In Columns
I have a database with products in and I want iT to automatically show every product on the page. Now I am able to do this easy enough but what I am struggling to do is that I want the products to be displayed in 3 columns. I can get them to display one under the other easy enough but I want them to be in rows with 3 columns instead.

Displaying Multiple Items From Database
what i have is a page that has four sections. what i want to have is when the page opens, in that page i want the lastest two items for each section from a database to be displayed. the items to be displayed are an image, a title and a description. but i also want the description to be shortend to say about 25-30 words or about 100 chars, if thats easier?

so in the end i have 4 sections, each showing the lastest two items for each section.

would the best way to do this be to have a seperate table in the database for each of the sections? or would i be able to do it from one table?

would i have to creat a query for each of the sections?
e.g:
SELECT * FROM table WHERE section=section

Displaying A List Of Categories From A Database In A Select Box
Could someone please tell me why this outputs nothing

<select name=categories>
<?
$cat_array = get_categories();
foreach($cat_array as $this_cat)
{
echo "<option value="";
echo $this_cat["category_id"];
echo """;
echo ">";
echo $this_cat["category_name"];
echo "
";
}
?>
</select>

==========================================================

function get_categories()
{
//get the list of categories from the database

$conn = mysql_pconnect("localhost", "user", "pwd");
$query = "select * from categories";
$result = mysql_query($query);
if(!$result)
return false;

$num_cats = mysql_num_rows($result);
if($num_cats == 0)
return false;

$result = db_result_to_array($result);
return $result;
}

//A function that returns a query to the database as an array
function db_result_to_array($result)
{
$res_array = array();
for($count=0; $row=@mysql_fetch_array($result); $count++)
$res_array[$count] = $row;

return $res_array;
}

Displaying Database Records Over Multiple Columns
I am currently using the following to generate a table with a single column with ten entries PHP Code:

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

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:

Database Search -text Database...
Can anybody tell me how to search a flat file database delimited by |. I have exploded the data and managed to get it into a table but want to restrict the final table contents by a search.

The table code at the moment is below - I'd be using a htm file to submit the data. and hopefully be able to search by partial searches eg big would return big and bigfoot. Code:

Quickly Adding Text To A Mysql Text Field That Is NOT Empty
Is there a way to insert text into a mysql text field that already has
text into it; without having first to extract the existing data and
append the new text to that string variable and then insert the new
string.

Basically i'm looking for a way to do it with a single query not 2 (one
being a select to gather existing data).

Gaining Access To How MySql Parses Text For Full Text
I want to gain access to the function or process MySql uses to parse words and phrases for Full Text searching. Here is an example.

If the user inputs...

Milan in history

MySql will search for milan, history, and milan history. Is there a way to extract just the combination of terms MySql uses to search the db without the stop words? Stop words are automatically eliminated from the search request unless the user encloses a phrase in quotes.

What I am trying to do is develop a script to highlight found search terms and phrases. I can explode a phrase into single words but if I do that the stop words would be included in the array. If there is some way of getting into the parsed words or phrases MySql Full Text actually uses to search, I can use each of those combinations as a keyword in my highlighting script.

This request is about searching for the code or any code related to the questions involved.

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.

Text Not Right From Database
I have a Profile section in my users registration, but if you enter a few lines and a few 'enter spaces' like <BR>, then the <BR> spaces do not appear and the text is continuous!
my profile section is just 'text' in the database..should i change this to blob or varchar.? I also need the same fix for my news part! which is over 255 chars!

PHP, MySQL And Displaying JPG Images
I got a script that is supposed to display a JPG image from the database, but, instead of displaying the image, it displays the JPG binary output with those alphanumeric characters.

Coule this be a Header MIMI type problem in my script?

Displaying A MySQL String Using PHP
I've got a multiline string of data held in a MySQL database.

I can extract the data using PHP and display it on the screen but when I do so, the string loses all of its formatting (i.e. The carriage returns and line breaks get lost and the string is placed all on one line).

How can I display the string correctly without using a <pre> tag and without putting the string into a <textarea>.

Displaying MySQL Tables
I am creating a database that allows anyone to fill out a form and be added to the MySQL database. My problem is, I can't see who has been added. Could anyone please help me with the PHP code for this? I have tried the following: PHP Code:


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