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




Excerpts Of Data


I am working on a project that involves PHP and MYSQL. I am currently pulling information from a TEXT field (could be LONGTEXT). I would like to be able to create an excerpt from the data.

So...say I run this query:

SELECT review FROM bookreview WHERE id=1

That will give me a rather lengthy review. What I would like to do is display only the first X number of words or characters (preferably words), add a ... and then link it to the rest of the story.

My question is how to cut short "review" after X words or characters. I presume it can be done in either PHP or MYSQL but I have no idea how.

I am uncertain if this is important, but this query is going to loop at least several times so I need to be able to work whatever code you give me into a loop so I can pull multiple reviews.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Simulate Send Data With POST And Get Data From A Web Page (whith A Session)
I'd like to get text of a webpageB that I reach by putting
a login and a password in a webpageA.

I mean:
I'd like to get text of a WebPageB with a php script.
But before I can see WebPageB I have to autenticate myself
in a WebPageA writing my login and my password in a form,
the host recognise me and (by session) let me see the WebPageB.

The question is:
1)how to simulate send data (login an password) in form with a PHP script?
2)how to navigate in a Web usin the same session?

Problems With Reading Data From A Text File And Inserting The Data Into DB
Ive been having problems getting this to work for 3 days now. Basically what im trying to do is read from a text file and insert the information into mysql. The text file is in this format:

"LuCyndi@infiniti.com","carol","kellerhals","109 veeder dr","las vegas","NV","89128","702-254-2061","45"
"the_prophet@att.net","a.","cohen","6794 e. bonanza rd","las vegas","NV","89110","702-463-6569","55"

I understand how to open files to read but im having problems turning each set of data into an array so i may insert it into mysql. If someone could please help it would be appreciated.

Comparing Form Data To Mysql Data
Im interested in building a script that would take form data, a variable like an address, and compare it with a known address in a mysql table (called addresses), then if there is a match log the address information in a separate table called (addresslog), and return the visitor to a certain page. If there is no match between the address entered in the form and known addresses then the information is still logged into the addresslog database but the visitor will be sent to a different page.

I'm still new to this, and am working through the logic and the syntax, but I believe I'm close. It's still not working, I have all of the proper tables, maybe I'm way off with the coding so I thought I would seek out some expert advice. Here's the entire script with as much explanation as I could give. PHP Code:

Data Type Change Without Loosing Data
I have a problem in mysql. I stored a date in  08/14/2006 format and choose a datatype longtext now i want to store date in 2006-08-14 form is it possible to do it without loosing data in db when i convert datatype longtext to date the data lost. Any solution?

Showing Data From Data In Specific Interval
i will make a banner system to my website. there is some information in the database i get out with to my site. that is pasteing the data in random way. i have a date with day-month-year and a time .. hour:min. how do i do in my code so its is displayed in ex 1 month from that day it is acceptet. give me an example to how i could do it.

Data Mining / Data/Website Scraping
I'm looking for a piece of software or coding that will let me post a
form
to another URL, accept the response, search it for a specific
"success"
string and then let me continue processing the rest of my program.

I want to accept queries on behalf of my supplier, forward it to them
behind
the scenes, accept their response and display it within my website.

Has anyone had any experience with this? Is there a simple, basic
utility
to let me do this?

I was kind of hoping I could avoid developing it myself.

Delete Data From The Data Base
Im doing the PHP-MYSQL program to search the data in the database and display on the HTML Page. Everything is working fine till now. Now I want to know that, how to write program to delete the searched and displayed data from the database.....

I know the MySQL Syntax to delete data from database...Im not asking about MySQL programming. I want just an idea, how to do the delete process. Here is My full PHP script, Code:

Comparing Database Data And New Data
I am trying to create a PHP script that reads in a file, parses it for the data I want and compares it to the data I have in a database.

The data is points and ranking information for a Folding@Home Team.  Every week someone creates a news item with points gained by each team member for that week and other info.  This is done manually and takes a lot of time.  I hope for my script to automate as much of it as possible.

The script was to run as follows:

Download and parse latest statistics into 2D array
Compare usernames in array to usernames held in Database
Any new usernames and their respective points/rank to be added to database

