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




Fetch Maximum Amount Of Chars


I want to fetch a maximum amount of chars, 10 in this case, from my mysql dbase with php. For example: If there is 'Post new topic for forum' in the table, I want to output it to the screen like this: 'Post new..'




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Chop Down To Given Amount Of Chars
I need to take a string and reduce it to a given amount of characters, chop and trim seem to take a substring to chop at but i need it to be a set number or characters can anyone help?

Specials Chars Replaced By Strange Chars
i got a small problem in PHP.
When i try to get some data from a file (fopen), it replaces special chars
by weird chars.

Example :
Français instead of Français.
thème instead of thême...

Fetch?
If I want to retrieve a single row. I would make a query and than use msql_fetch_row. (If I use this in a loop it will fetch the next row until it becomes false).

If I want to retrieve multiple rows. I would make a query and than use msql_fetch_array etc..

Say I use a loop with msql_fetch_array and display the data in a table do I have to make a new query to display say the third row of the original table somewhere else on the page?

Validation On Amount
I am using a form to let the user enter an amount.
This must be with zero OR with 2 decimals.
I'm using the comma for decimal seperator.
How can I check if the input is valid (ereg or preg_match?) and what is the
exact statement I will have to use?

Fetch & Process
I doing a straight forward webpage fetch and saving it to a file: CODE:

$open = @fopen($url, "r");
$urlfile = @fread($open, 50000);
@fclose($open);
$page = split("",$urlfile);
$datafile = fopen($tempfile, 'w');
foreach ($page as $line) {
echo($line);
fwrite($datafile,$line); }
fclose($datafile);

So I basically just write the fetched HTML line by line to a local file. The weird thing is I'm getting a bunch of ^M characters in the final file after every $line is written to the file.

Fetch A Column
Is it possible to fetch a column from a queryresult?

Fetch A Php File
In my HTML I want to fetch a php file (the php file is a form for a user to fill out) but I want the form pasted on my page but instead it ries to open the form page in a new window of it's own... I tried href but also include.. I don't know that I am using the include properly..  any ideas?

Log Amount Of Clicks
Every time a link is clicked, how do I keep a record of the number of clicks a link has received, and store the results in a database?

Log Amount Of Clicks
Every time a link is clicked, how do I keep a record of the number of clicks a link has received, and store the results in a database?

Maximum Sizes
I have few more questions what is maximum string size, maximum header size for sending e-mails & maximum html e-mail size if we want to send html content in body and set content type tex/html.

How to configure linux server to increase mailbox size so that I can send huge mails. I'm really in a great trouble, It will be of great help to me if any one tells me this maximum sizes and how to handle if maximum size exceeds.

Maximum And Minimum Value
I want to find the maximum and minimum, average value from the text file

<?
$lines = file('./data.txt');

                foreach ($lines as $line) {
                $text_line = explode(":" , $line);


$text_line1 = explode(" " , $text_line[2]);
array_sum($text_line1);
}
?>

This method I am not able to get the array sum..... How to get the numerical value of numbers from strings When I explode the line it is in string format. I should find the array_sum and max() which I values  are in numeric not string.

How To Fetch The Structure Of A Table
Well can anybody tell me how to fetch the structure of a table and also the values specified for a patiular field type. Well what i exactly want is to retrieve the value set for teh enum field but have no idea as of how to get that values.

Select On Updated Value During The Fetch
Hi i have a table with all value at 4
i select all lines in a fetch
i update one with a value of 7

i update all the row in the fetch with a value 5

the result is that all my row are at 5
and the only line which should be at 7 is at 5 too.

i see that the problem is at the first mysql_db_query, and i don t know
how to solve it

$query="SELECT * FROM val WHERE str=&#394;'";
$result=mysql_db_query($datamysql,$query);
$query7="UPDATE val SET str=&#397;',updated=&#391;' WHERE val=&#392;'";
$result7=mysql_db_query($datamysql,$query7);

while ($row=mysql_fetch_array($result))
{

$str=$row["str"];
$val=$row["val"];
$query2="UPDATE val SET str=&#395;' WHERE val='$val'";
$result2=mysql_db_query($datamysql,$query2);
}

