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




Navigating Database Results And Posting New Values


I am trying to dynamically display results that I retrieve from my database i.e. only 5 results per page and code should automatically compute how many pages it needs and create links for each page. I have also added a link at the top of my page so that if user wants to POST new data he can post it. Problem is that when I click on page 2 or 3 or any numbered page and click on POST link it gives me following error
"CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:

And it did not tell about any header etc. Code:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Navigating Database Results And Problem With Link
I am loading results from mysql database and displaying on my page and then dynamically displaying only 5 results per page. On each page I have a POST button so that if user wants to POST something on form he should be able to do it whether he is on page 5 or page 1. When I first time loads the results on page 1 this POST button works fine but when I go to page 2 and click on POST it gives following error

"
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:
"
and then even if I go back on page1 it starts giving me same error.

Navigating Multiple Results?
Hi all, whats the best way to navaiagte multiple page of results.

<Previous 1 2 3 4 Next>

What SQL is needed to do a limit that starts in the middle of a returned set.

SELECT * FROM table LIMIT BETWEEN 20 TO 50;

Posting Search Results
i am a bit stuck on this part of coding, when people search ALL categories i leave the option value as: <option value="0"> so if 0 is passed to the GET all categories should be searched instead of just category 1,2 or 3 etc Code:

Posting Form List Multiple Values ?
how to get the values using post from a multiple list form when more than one value is selected ?.. is it possible ?

Curl: Posting Form Variables Results In Redirection
I'm using the curl functions in php to scrape the wan ip address from my
home router (the router is an SMC product). This is a two step process:
1. post the password value to the login.htm page
2. capture and parse the content from the status_main.htm page

On the SMC's login.htm page there is a form with the following elements:
<form name=tF method=post action=login.htm>
<input type=password name=pws>
<input type=hidden name=page value=login>
<submit value='LOGIN'>

Here are three test cases - only the first two work as expected. I need to
understand why I got that third response... posting the variables causes a
the SMC to give me a redirection to index.htm which does not exist?

COMMAND LINE TEST (returns login.htm and status_main.htm accurately):
curl -d page=login.htm -d pws=mypassword http://10.10.10.1/login.htm
curl http://10.10.10.1/status_main.htm | grep 'wan_ip'

PHP NO-POST TEST(returns login.htm accurately):
$ch = curl_init("http://10.10.10.1/login.htm");
$strIP = curl_exec($ch);
curl_close($ch);

PHP POST TEST (returns an unexpected result):
$ch = curl_init("http://10.10.10.1/login.htm");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "page=login&pws=mypassword");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$strIP = curl_exec($ch);
curl_close($ch);
print "<!-- $strIP -->";

<!-- <html><head><meta http-equiv=refresh content=&#390;
url=/index.htm'></head></html> -->

Comparing User Input Values In A Form With Database Values
I want to compare user input values in a form with my database.
Basically I want to check whether the user exits in my database.
What mysql command can do that?

Posting To A Database.
I'm currently developing a website that includes an online registration form using PHP.  I'm having trouble getting the script to post the value of a check box to the database.  I have succesfully managed to post the values of the text boxes to the database but can't figure out how to post the value of the check boxes.

Data Not Posting To My Database Php/mysql
I am having a problem postion data from my form into my database. My users visit my site and fill out a form which is suppose to go into my mysql. I check phpMyAdmin to see if the data got there but nothing. Below is my Code. could someone help me out. Code:

User Info Not Posting To Database
I am trying to figure out why my script isn't updating the information of the user names stored in the database. Can anyone give me the solution?
Below is the script: Code:

Adding Values In One Column From Query Results
I have this query:

SELECT *,
sum(field_value) as totalValue
FROM table_name
WHERE field_id = $id
GROUP BY field_group

the data type of field value is a decimal value, with values such as 125.00 and 150.50 stored in each record. My goal is to have totalValue be the total value of those numbers. So if I have two records that equal 125.00 and 150.50 totalValue would = 175.50.

the above query does not do this. What do I need to change here? Should I try to do this from the PHP side?

Navigating An Array
let's say you have a numeric indexed array with 30 elements. Now let's say you want to only output elements 10 thru 20. Is this possible?

Navigating Between Pages Of Array Contents
I didn't know how else to name this thread...but what I am trying to do is echo out the data in my database so that there are only 9 entries per page.