Compare points in 2D array of each user to those held in database.
Output username and points gained

I thought I had a working script until I actually tested it on real data, and realised I missed something rather obvious - the order of usernames from the parsed file is not going to be the same order as in my database - due to people moving up and down the ranks.  So i can't just get a recordset from the db and run a simple loop to compare it to the parsed data.

I am not sure how to go about comparing the database information with the parsed data that works around the fact the data could be in any order.  The only thing i can think of is:

foreach item in $parsed_data_array
    query database for $parsed_data_array=>username
        if(number of results == 0)
          build new insert query for current username
        else
          continue

I don't know if this works [haven't tested yet] but I can't help feel it is a little DB intensive.  There could be up to 200 queries being sent to the database.  This can be minimized by adding extra criteria, like ignoring inactive users of course.  Is this a viable solution or is there a much better way of doing this?

Retreiving Data And Maintaining Data
I am trying to add data to a table in oracle but get

Warning: ociexecute(): OCIStmtExecute: ORA-00936: missing expression in /homedir/ilex-s02/mrace/public_html/addnewemp.php on line 18

here is the PHP script i am working with, Can anyone see any faults with it? Code:

Get The Data From Those Rows That Have Data
Hi Guys,
If i were to have the following php query:


$query = "SELECT * FROM alist WHERE list_id = $id";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
echo "<b>{$row['List_Name']}</b><BR>";
echo "{$row['address']}, {$row['state']}<BR>{$row['post_code']}<BR>Tel: {$row['phone']}<BR><BR>";
echo "{$row['Info']}<BR>";
echo '</blockquote>'

....how can i get the data from those rows that have data.
For example, some rows won't have a 'phone' value so i don't want this to display "Tel: " if there is no value associated with 'phone'.
What do i need to add to my script inorder to achieve this?

Thanx...

Posting Form Data And Also Allow To Download Form Data
i have a client that whats to post form data to a database but he also wants users of the script to download it aswell how will i got about doing this i thought about it that i could make it save it into a txt file then echo the download link is there any ideas? because to post it to a txt file it would be posting 2 places is there a way to do this? Code:

Getting Data From The URL.
I´m using php to build dinamyc images. The whole process is done via form. The user enters some data in text fields and them a script retrives this info and builds the image.

The next step is to provide the users with a url so they can display that image in their site. But I need that image to be updated ( if needed ) when it is called to be displayed.

My question is this, how do I get data from the url and use it on my script.

Let me give an example:
The url for the image would be something like:
http://www.myserver.com/images/fabiop.jpg

I need to retrive the username ( fabiop ) and the extension ( .jpg ) and use them in the script to generate the image on the fly to be displayed. How do I acomplished that ?

I´ve seen this working on some sites but I didn´t figure out how it was perform. My best guess was that this sites have a webservice running in the background that performs this action.

Getting Data From A Txt File
Get data from a txt file, and say that the first 8 characters are the id, the characteres 9 to 17 are the date.

Sorting Data
Im displaying data from a mysql query that displays a Player, email, id etc.. and I have links that sort the data by player, email, id etc... But Ive seen websites where you click sort and it will sort the data by that and if you click it again it will sort that data this time in descending order.

How am I able to have link that will sort the data normally and descending order?

Parse XML Data To PHP
When parsing XML data in a php file the script is told where the data is. For example:

Inserting Data Into A Row
I’ve got a table of three fields (id, name and comments) that contain 30 rows. Each row contains data in the two first fields (an id and a name). The third filed is empty.

When a user accesses my page they can select one of 30 names from a drop down menu. After they’ve selected a name the user can write a comment about the person he/she selected.

How can I insert the comment from the user into the comment field related to the name selected?

Dynamic Data
I have included a php script into my page
as <img src="plot.php">. That script just plot some time changing data. Now I have two questions that I cannot solve myself:

(1) When I press the reload button I expected
the plot reflected the changed data.
Instead of that plot remains unchanged
until I directly invoke the php script
from the browser...
Is there any method to avoid this
unwanted caching?

(2) That is a bit off topic but is there
any easy way to get a web page updating
after a certain period of time?
Once solve my first question I'd like
to offer mi visitors a automatically
changing graphic.