PHP Fetch 6 Letter Strings
How would I go about fetching only 6 letter and more words from my string. Say the string was from a database, and is formatted like this. Code:

Fetch Object Using Oracle API
I cannot fetch object using oracle functions defined for php3.

Checking Shipping Amount With UPS
How do I check the shipping amount with UPS from one location, to the zip/postal code they entered into the site (shopping cart) and return it to my site. I'm making a shoppiong cart here, and I don't know howto do this with UPS--does anyone know?

If Fetch Array Is Empty ?
I'm doing a fetch_array and I would like to display a "no records
found" message to screen. For some reason this is not working:

here's my Postgres SQL as proof:
surveys=# select othermore from table where othermore <> ''
othermore
-----------
(0 rows)

Then I have:
$result = pg_query($conn, "select othermore from table where
othermore <> ''");
while ($row = pg_fetch_array($result)) {
if (!$result) {
echo "no records<br>
";
} else {
echo "$row[0]<br>";
}
}

Strnage ? Can someone shed some light on what UI am doing wrong ?

How To Fetch Records In Div Listbox?
I found this code interesting and wish to use for my project, but i wondering how do i fetch records in this nested div tags. Code:

Showing X Amount Of Text.
I have a design on my site, and i want it only to show so much text.. How do i go of doing this? its using a php include tag to include a .txt file that my new management system writes to.. How do i limit the text shown?

How Can I Fetch Files From Another Site
i wanna to catch html files from another web
how can i do it?

Big Amount Of Mysql Queries...
I have good script which works fast, but if i try to push to mysql many queries, i loose about 1000% of speed... my system have about 300-800 select queries and they can't be optimized... can it be here some hidden things too process many queries (select) faster? (no merge or different sql based optimizations... only php)

Amount Of Data On Submit
Is there a limit on the number of characters that can be submitted at once through a form?
I built this little emaildatabase and want to submit like a 1000 addies a time, seperated by comma, but somehow not all the data is sent through, is there a limit and if yes, is there a way to work around?

Fetch Url From Html File
basically this is no problem at all as i can use regex etc. etc. what i want to do though is: fetch the url from the source of a html file (still - no problem here) which is online in the web (the problem begins). the most simple way (imho) would be to essentially just do an PHP Code:

Replace A Set Amount Of Characters...
I was wondering if anyone knows the function which allows you to set like "..." after a set amount of characters.

COUNT Only Within Last X Amount Of Days
The script should grab only last 7 days of database entries which it does.  Also it also needs to count to see how many times a CD was played, which it also does, but gives overall total and not just within that 7 days. Code:

Select All And Effect Only X Amount
Is there a way to do some thing like this:

Select all users ... then UPDATE a random 20 % of the found users from A to a B..in a field lets say named Test ?

Fetch The Date From Timestamp
i have a mysql table with 3 fields

1.id  2.time 3.approved

values

1  1181237691  0
2  1181237703  0
3  1181237711  0

i want to fetch the distinct dates from this timestamp values using select statement.

i want to display like this
1  2007-06-07

second thing i want to update the approved value=1 where these distinct dates are equal to the above timestamps.

Get Amount Of Method Parameters
Php has some method related functions like method_exists to check wether a function exists in a class. I need a function that returns me how many parameters does a function of a class NEED to be executed, is there any?

Showing Only A Certain Amount Of Characters From A Value
I'm trying to display the description of someones article. I want to take the first 100 characters of their article and use it as their description, so my question is, is there a function that allows me to limit 100 characters of a value.

Getting Maximum Value Inside A Loop
I'm using something like this, to output a table of rows:

// Set max_val
$max_val = 0;
// Do the loop
while ($row = mysql_fetch_assoc($result)) {
$max_val = max($max_val, $row['integer']);
// etc etc
echo $max_val;
// etc etc
}

I want the maximum value of $row['integer'] to be available in every row. The above example does this, with the exception of the first (top) row of the table, where $max_val is then the value of $row['integer'] for that row - not the actual maximum for all rows.

What Is The Maximum Length Of A String?
the php manual gave an example where you can pull an entire file into one string:

$fcontents = join( '', file( 'http://www.php.net' ) );

is there a maximum size that this string can hold, therefore a maximum size file I could import...what happens when this max is reached...error, or just cuts off..?

Maximum Dropdown Size
I have a strange issue with dropdowns. Using php4, mySQL5, Apache 2 on
a fast XP pro PC, I have a form which requires 5 dropdowns populated
with indentical values. I extract the values using SQL and populate 2
variables and use a for-next loop to create the dropdown. The dropdown
contains some 310 items! It works beautifully if I have 1 or 2
dropdowns but as soon as I add more it partially creates the 3rd and
just stops until it times out!
All 5 work because I have altered their positions but it always stops
part way through creating the 3rd dropdown.

I tried an alternative method by doing away with the variables and
constructing the dropdowns with a 'while' statement reading through
the results of my SQL and got exactly the same problem only 2 and a
bit dropdowns.

Stopping it running after a few seconds or several minutes makes no
difference, it seems to reach a certain point and just stop - no error
messages or anything!

I have tried increasing the resourses in my php.ini file but this also
made no difference.

Can anyone suggest an alternative or a fix?

Maximum Integer Size?
I'm trying to figure out how big integers in PHP can be and am having
some difficulty.

My first idea was to try something like this:

<?
for ($bits=0; (1<<($bits+1)) > (1<<$bits); $bits++);
echo $bits;
?>

The result was 30. This, however, is incorrect as the following
demonstrates:

<?
$num = 1<<30;

echo "num = $num
";
echo 'num<<1 = '.($num<<1)."
";
echo 'num*2 = '.($num*2)."
";
?>

That my first idea would return the wrong result doesn't surprise me,
though, since bitwise operators in PHP are treated as arithematic ones
and not logical ones.

So I came up with another test.

<?
for ($bits=0; pow(2,$bits+1) > pow(2,$bits); $bits++);
echo $bits;
?>

In Windows XP, I got 1024 back. On Linux 2.6.13.2 and 2.4.28 (as
reported by phpinfo), all I get are timeout errors. So I decided to
make my script more efficient and hopefully faster:

<?
$x = 2;
$y = 1;
for ($bits=1; ($x*=2) > ($y*=2); $bits++);
echo $bits;
?>

On Windows XP, I again got 1024 back, whereas on Linux, I again got
timeout errors.

Using SELECT To Just Find Row With Maximum Value
how do i do a SELECT statment that will just query a table to find the
row with the maximum of a declared field. for example, if i have a
table of customers and i would like to get the value of the last
customer to register so the SELECT statement would return only one
row, how would i do this?

also, the plan i have is to use a while loop (coz i dont know any
other) to get the colum value of each row:

$select = "SELECT ...
$result = mysql_query($select, $conn); //$conn will be predefined in
the code
while ($row = mysql_fetch_array($result)) {
$date_added = $row['date_added'];
}

the while loop makes sense when outputting many rows but to get the
value of one column in one row, i dont know. it just seems a little
inefficient to use a while loop when i know there is only one row
returned (or will know), is this how all rows from a select statement
are queried or is there a more efficient way of doing this for this
situation?

Maximum Characters In Variables?
My concern now is that I am putting a lot of info into arrays. Is this a bad way to proceed? Or should I use a way to simply include() the file instead of loading it into a variable and printing it to screen? The reason why I have it in an array is for reading different parts of the file... But I can fix it to use the include() function for the heavy parts...

Right now I am storing the same data into a database I downloaded MySQL, made the database and tables and all I need to do is insert the info... But that's another thing. I wanted to not use a database because it will save money for hosting. The site isn't going to be very big (guessing only 50 pages) so I can use only PHP.

Using Mysql To Fetch And Display Document
I am currently building a library on the web, this library will consist of pdf-files, at least for now. To keep track of these files, I of course wanna use mysql to keep the information. The whole library itself is supposed to be viewed on a page, where you can sort the titles alphabetically, by author, year, etc.
The library will be completed with a fileupload-utility at a later time, but for now I just want to be able to display all titles from the db, that also should turn into a hyperlink. How do I do that?

Limit Amount Displayed In Array
I need to limit the amount displayed in an array. if the array is 100 I need to limit it to the first ten. I tried to do range but I can't seem to get it to work. here is how I am showing the array.

<?
$results = array_unique($results);
foreach($results as $resultsindex =>$goto)
{
?>
<a href="index.php?mode=2&url=<? echo $url.$goto;?>"><? echo $goto;?></a><br>
<?
}

Selecting Certain Amount Of Text Question
I have made a news administration tool that allows users to bold text, italize text, underline text, and create links using javascript kinda as you see on here with this message board when you go to post a message. This works fine.

I want to be able to select a certain amount of text from the news item posted in the db. This works fine also.

But, say for example I am extracting the first 150 characters of the text and say the last character is opening a link ie a href=" and never gets closed? My question is when extracting a certain amount of text how do I make sure that everything gets closed?

Pausing And Initialising Fetch Statement
i need to know, is there any way of suspending OCIFetch function, however storing it in the buffer and than initialising it again, after some process.

PHP.ini File Enabling GET To Fetch Infro From URL...?
What should the contents of my PHP.ini file be if I want to enable "GET" to fetch infro from URL?

Display Only A Certain Amount Of Content Per Page?
Basically, i am using file() and a for loop to display content from text files, but i don't want to have all the information displayed at the same time.

I want to show the first 20 lines, then have a link saying "Click for the next 20 entries" which takes the user to the next page which has the next 20 lines. What is the simplest way to do this?

Fetch Row Data Where Column Value True
I am looking for some guidance here with something I have driven myself nuts over. I have a MYSQL table that holds site variables in three fields, a "varname" field, an "id" field, and a "value" field. I would like to fetch the "value" field where the "varname" field is true. Example Rows:

ID=1
varname=title
value= My Website Title

ID=2
varname=url
value= http://www.mysite.com

I would like to add the value into a template by using the code: $setting[title] or setting[url], etc. Can anyone tell me how I go about fetching a row ov values where a specific coumn value is true?

Function To Fetch Database Results
I have a function that is supposed to fetch all the results from my table "games". There are two database records in that table. My function is supposed to display all of the records, but it only displays one. I also use a function to display a certain template. Here is the coding for both functions and my index. Code:

V(oice)XML/MySQL/PHP, How To Fetch Out Variables ?
I have a question (hopefully someone in here have worked with VXML and server scripts with a back-end database). How do i write the php code that fetch out the variables i am storing in mysql with vxml tags ? I have tried (using bevocal cafe) the code below, but without any luck(i am sure there is something with the echo/print statment) Code:

How To Access Value's From The PDO Fetch Command
I am using the PDO fetch command to return a vlue from the database, now the problem I am having is being able to access the value,

$bob = $result->fetch(PDO::FETCH_ASSOC);
print_r($bob);

When I print it out on screen I get
Array ( [assessmentID] => 1 )

If I try $bob[0] it return nothing,

any ideas?

Mysql Fetch With Drop Down Menu
Im trying to do somekind of dropdown menu taking information from the database but im not quite sure how this could be done with my knowledge.

alright so lets say i have a table named: projects SELECT name FROM project. and it will put all the data found in a html drop down menu?

Display Amount Of Data Transferred
Here I am trying to figure out if there is a pre-defined variable that tells amount of data (in bytes) transferred.  I would like to be able to make out an echo statement displaying the amount of data transferred from the browser form to the server by using GET or POST in form action.

Restrict CURL To Fetch Gif,mp3,pdf And Etc Files ?
My curl script fetches all links from a html page , but it fetches the mp3,jpg,gif files. Is it possible to set "text/html" in curl_setopt

Date Comparison For X Amount Of Time
Is there a way with the Now date to do something like:

From the timestamp of "when this event happens"...
dont allow this until X amount of minutes have passed from "when that event happened earlier" if you get me.

So basically the users go to a "jail" and in jail they cant leave till their time is up... but im not good at cron's so trying to find a different method of working out when a time has passed...


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