At the moment, all I have been able to do is show the next 9 rows of data on a page, then assign all the other rows of data into a new array, which i would then pass to the next page in a cookie and start over again using the new array. As well as being sloppy coding, this is at a disadvantage because you can only every go to the 'next page'. You cannot navigate to the previous page unless you click back (and that won't always work) and you can't navigate directly to any page.

I think what I could perhaps do is take my original array, and split it into individual arrays of 9 rows, and then store each of these in a session. This is still at the disadvantage that it will only work if you go to page 1 first - people won't be able to link to a different page.

What would be the best method of being able to navigate through the varying pages of data? And as I have never used sessions before, could somebody please show me how to get started, or at least link me to something that is easy to understand.

Thanks!

Retrieving Values From The Database
I am retrieving a value from the database and I insert the value as a value of a field
The problem is that when the value has spaces then in the filed is viewed only the part of the value before the first space. If the value is not includes any spaces then the value appears in the field correct.

Addition Of Values In Database
In my database I have two products. Each product is made up of components. This is the product table: Code:

Getting Results From MySQL Database In PHP
I am trying to write a php page which connects to a MySQL
Database which is supposed to get the results from a table within a
database and display the results in a table.

Below is the code that I am using:

Database Search Results
i have a paid to read website,im hosting it off my own pc..as a member you can search offers and complete them, heres where i need some help..when a member clicks submit and the offer goes to an offerdone table i need the offer to hide from them so they cant do it again,also that same offer needs to hide in the search results as well...is there somthing like onclick hide and for the results something like if duplicate hide from search or if offer found in this table hide from results...

there are 2 tables one will all my offers the other with offer they have done,also this needs to apply for each member account.i am new to all this and have made it this far to have my site up and going but im looking for those extra catchs i could really use,so that a member cant repeat an offer they have already done,

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)

Inserting Values Into Database Using Arrays
I'm trying to insert the database the answers to a question and to get the user to select the correct answer. PHP Code:

Unable To Insert All My Values Into The Database
I have an error in my code because its not inserting my $_session['identity']  into the database. I know the session has a value because I am able to display it on the page. it just wont insert it into the database. Code:

Droplists/database Values/sessions
I have many droplists that are populated with the values "open" and "closed". This one is called drop31. As with all of the droplists, which value is default is dependent on which value is currently stored in the db under "Lot31": Code:

Increasing Certain Values In MySQL Database
Each post in my announcement section has an IndexNo . . . so far I've had to do enter that automatically. How do I rig something up so that php will extract the most recent (or last entered) news post's IndexNo and increase it? The IndexNo is stored as an integer so increasing it is no worry . . . my real problem is how do I tell mySQL to give me the most recently posted news article?

Calculating Against SQL Database, Returing Values
I was interested in trying to calculate against an SQL Table and return values that matched within the calculation. What i am trying to put together is a Zip Code Locator. I have a table "AREA" of Lat, Long and Zip Code numbers for the area im interested in. I also have a table "LOCATIONS" of Lat, Long and Zip code numbers for 25 different locations with data about Store Name, Address, etc.

What i would like to do is have a user input thier Zip code and that would launch one query, which would pull down the Lat & Long from the table "AREA".  I would like to then Query the database "LOCATIONS" and calculate the distance between them using a formula. So it would do this.

User submit--->$_POST['zip'];---->Query and bring down LAT, LON from "AREA" table--->Query the LOCATIONS table, bring down all values---->calculate LAT, LON, from AREA table minus LAT, LON from the LOCATIONS table and populate to Variables the values that were LESS THAN 5 or something.

Having Trouble Alphabetizing Results From A My SQL Database
I'm a beginner and I'm having trouble figuring out the sort command (assuming that's what I'll need to alphabetize my results from a database.) Any helpful input is welcome.

Grouping Database Results In Pagination
I'm dealing with a situation where I can potentially have over 3000
results to display from a database. I'm successfully paginating the
results, 10 at a time, but don't want to display 300+ page links at the
bottom.

How can I group the pages to show, for example, the first 10 pages,
followed by a "next 10" link?

i.e., Page: 1 2 3 4 5 6 7 8 9 10 > >> Next 10

My current code:

Sorting Database Query Results
I want to know if it is possible to sort query results so that the records with a value in a certain field is displayed first and the records with the field empty thereafter.

Showing Image With Database Results
I am trying to retrieve data from a MySQL database and have got it working. Only thing is I would also like to display an image for each row. Each record has a file number and the images are all saved in an image folder and are named with the actual file number.

EG there is a record with file number 1111 and there is an image called 1111.gif in the images folder. I have included my code below. If someone can tell me how to include some html code to show the image in my php code. Code:

Problem Retrieving Results From Database
I'm trying to retrieve fields from my database with following mysql
statement:

$query = SELECT g_games.Title FROM g_collections, g_personal_reviews,
g_games WHERE (g_games.ID=g_personal_reviews.G_ID AND
g_collections.U_ID = '" . $data1['ID'] . "' AND g_personal_reviews.C_ID
= '" . $data2['ID'] . "' ) ";
$resultset = mysql_query($query);
$data = mysql_fetch_array($resultset);

3 Rows in my database comply with the above statement... though I only
get 1 to show up on my php page? How can I show all of them?

This is the php code I'm using to write the results:

while ($data= mysql_fetch_array($resultset))
{
echo $data[Title]." ";
}

My tables are as followed:
g_games
g_collections
g_personal_reviews > this table connects all others with G_ID ("game
ID"), C_ID ("Collection_ID"), U_ID ("User ID)...
users

Putting Database Results In A 5x1 Table
I have a db of tens of thousands of entries. It's not too hard to pull
all the entries and build a table that displays them one at a time, but
in my case, that will be a huge waste of space. What I want to do is
put one record in each of the columns. I thinks it's possible to do
because I have seen very elaborate thumbnail gallery scripts to do this.
I just want to be able to put two or three strings of text from each
record into each row, and a checkbox. Here's sample of what I mean:

