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




Return Results On One Page


i have a search field on a .php page. i want to return the results on the same page i.e i dont want the action to point to test2.php but test.php which is were my search filed is sitting at the moment. how do i do this? 

i got this on my first page:

<form method="post" action="test2.php">
Name: <input type="text" size="10" maxlength="40" name="name">

<input type="submit" value="Send">
</form>

and this on the second:

<?php
$name = $_POST['name'];
if ($name=="Friday")
  echo "Have a nice weekend!";
elseif ($name=="Saturday")
  echo "Tomorrow is Sunday!";
else
  echo "Please enter Friday or Saturday";
?>




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Return Search Results On Same Page
I'm struggling with this much longer than I think I need to,

How do I make the results of a search display on the same page as the
search, sort of beneath the 'submit' button? Thanks for helping out.


How Do I Return 10 Results Per Page Using SELECT Statement?
I'm wasn't sure whether to post this under the PHP or under the MySQL section of the forums. Since most people (I'm assuming) who write PHP script, also use MySQL, I thought I'd stick with PHP. I'm rather new to both PHP and MySQL and I'd be very grateful to anyone who can help me solve a problem I'm having at the moment. First, I'll give you an introduction to my little project...

I'm developing a database in MySQL that is used to store the song titles of all the MP3s I have on my PC. I've written a basic search feature that works well. The user has 2 options: Either he can type a special "!ALL" "parameter", that I made up, to return all the songs in the database or the user may enter a few characters in the textbox and select "song title" or "artist" etc. from a dropdown to search for a specific song title or artist etc.. Hope you are following so far? Say for example the user presses submit after typing "!ALL" to return all the song titles - there could be hundreds of results. What I want to do now is display 10 results on a page, then on the next page another 10, etc. (like a real search engine!). I've tried doing it with the LIMIT statement, but like I said I'm new to this and discovered that that is not the right way of going about it. My question is this: how would I go about returning 10 matches per page? Do I use hidden form fields? What would the SELECT statement look like? What would the PHP scripting look like to setup the "back" and "forward" navigation between the result for the search?

MySQL Results To Return Only One Value
For example, I have a column that has three different values, 1, 2, & 3. In the database, there may be over 500+ entries with one of these values assigned to it. How can I get MySQL to return just 1, 2, & 3 only once rather than several hundred times.

Query In PHP Won't Return Results In There's Only 1
$sql = 'SELECT `PageTitle` '
$sql .= 'FROM `Pages` '
$sql .= 'WHERE `PageID` = 1 LIMIT 0, 30'

I have run this query in MySQL control panel and it works perfectly.
When I try to do it via PHP I get no results.

If I select all rows (i.e I don't specify a "WHERE") I get one fewer
rows returned than there actually are.

Building Array Of Difft Results For Return
I have 2 functions that I want to call from a subroutine, and then return their results; one result is an array, the other will be an array of arrays. The first will be the information about a product, $product, with values like $product['title'], product['id'], etc.

The second will be an array of arrays, each line of which contains information about an element of the product. I.e., $item[0]['title'], $item[2]['value'], etc. How would I best combine these so I can RETURN the total thing from the function, and then how would I refer to the parts in the calling code? For example, if I said Code:

Mysql Doesnt Return All Results Of A Query
I have an sql query like this:
SELECT column FROM table WHERE column1="3" AND column2="1"
This query works perfectly if i run it in the command line, to be
exactly it return two results.
But if i run it from php i just get the first of the two results.
Any ideas?

Mysql 4.1.8
php 5.0.3

I have a second problem. But its more of a question.
if i run the foreach loop on an array like this
array("id" => "78"), then it splits 78 up in 7 and 8.
Now you say its stupid to use a foreach for this array. But in the
function there i use it the array could also be two dimensional.
Is this behavior normal? I looked in the php manual but found nothing.

Return To The Previous Page In Php?
How to return to the previous page in php?

Paypal Page Return.
so, on my site, users are allowed to donate. When they donate (via paypal) they are directed back to the processing page. I use this:

if($_SERVER[HTTP_REFERER] != 'https://www.paypal.com/cgi-bin/webscr') {
echo "<center><b>Error.</b> ";

to check to see if they came from paypal, which prevents false donations / receiving the donation item multiple times with one payment.

BUT, It does not work . Is there any other way to secure that only one donation item is given?

Directing Server Php Return Page
How do I have the server-side php script open up a new client window, rather than having it return to the client page that invoked the php script in the first place? I want to preserve the original client page. Or if I could do it, better yet, is there a way to have the php script return to the
same window, but a new page, thereby preserving the original client page?

Return All Instances Of A String Within A Page...
I'm looking to do this, but is it possible?:

A page to be downloaded via file_get_contents which has stuff similar to
the following in :

<a href="file.php?name=Widget1">Widget1</a><br>
<a href="file.php?name=Widget2">Widget2</a><br>
<a href="file.php?name=Widget3">Widget3</a><br>
etc.

I would like to be able to create an array which contains all the strings
between <a href="file.php?name=Widget1"> and </a><br> (The link text)

so
<a href="file.php?name=Widget1">Widget1</a><br> => Widget1

So that $linktext[0] = Widget1, [1] = Widget2 etc.

Is this possible, if so, how?
I've looked at preg_match_all, but can't see how to output multiple matches
of text *between* two strings to an array.....

Function That Will Return The Url Of Every Page I Have In My Domain?
Is there a php function that will return the url of every page I have in my domain? I am creating a sitemap to send to google and I really don't want to have to copy and paste 500+ urls.

How Do I Setup Php Script To Return A Browser Page?
I want the server-side php script to return a browser page that is essentially a copy of the
original client page that contained the <form> which referenced the php script in the first place.
However, the php script will need to change a couple html lines in that returned page.

Having Different Results On Same Page
I have a database that I would like to use to display the contents in different lists on the same page. In other words, I would like a list of the latest 15 entries in the database to appear in list...then I would like the next 15 to appear on the same page but in a different list structure, etc. I have this so far, but it only displays the latest 15...I am stuck on how to get another list generated from the same query: Code:

Use Arrays To Page Through Results?
I've got a search facility that interrogates an SQL database then shows the results 30 at a time. Currently, when you go to the next page of results it has to run the query all over again, because there is no way of handing the resultset to the PHP file. So I wondered if there was another way of doing it.

I'm tempted to use mysql_fetch_array and create a multi-dimensional array full of result rows, then hand that around, but so far cannot find out how to hand a PHP array as a variable to a PHP page.

IS this possible, or am I barking up the wrong tree? Or is there a better way of doing this?

How Do I Make The Results Appear On The Same Page?
Presently i am calling a new file to accept my dropdownlist values. Is it possible to make it such that the results will just appear on the same page? Code:

PING Results On PHP Web Page!
Can someone show me sample code on how can I write a script that shows ping results on a web page.

Multi-page Results....
I'm working on an engine to search a MySQL database of a bunch of forum messages. The PHP code retrieves the results from the database, then stores them into an multi-dimensional array for processing.

Once stored, the code parses each result and assigns it a relevancy score, and once all of the results are scored, it then sorts all of the results according to relevance. The end product off all this is an array that holds all of the retrieved messages relevant to the search, holding such information as title, author, date, msgID, blah blah blah. now that i've kinda explained what's going on, i'll get into the problem i've bumped into.

Being that there's roughly 16,000 messages in the database (not to mention the 800,000 lines of message text) that could possibly be the results from a query, displaying it all on one page is most definately out of the question (it still takes a few seconds to load on my cable line with only a few hops to the T3'd server. I'd hate to see what a 33.6 or 56k user would be waiting for).

The real problem all comes down to: how am I going to pass the results from one page to the next? an array of a few thousand messages is a *little* large for an http post action, and storing the results in a table in the mysql database posses a few problems as well (namely, how long to keep the table around after the user has executed the search. temporary tables are out of the question, as they die as soon as the mysql connection is closed, but a persistent mysql connection would create exactly the opposite problem: ei, temp. tables never die).

10 Results Per Page But From Different Categories
I have a script that shows a list from a different category depending on what is in the URL. I've got it to limit the results to the 1st ten results and keep the chosen category in the link(?category=differentcategory) but when next page is clicked it repeats the same ten results. Code:

SQL Query - Results From Another PHP Page ?
Can I store this PHP code in another page, then refernece it on
multiple pages using Require or Include ???

//results from sql query
for ($i=0; $i<$number; $i++) {
$ID = mysql_result($result,$i,"ID");
$CompanyName = mysql_result($result,$i,"1");
$ContactName = mysql_result($result,$i,"2");
$Phone = mysql_result($result,$i,"3");
$HomePhone = mysql_result($result,$i,"4");
$MobilePhone = mysql_result($result,$i,"5");
$AltPhone = mysql_result($result,$i,"6");
$SecondContact = mysql_result($result,$i,"7");
$SecondPhone = mysql_result($result,$i,"8");
$ThirdContact = mysql_result($result,$i,"9");
$ThirdPhone = mysql_result($result,$i,"10");
$Notes = mysql_result($result,$i,"11")

Getting Other Webpage Results In To Php Page
I Have a page which will take authentication from a diffrent page from
a difrent website.

My program needs to call a page like this from php page lets say:
http://www.abc.com?handshake.jsp?us...htoken=94399843

my php page is at www.xyz.com
based on this url's response i need to print the result on my php page?

I tried this..

$url="http://120.126.79.21:6080/AutoPrintWeb/apvalidator.jsp?tempid=$tempid&authtoken=$authtoken&ipaddress=$rmtadd";
$fp = fopen($url, 'r');
$response1=stream_get_meta_data($fp);
print_r($response1);

The reukt is like this:

Array ( [wrapper_data] => Array ( [0] => HTTP/1.1 200 OK [1] => Server:
Apache-Coyote/1.1 [2] => Set-Cookie:
JSESSIONID=B55CA82D1790D6C0A9E20ED1CEDBB1B9; Path=/AutoPrintWeb [3] =>
Content-Type: text/html;charset=UTF-8 [4] => Content-Length: 382 [5] =>
Date: Fri, 10 Mar 2006 10:22:41 GMT [6] => Connection: close )
[wrapper_type] => http [stream_type] => tcp_socket [mode] => r+
[unread_bytes] => 382 [seekable] => [uri] =>
http://193.186.79.21:6080/AutoPrint...dress=127.0.0.1
[timed_out] => [blocked] => 1 [eof] => )

I need only sucesss or fail..

Limit Results To 20 Per Page.
I have a Database and script where it SELECT * FROM my database and lists the info on my website. I want to be able to limit the quary to only 20 per page. Here is an example of what i am talking about on this page http://sacvalleyhomes.com/Sacvalley/property_inquiry.php

Everything listed under Property Inquiry is genarated be my database. As it is now i have 5 diffrent tables for 5 diffrent pages. This is way to much work to keep updated.

What i want to do is put all 5 tables in to 1 table and have my php script only show the first 20 listing then generate the page numbers on the bottom or some way to view next 20 results and so on. Code:

Why Does My Page Always Show JUST First Set Of Results?
Whenever I execute a query I limit it to lets say 2 rows per page. The problem is my code will only say there is 1 page of results when there should be more! What am I doing wrong? Code:

Results Only X Number Per Page...
am doing a real state site and when searching it shows all the results from the database in one single webpage, can you help me with one easy way to show only 10 results per page?

I've seen some complicated sites with previous and next arrows, i only need to show 10 results then a link to show next 10 and that's it.

Limited Results Per Page
i have a download section for my site, with about 20 downloads, and i was wondering if their was a script so that it would only show 5, and clicking 'next' button would show the next 5 etc.

PHP / Microsoft SQL V7/2000 - Page Results
Anyone know a simple way to page results of a SQL Select using Microsoft SQL ? I don't believe they have anything as handy as MySQL LIMIT.

Search Form And Results Page
I have a table called "lista" into my mysql database.This table has 5 text columns : "TRANSLATEDTITLE" "ORIGINALTITLE" "ACTORS" "DIRECTOR" "YEAR" , and 1 image column called "COVER".

I want to create a page with a form to search entries into this table (ex. with Title, Actors, Director, Year), and anotger php page with the search results shown inside, everyone with a link that opens a pop window (ex. 400X320). Code:

Displaying X Number Of Results Per Page
What I need to do is this. I query a MySQL database and, for example, 400 results are returned. I can get it to display the number of results, but I would like to set a value to display, say 20, results per page and generate numbered links with and offset to browse through and next/previous buttons -not unlike this page. Can anyone point me in the direction of a good article or if you have it, post some code here?

Newbie Question: Results By Page
How do I make results that I select from my database on different pages
based on length?

For instance, say I have over 50 records with more being added and I want it
to display 10 records per page. How do I get that info to display only 10 at
a time instead everything all in one page?

Fetching Results Across Page Loads
I would like to find a way to execute a query against an MS SQL server
and return a small number of rows each page load. However, I cannot
read all the results in during the first page load due to size
contraints.

Here are the details. A user submits a request. I construct a SQL query
and execute on the MS SQL server. The query results in a million rows.
The initial page load shows the first 100 rows. Each successive page
load shows the next 100 rows. Because our web server has limited disk
space, I do not want to return the entire result set now, but only 100
rows at a time. Also, for performance reasons, I do not want to rerun
the query each page load.

So, I need a "persistent result" set that can be fetched from across
page loads. I have tried to store the result set in a session variable
using serialize and unserialize, but to no avail. It seems that across
page loads the result set loses its way, even with a persistent
database connection.

Page Navigation From Search Results
I have created a search form that searchs for results from my database matching the criteria to what ever the user inputs. I have done this using 2 php pages the first page points to the second, where the data is sanitised and cleaned accordingly. The results are displayed on the 2nd page. Code:

Displaying X Number Of MySQL Results Per Page
I'm writing a search on a MySQL DB, and everything so far has just gone swimmingly. I've got a "results per page" drop down box in my form, with a few different values.

At the moment, I'm just using:

while($myrow = mysql_fetch_array($result)

to output results to screen.

I'm not too sure how to go about it, but I did have two thoughts:

1) Suck the results into a multi-dimensional array, and pass the array to a display results script (not sure if you can pass arrays to other scripts???

2) Display x number of results, then have the "Next" (or 2, 3... ) links call the search again, but displaying results x+1 - x+x.

1 sounds like too much trouble, and 2 sounds inefficient. Not too sure how else to go about it. Any info / thoughts you guys have would be much appreciated.

On a side note, how do you look at a specific row in the result?

Limiting Results, And Display Page Numbers
How do I make it so only 50 items display per page. And if there's more than 50, it displays a link "page 2", "page 3" and so on? I know how to limit results with MySQL but how do I generate pages for the next 50 within the PHP code?

Link To Form Results Page Dynamically
I have a dropdown box that pulls information from a database. What I want to achieve is that when a caller selects an option, the option determines that page that comes up.

I tried setting the form action to the name of the option, but this down not bring up anything; actually the resulting page is .php. I also tried moving the form action statement after ther selection, but that does not work either - the Submit button does not work. PHP Code:

Search Results Showing An Include Page
I have a page index.php which includes different templates based on a passed URL variable through the include() function. My problem is that I have the files saved as temp.inc.php files. Search engines are returning the include page as a result and then the user is directed to a new window with just the include page displayed. Any ideas on how to get around this?

How To Pass Mysql Search Results From One Page To Another
I am creating a website that uses PHP to query a MySql database. upon supplying the PHP script with a given search string and search term, a list of scientific documents with attributes such as author, date, url and revision are returned. Each document also has a unique id number within the database. What I would like to do is create a system whereby user of the site can leave reviews for each particular document, much like the product review system employed at jungle.com. I have got to the stage where the php script outputs a list of results each separated by a horizontal rule and what i would like is to be able to place a button on each record marked submit review, which would then take the user to a form where he or she could leave a review which would placed into a reviews table in the database.

However my problem is that i do not understand how to pass the paper id automatically to the form such that the user does not have the inconvenience of having to type into the form. Does anyone have any ideas on how I could solve this problem?

Populating Form From Database, Then Passing Results To Next Page
I have a multiple select input in a form that's being populated by a row
from my database as such:
<input type="checkbox" name="subm[]" value="$row[ID]">

That part is working fine as I can check the displayed page using View
Source and see that the value is the correct row number from the
database. It is then being submitted on a form by $_POST method to
another page where I want to evaluate the checkboxes and display the
contents of the entire row that corresponds to each value="$row[ID]"
that have been checked. But I can't seem to get it to work. I'm having a
problem passing the selected value. Can someone point me in the right
direction?

$query = ("SELECT * FROM `table`");
$result = mysql_query($query);

print "<p>Data for Selections:";
print "<table border=2><tr><th>You chose:";

foreach ($_POST['subm'] as $value) {
print "<tr><td>";
print "$row[ID];
";
print mysql_field_name($result, 1) . ": " . $row[name]."<br>";
print mysql_field_name($result, 2) . ": " . $row[address]."<br>";
print mysql_field_name($result, 3) . ": " . $row[city]."<br>";
print "</td></tr>";
print "</table>
";
}

if (!isset($_POST['subm'])){
print "<p>No matching entry ";
}

mysql_close();

Search Brings Back Different Results Or Sometimes No Results
The problem Iv got is that when searching the site - it brings back different results or sometimes no results. For example: "i026", "i 026" and "026" do not bring back results for "I-026" which is the correct model number. Any ideas on how to make it search more variations or of a "Did you mean... I-026" script?

Search Results ($num_rows) Does Not Match $search Results (PHP,MySQL)?
For example, when I do a database search for a term I get 2 results but the $num_rows says there are 3 results.

I suspect it's because there are similar keywords within different search fields of the SQL statement. But I am stumped as to how I can change this. Any Suggestions? the code:

Return A Value
i got a functions and it echos out a result, the problme is if i make the functions into a string it still echos out the result at the spot where the string is at. Code:

Return 0
I have a little function that gets a result from a query when supplied arguments, it works great except when the result is 0. Here's the func : Code:

Return MAX Value From Array
I need to return the county with the greatest score with the following long query:

Class Does Not Return A Value
My first time working with a PHP class, and after 6 hours of working out the
kinks I am unable to return a value from the class, so now I appeal to the
general audience what on earth did I do wrong this time?

This is the code the retrieves the values:

What Can Return The ENTIRE Url?
I'm looking for PHP equivalent to Javascript's location.href property. This returns the ENTIRE url (including any variables that might be submitted to a script). I've looked at phpinfo(), but I didn't see exactly what I am after. If the answer is the HTTP_POST_VARS variable, could someone please give me a simple example of how exactly this variable is to be used in code?

Return Statement
What happens when you take the value returned by a function that
doesn't return a value? For example,

function myfunc($myvar) {
if ($myvar == "xyzzy")
return(1);

return;
}

$abc = myfunc("def");

I know from my days of c programming that this would be very bad to
do. But php gives you so rope I'm wondering if you could just do an
isset($abc) to see if myfunc returned a value.

If so then we could write (scary) code where on an error condition
instead of returning something like -1 you just don't return a value.

Return $$ From Function
How can I use the variables generated by the following function in my code? They're just not being passed to the main script. I've tried global $$k; bu that did nothing PHP Code:

Return Mail
I have Apache and PHP in a Linux server. I am using the mail() function from PHP to send mail in a webpage. How do I deal with returned mail? (eg. wrong address) How can I specify what address returned mail is sent to?

Return Row # With Each Array Value?
Does anyone know how to output an array from a MySQL query, but tack on an incremental value to the end of each variable that represents the row number? I'm looking for something like this:

// query stuff here
// Now I output the query result:
while ($fetch = mysql_fetch_array($result)) {
echo "&quoteBody(CURRENT ROW NUMBER)=".$fetch["quoteBody"]."&quoteDate(CURRENT ROW NUMBER)=".$fetch["quoteDate"]."&quoteWriter(CURRENT ROW NUMBER)=".$fetch["quoteWriter"]."";}

Of course the (CURRENT ROW NUMBER) references are what I'm looking for. The way I have it now, PHP outputs an ampersand-delimited string representing all fields in the database. Output looks like this now:

&quoteBody=This is the body of the quote&quoteDate=08/11/01&quoteWriter=Mike&

I'd like to find out how to make it look like this:

&quoteBody1=This is the body of the quote&quoteDate1=08/11/01&quoteWriter1=Mike&

You get the idea. Anyone know how to do this?

Return Variables
I have "index.php" that includes "func.php" (global functions) as well as "p_rand.php" (random product generator). I execute a function (of "func.php") from "p_rand.php" and assign the value to a variable I'll use to do statistics, but the value does not return to "p_rand.php".

I can print the value from "func.php", but when I try to return the value the script appears to stall and the page times-out. I need to get the value from a function in "func.php" back to "p_rand.php". Anyone have any ideas why this might happen, and how do I fix it?

About Return A Array
When I write this codes:

<?
function r_array(&$array){
for($i=1;$i<5;$i++) {
for($j=1;$j<5;$j++) {
$array[i][j] = "d";
}

}
}

r_array($array2);
print_r($array2);
echo $array[1][1];
?>

it display in the brower like this:

Array ( [i] =Array ( [j] =d ) )

And this means $array[1][1] can't be used. And what's the problem?

I want return a 2D array and use it like $array[1][1],what should I
do?


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