Truncating Data
I have a simple form, going to a simple catch page, but it doesn't work perfectly. In the one text field, it truncates the first 4 characters of the text. The rest of the string comes through fine, but it's the first four that get lost.

this is the top of the form, and the field that is givng me a problem.

Extracting Data From XML ?
The following is the sample XML file from which I want to
extract the data of which availabity ="Available" using php.

The XML file will be generated dynamically from the URL http://www.upc.nl/zipcode.php?zipcode=3565BG

<UPC-Results>
<DateTime>05-12-2005 02:08:26</DateTime>
<Errors/>
<Products>
<Product name="CaTV" availability="NotAvailable"/>
<Product name="Chello Starter" availability="NotAvailable"/>
<Product name="Chello Easy" availability="NotAvailable"/>
<Product name="Chello Light" availability="NotAvailable"/>
<Product name="Digitale telefonie FreeTime" availability="NotAvailable"/>
<Product name="Chello Classic on DSL" availability="Available"/>
<Product name="Chello Plus on DSL" availability="Available"/>
<Product name="Chello Extreme on DSL" availability="Available"/>
<Product name="Digitale telefonie Basis on DSL" availability="Available"/>
<Product name="Digitale telefonie FreeTime on DSL" availability="Available"/>
</Products>
</UPC-Results>
 
from the
above XML, I need to get data of Product name which has the status of
"Available"

Sort Data
When I click a title of table, I want to sort data. It same phpMyAdmin.

Select Data From Db?
I have a db that I need to select data out of. In the field it is selecting out of there is data input there from an array and then implode is used to seperate each item with a, When I run a query and wanna select data from this row I need the data from the previous form to = only one of the items in the row, but could be any of the items. how do I tell the page or the query that it could be any of many things in the row, but only has to be equal to one of them?

How To Use PHP To Retrieve Data From A PDF
I am looking for a tutorial, script about how to use PHP to retrieve data (Ex: filled customer input in a PDF file) from a PDF file and store it as a XML file.

Printing Data?
why the following code isn't printing any data from the selected database. PHP Code:

Logging Data
i am making a website for off-housing department at my university. the dept. wants to have a daily log so taht they can check on a daily basis, as to how many ppl entered the website on a paricular day. Seperate logs for each day would be preferred.

Check Data Not Already In D/b
Hwo can you do it, on an insert query so that it will check whether there is a record with the same info, say club name for example, and then if u try input same thing again it will reject it.

Data Sorting
I have a database table that has these fields: id (auto increment), date, message and what I wanted to do is sort the messages in order starting from the latest messages. I then wanted to sort the messages and only show 5 messages per page. I managed to do all this but now I also want all the messages with the SAME DATE (but different times) to be shown in the same table. for example: Code:

Storing Data
Say I have a number: number = 34043923, this represents a wordID, so the word belonging to this wordID is say: forum (whatever).

This can be stored in 4 bytes (so i am told ) BUT when I save it with fopen/fwrite it takes up 8 bytes (1 for every character) and the file can be read (when opening the file it just reads 34043923).

How can I store this data so it takes up only 4 bytes AND how can I do this storing it in a textfield of a mysql db?

How To Add Data To An Array
I have a question about how to add to an array. below is a test program for an associative array in which the value is also an array. I can work out how to fill the array when it is declared (as shown) but I have not been able to understand how to add another set of data later on. PHP Code:

Truncated Data
My data is truncated when updating to the database. I have two pages. "Edit page" and "form page" I added some debug codes in my page.

My results:- (echo $t1_client)
In edit page - t1_client = "Company ABC"
Before submitting in form page - t1_client = "Company ABC"
After submitting back to edit page - t1_client = "Company"

I cannot spot any thing missing, so I was hoping for some experts here to help me out.

Here is my form page:- (the field is $t1_client)
<select size="1" name="t1_client" >
<option value=<? if ($t1_client) echo $t1_client; else echo $jobs_cust['jobs_cname'] ?>>
<? if ($t1_client) echo $t1_client; else echo $tt_client; ?>
<? client_pull_down(); ?>
</select>