<table width="76%" border="1" cellspacing="1" cellpadding="1">
<tr>
<td>$record1Line1<br>$record1$Line2<br>
<input type="checkbox" name="$record1checkbox" value="checkbox"></td>
<td>$record2Line1<br>$record2$Line2<br>
<input type="checkbox" name="$record2checkbox" value="checkbox"></td>
<td>$record3Line1<br>$record3$Line2<br>
<input type="checkbox" name="$record3checkbox" value="checkbox"></td>
<td>$record4Line1<br>$record4$Line2<br>
<input type="checkbox" name="$record3checkbox" value="checkbox"></td>
<td>$record5Line1<br>$record5$Line2<br>
<input type="checkbox" name="$record5checkbox" value="checkbox"></td>
</tr>
</table>

I want to pull about 200 records at a time from the db and display as
described above. How can I tell php to take five records from my result
set and display above, then loop through the result set until I'm done?

Filtering Results By DATE Value In Database
I have this code in my page for displaying some data from a database, sorted by date. i had posted a messed up version of this a while ago but I couldnt get it working even after a few suggestions. PHP Code:

Populating A Drop Box With Results From Database
I have a MySQL database with a table (category) with two fields, catId (int) and category (char(50)). What I want to do is to get all category names in this database and place all of them into a dropdown box on a web page so that the user can choose from the list of available categories.

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:

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:

Counting Results From A Mysql Database
I want to know how many results throw a query in order to know if they have reached a limit.I.E.

$sql = mysql_query ("select * from classifieds where user='$username'");
while ($row = mysql_fetch_array($sql)){}

I want to check lets say that only 10 classifieds per  'username' can be created. If ten or more classifieds are in the database for that 'username' then show error message.

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?

Population Select Menu Using Php And Database Values
I have no idea how to go about this. so i would apreciate some help i want to populate the values in a html select menu from database values in one table

so i want all the values from 1 particular field in the database to be displayed in the select menu as separate options.

Looping Database Values To Create An Array
I have a fairly simple php code problem I think, I want to loop values from a mysql database within an array to fill the array. I'v never done this before so your help would be valued if someone had the time.

*denotes where I want to use database values*

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

The code is:-

POST To Mysql Database And Email Results?
I have a simple html form that POSTs to a mysql database. Can I, and if so, how can I, have it post to the mysql database, and email the form results too.

I also have some other html forms that just mail() the results. So I can do both things separately, but I'm not sure how to combine them.


Double Quoted Values From Database Won't Show Up In Form
I enter user input from a form into a mysql database using addslashes. When I access values with a double quote from the database they won't show up in a text form field as the default value. I use stripslashes when accessing database values, magic_quotes_gpc is on, magic_quotes_runtime is off, magic_quotes_sybase is off.

Download Database Search Results As Text File?
Can someone please tell me how to query a database and then download results as a text file.

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();

Querying Mysql Database Based On Values From Html Form
I want to build a simple form for querying database having business organization info. The form has four fields name, category, city and state. Users should be able to search based on any of these fields. Code:

Sort Results By Date/time, Limit 5 Database Entries Of Today &/or Upcoming Days
I'm designing a website for my fraternity and in the database I have entries which contain past events, todays events, and upcoming events.  My problem is that I can not figure out how to sort the query results to display:
 
1) only past events based on the CURRENT DATE
2) only the events which fall on the CURRENT DATE or after, limiting the results to 5 entries
3) all events that fall on CURRENT DATE or afterwards

Example:   
Today is  September 15, 2007

Problem 1) Displaying all events that happened before September 15, 2007
Problem 2) Displaying only 5 results that fall on September 15, 2007 or after
Problem 3) Displaying all events that are happening on or after September 15, 2007

And obviously I would like the CURRENT DATE to change depending on what date it is, currently.

Ok so now I've been very redundant in my explanation of my problem here is the code and a link to what that particular page looks like. Code:

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?

Adding New Values To An Array That Already Contains Values..
is it possible to append new values to an array that already has values in it??

say, i have my existing array;

existing array;
$array = array([66314] => 66314 , [66315] => 66315) ;

then , when i check my checkbox on my next page, the ids should be appended to the $array:

array that needs to be added to the $array;

$array = array([66316] => 66316,[66317] => 66317,[66318] => 66318);

how should it be done??

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:

URL Posting
I just need some direction as to a function that can help with this particular situation:
I would like to create a script that acts like a browser and simply goes to a specific web (ie: http://www.whatever.com) address on a regular schedule (ie: 100 times a day).
Any functions that emulate a web browser?

Posting With &amp;
Our database stores the & symbol as &amp; I have a select menu that
queries the database based on the selection. A sample selection:

<option value="Cats &amp; Dogs">Cats & Dogs</option>

After I click on Submit, the value gets posted as "Cats & Dogs." How
can I keep it just "Cats &amp; Dogs"

IP Posting
Is there a convenient variable for the server's IP? I was thinking of trying to have my wget crontab also post up a page that displays the server's (dynamic) IP, so I could access the box from school.


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