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




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




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Retrieving,Sorting & Displaying Multiple Results From Mutliple Tables
I need to know how to run a php / mysql query to do the following.

I have 1 database (lets call it "database" for now) within this database there are multiple tables ("News","Feature","Header_feature")

For NEWS I need only the 6 latest results pulled from that table and displayed in a table.  The "News" table has the following columns "ID","Title","Date","Body","Image"

For Feature I need only 1 result retrieved from the database and displayed under the variable $ticker as it will display as a scrolling marquee within a table.  The "Feature" table has the following columns "ID","Ticker".

For Header_feature I need only 1 result retrieved from the database and displayed in the following manner <a href="$link"><img src"$header_feature">[/url]  The "Header_feature table has the following columns "ID","image","link"

How would I code this all into 1 page?  I cant seem to get the query to do everything I want it to and display the results properly.  You can see what I have so far at www.getlivemedia.com  The $ticker is the scrolling text near the top of the page and the news is obviously the bulk of the page and $feature_image is the broken image.

Retrieving Database
User choose on ID and submit.

I use the URL query method to get the ID and rest of the profile like first_name, last_name,
I tried something like this

$query = "SELECT * FROM user where user_id= $ID";
echo $_get['first_name'];

but it doesnt show, how come?

Problems With Retrieving Url From Database
I am having problems with retreiving the url of the avatar that the user chose, which is stored in a database, and then diplaying it as an image. I have no prob's with the query:

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.

Retrieving Info From A Database
I would like the code below to fetch and display in an html table the Ad_Id, Date, and Type_Job fields from the 1st 10 rows of a table called employment. I'd like the results to be sorted first by date and then by the Ad_Id #. I have replaced my username and password with "user" and "password". Currently, the script returns the error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

Also, the script is ignoring the css info that I have supplied. Code:

Dates In Database + Retrieving
What is the best way to store dates into database so the data can be retrieved later on.

For example: I use this to get the date and i store it.

<?php
$date = date('d/m/y');
?>

However, if i wanted it to say '20 March 2007' would this be easy or is there a better way to store them.

Retrieving PDF/MSWord Files From Database
I am able to upload .pdf and .doc files into the MySQL database (using Medium
Blob) but I can't retrieve or download them back. Can you help me download them?

What I did was the following pages (downloadpage.php and downloader.php):

Retrieving (Data + Fieldnames) From Database To Array?
I'd like to poll a database and get the table contents, as well as the field
names from that table. I've been to php.net but this time I cannot find
something helpful.

I can get the data, and retrieve it into an array noproblem. [1]

I can get the data+fieldnames and put it into a list. [2]

But I cannot seem to be able to fill an array with the data *and* the
fieldnames. If you check both chunks of code, you will se what I'm doing....

Retrieving Database Info Based On User
I'm still quite new to php and mysql but I have been unable to figure this out.  I'm attempting to display a specific row and column from a mysql database based on the user.

$result = mysql_query("SELECT fbleague FROM users WHERE username = $_SESSION[username]");
fbleague is the column
users is the table
username is the primary key column
$_SESSION[username] is the username variable

Then later I try to display it with

echo "You are in league $result ";

I know $_SESSION[username] is set correctly because I can display that with no problems. 

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,

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:

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?

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:-

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 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:

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.


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

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?

Retrieving HTML
I was working on php script that could pull content from another site, and post it on mine. Some of the HTML from the site is not needed and I would like to remove it. How would I remove some of the HTML but keep that part that I need?

Retrieving NT User ID
Does anyone know how to retrieve the NT user id that someone is logged in as?

System is running IIS. Have tried HTTP_AUTHENTICATION but that doesnt appear to work under MS - unless someone knows a works around.

Alternatively - how can I retrieve a UNC pathname for a specific drive mapping.

Retrieving Records With Between
I am trying to convert my asp website to php. So far so good, but I am having a problem with my SQL Statement that needs to us the Between. Here is what I am using:

$sql = "Select * From tblTrack Where DateEntered Between $start and $end";

the vars start and end come from the same form. I don't have a problem when I hard code the dates, but when I use the variables, it won't retrieve anything.

Retrieving URL's
I'm assembling a search spider, and codes from other search scripts look way to hard to understand, so I'm assembling one right now. My question is, could someone show me a very brief example, of how to get all the URLS into an array. Then I just use for() or foreach(), but then I need to know the function to get the file size in kb. How would you do that if you were to use a directory?

Retrieving Full Url?
Is there any way to pull from a variable of some sort the full address in the browser. Including any get variables currently there?...

I ask because I have a number of different things, filters and such that should be compounded on each other. example. user has selected to filter a page by some field, user name or whatever depending on the data, then they choose to delete a record... etc. there are many uses i see, very possible with a lot of tweaking, but i thought there might be an easier way.