Postcode/zip Data
I need to make a 'find nearest' for a couple of different countries, does anyone have zip/postcode databases for all countries, or, if anyone just has the data for one country that would also be good.

SSL : When Data Is Not Encrypted?
If I have a PHP login page that is displayed via an SSL connection and then the form sends a POST request to a page that is not requested via the SSL connection, is the transmission of the username and password encrypted?

I thought it was as the login page is encrypted but just want someone to confirm this to give me a happy,warm feeling. Are there any security flaws with this method?

Feeding Data From Txt -> Sql Db
im making small catalogue in php. just add, view and order features. I first thought it might be easier to make the product database in .txt -file but when/if the catalogue grows its a lame solution(?) So is it hard to make a script in php which feeds data directly to sql db or form -> txt -> database.

Data Transfer From A Non-SSL To And From SSL
I would like to know how we can transfer data through a
secured channel to a non-secured site. I am designing an
e-commerce site and getting data from secured site
database(on a firewall) and display to my site.

Posting Data
I've got form with few submit buttons and one select field.
I need to post data to another file or to the same document.
Is it possible?

How Can I Insert Data In A Pdf From Php??
I have been reading this group but I can not find the simple answer
tohow i can solve what i need to do. I have a pdf template, it is, a
pdf with some data like name, surname,etc ...and i want from web
(using php) to open this pdf, fill thesedata and repeat it so many
times as number of students there are... I have read about fdf , etc,

Data Structures
Is it possible to create data structures in PHP and if so, would someone
provide a bried example?

Example:

I would like to create a Data Structure JRec which has the following fields

lID (Long)
dtDate (Date)
sName (10 Character String)

Extracting XML & RDF Data Using PHP
I have an XML file that contains metadata in the form of RDF. The file
is something like this:

<?xml version="1.0" encoding="utf-8" ?>
<xmpData>
<WavXmpInfo path="C:.....................................")
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="" xmlns:xmpDM="http://ns.adobe.com/xmp/1.0/
DynamicMedia/" xmlns:xap="http://ns.adobe.com/xap/1.0/"
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/"
xmlns:xapRights="http://ns.adobe.com/xap/1.0/rights/" xmlns:dc="http://
purl.org/dc/elements/1.1/" xmpDM:audioSampleRate="16000"
xmpDM:audioSampleType="8-bit"
xmpDM:audioChannelType="1"
..........
..........
..........
<dc:rights>
<rdf:Alt>
<rdf:li xml:lang="x-default">HHHHHHHHHHHHHH</rdf:li>
</rdf:Alt>
</dc:rights>
</rdf:Description>
</rdf:RDF>
</WavXmpInfo>
</xmpData>

I want to extract data such as audioSampleRate, audiosampleType etc,
so that i can insert them into a database. I'm having problems
accessing this data.
I'm using DOMXML. Can this type of data be extracted using DOMXML? If
not how would one go about accessing it?

Validating Data
I have data that is in this format: 8-8-19-29-1-4-41
I wanted to write a simple function or regular expression that
verified that data is in that format. The numbers should only be 1 or
2 digits. There should be 6 dashes (-) with 7 numbers around the
dashes. Here are examples of bad data:

8-19-29-1-4-41 (Only 6 dashes)
5-1-2-3-4-S-67-4 (Includes a letter)
5-1-2-3-4-222-67-4 (has three digits in one space)

Session Data
I'm having a small problem with sessions, or in particular some of the
data is not being saved within the session data.

To be exact, 1 variable from within an object is not being saved, but
all the other varibles within the same object are. Having a look at
the created session file, shows an unusual field relating to the
varible in question.

Session Data:
HRM_App|O:7:"hrm_app":9:{s:5:"state";a:0:{}s:7:"user_id";s:2:"19";
s:8:"username";s:17:"d.smith";s:4:"dept";s:1:"1";s:4:"comp";s:1:"2";
s:13:"user_security";i:1;s:3:"msg";s:0:"";s:15:"defaultRedirect";s:0:"";
s:3:"cfg";a:11:{s:6:"dbtype";s:5:"mysql";}}

The odd one out is: s:13:"user_security";i:1; where all the other
fields have the following format: s:3:"msg";s:0:"";

When I query that field later on, it returns "1", not the value that
it's initialised with as part of the application login procedure
(which also sets the other variables as well).

So can someone explain what the "i" indicates, what's going on, and a
possible fix?

PS. PHP 4.3.2 on Win2K with IIS.
PPS. I've searched for a description of the session file format used
by PHP, but can't find one anywhere?

Sorting Data Help
I know this should be fairly easy, but I am still very new at this. Ok, I am trying to pull data from my database and sort it. I want it to sort it by using field one sorting alphabetically, but only pulling up results from field two that has a specific name. I am not explaining this well sorry. I'll give you the code that I am trying and it's not working because I know I am not doing it right.

$result = mysql_query("select * from items where itemName Like'A%' and WHERE field2='value' order by itemName asc");

Table Data
I have a table on a php page with the cells containing database data from a mysqldatabase.
what would be the easiest way to allow a user to change how the data is listed by clicking on the top of each data column? I have seen this feature on most applications but cant figure out how to doit??

Data Transfer
In mysql there is table downup
************************
site enum('site1', 'site2'),
down datetime,
up datetime
************************
and there is file with such statistics about site1, site2 down and up period
************************
2003-01-28 15:42:08 (back up)
2003-01-27 14:05:45 (down)
2003-01-25 15:54:17
2003-01-25 15:11:19
2003-01-23 09:38:19
2003-01-23 09:06:55
2003-01-10 13:42:38
2003-01-10 12:45:40
2003-01-07 01:56:44
2003-01-07 01:34:47
************************
how to transfer these datas to the mysql table. If there is not back up the data will not be transffered and always check the highest datetime / event has to be on the top/last.
should i use regular expression (preg_match).

Inserting Data Twice
I'm working with a database now, and I have an error here, somewhere. The first time the user hits submit, the data goes in once, the second time the user hits submit, the data goes in twice. I don't know why. PHP Code:

Get Mysql Data
I have a database, and what I want is for people to be able to put in a number from the database and it pull up their info and put into a form, so then they can just add to what they already had.

PHP Handling Data
Consider the structure
C:firstFile.php
C:addsecondFile.inc.php

A user comes and postes some data to firstFile.php . Then the file does
a whole bunch of processing on the posted data. Now what should I do if
secondFile.inc.php wants the same posted data.

Is there anyway to make the posted data available to all the subfiles?

Sorting Data
I want my web site to be as dynamic as possible (hence the reason for trying to master php) but the knowledge I have at the moment will not quite stretch to doing the following:

I want to have the height attribute of an image to be controlled by data in a database table. The table will hold the numeric test result that pupils score when they take a test on my web based tutorial. The image is a column, the larger the score, the larger the column. I would like to know: Code:

Importing Data
I have this file cvs that's roughly 2.5 meg. Right now, it uses a function like this to import the data into the table. PHP Code:

PHP - Data From Access Db
I'm using the code below as a base for a connect to an access
database.
This works well, but I have an issue...

<?php
$db = "./access.mdb" ;
$pass = "1234" ;

$conn = new COM("ADODB.Connection") ;
$sql = "DRIVER={Microsoft Access Driver (*.mdb)} ;
DBQ=". realpath($db) ." ;
uid=admin ;
pwd=$pass ;" ;
$conn->open($sql);
$rs = $conn->execute("SELECT * FROM TableName");
while (!$rs->EOF) {
echo $rs->Fields['FieldID']->Value ;
echo $rs->Fields['FieldName']->Value ;
$rs->MoveNext() ;
}
$rs->Close() ;
$conn->Close() ;
?>

using this:
while (!$rs->EOF) {
echo $rs->Fields['FieldID']->Value ;
echo $rs->Fields['FieldName']->Value ;
$rs->MoveNext() ;
}

Averaging Data
I have a table of evaluations. The table contains the students names and proctors who completed the evaluations. There are 5 attributes that each student is evaluatted on. Each student will have between 5 and 10 evaluations, and there are 10 different students in the table.

What I want to do is be able to query the database (mysql) and return the average eval for each student on each particular attribute.

I am thinking the best way to do this is to use the avg function for each attribute, but I cannot figure out how to do this for each student, and then how do I return the query in php.


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