Retrieving InnerXML In PHP DOM
I'm trying to return the inner XML from a DOM element, but I can't find
any methods that allow this.
For example, if I have a string:
<TEXT>Here is a string with <B>bold</B> text in it</TEXT>
then I want to return the enclosed string _including_ the <B> tags:
"Here is a string with <B>bold</B> text in it"

Using get_content strips out the tags.
"Here is a string with bold text in it"

Retrieving A Zip File
I'm doing a sort of download center. Where the user fills out their details and then chooses the program they would like to download and the information is then entered ito a log file. So all this information is fed into a send.php file. What I'm looking is for the send to go to a thank you page and get the file that the user has requested. Code:

Retrieving Information From URL
I want to make it easier for a user to get to a comment on my page and to be able to go directly to that comment when it is typed into the URL.

For example, instead of this:  http://www.mysite.com/comments.php?id=1
I want them to be able to do this:  http://www.mysite.com/1

I am just wondering how to retrieve the "1" from the url instead of having to type id=1 and store it into a variable.

I know that the second one is pointing to my homepage instead of comments.php, and thats fine. I am just going to redirect to the other page or include the other page after I retrieve the "1".

Retrieving Max Numeric Value.
I can't see anything wrong with this code at all. Trying to retreive the last(highest) id from the text_id column which is auto-increment and primary key.

The conncetion to the DB is fine and working. It appears that the result isn't being drawn though... any ideas? Code:

Retrieving Field From Mysql With Php
I want to select as in the code, an email matching a username, and after I want to make a variable called $email_a to send to this user an email. What is the way to retrieve the email address from the database and insert it into the variable?

$query = "SELECT email from users WHERE username = '$username'";

mysql_select_db($db_name);

$result = mysql_query($query, $connection) or die ("Error in query: $query. " . mysql_error());

Retrieving Mail Attachments
I would like to retrieve mail attachments but am clueless as to where to start.

Retrieving Cookies (Opera)
I have a script which sets a cookie which is a history of Mysql queries a person has tried. My problem is that when I run a query 'show tables' when I retrieve that value from a cookie it is stored as 'show=' instead of 'show tables'. This only happens in Opera. Everything is fine in IE and Netscape.The script is in Python but I am hoping someone using PHP has had a similar problem.

Retrieving The CLient IP With Php4.2
I am runing php 4.2 on an apache server. I'v tried several things in order to get the ip address of my visitors, the problem is none of them work. I'v looked over the phpinfo() output several times and found nothing that would provide me with that info also I tried several examples using getenv() and none of them seemed to work. I remeber doing this easily with older versions of php. What changed?

Retrieving A Value From An <a Href...?my_value>
Anyone know how a php program can retrieve the following value?

<a href="http://myurl/my.php?COMBO_SUBJECT=J&COMBO_LANG=ENG">

Retrieving NT Logon Name For PHP Authentication
I am in the process of developing an web-based helpdesk system for our Intranet, I would like it if the user did not have to logon to the helpdesk system, but was automatically logged in using the username they logged onto the network with.

I'm pretty sure this is possible with PHP, but just haven't discovered how for our setup. Running Apache w/PHP (not our NT server), users use both Win95 and 2k.

Retrieving Hyperlinks From Access
does anybody know a simple way of retrieving a hyperlink from an acces
table. After retiving the data array with odbc_fetch_into()the hyperlink
is returned as "hyperlink name#..path of document#.
maybe sombody has already solved the problem and can save me hours of
programing.

Retrieving An Image If Condition Not Met
I'm sure the answer is simple, but the solution is eluding me-I'm
not too good at the particulars of scripting. Maybe someone can point
me on the right path...

Here is the problem:

I have a string of php code that retrieves an image, in this case, an
image of a book cover from Amazon.com. This works perfectly well,
unless, there isn't an image of the book on Amazon's server. When
there's no image, a blank hole appears on the final page. What I
would like to happen is, if the variable for the image isn't met
(i.e. no book cover image), a "No Image" image, from my server,
will load in its place.

Here is the code that retrieves the image:

<img border="0" src=<? echo $i['ImageUrlSmall'];?>>

Is there a way to include a command that will retrieve an image from
http://www.mysite.com/images/noimage.gif if the first condition is not
met?

Retrieving Form Data.
I have two scripts - common.php and edit.php. The working is that common.php contains a form that is used initially for registration and later used again so that registered users can edit their information. edit.php contains the connection to the db to update the form with the current users information. PHP Code:

Retrieving An Object From An Array
I have an array of objects, and I would like to retreive one of the
objects based on a given key and value (ie. name='john'). Is this
possible and if so what is the syntax?




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