Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MYSQL






SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Display Results Within Results


1) I have already did a search for: "Results within results" on this site, in PHP & MySQL forums ( I think) properly...and one search resulted in over 100 pages etc.

From the below structure of my DB, I would like to get the code from the below URL working on my existing data I have, but I am having trouble and I am just getting flustered....

I would eventually like to have the user "select" first a $State and then $County from a "drop down" for now, and eventually a "map" but the "drop down" for these (2) will be a must have....but I am just trying to use this function first.

At present, I am unable to even get proper printed results, and I know it has to do with something on the variable call end that is screwing me up.

2) This is what I am using (learning) from:

3) This is my mySQL db structure: ....




View Complete Forum Thread with Replies
Sponsored Links:

Related Messages:
Display Results From A Column In A Row
I am using php/MySQL 4.0 .. tried using GROUP_CONCAT, but it would not work ... perhaps not supported in MySQL 4.0?

If I had a table consisting of:

player l code l amount
-------------------------------------
playerA l 1 l 5
playerA l 2 l 6
playerA l 3 l 4
playerB l 5 l 10
playerC l 3 l 4
playerC l 4 l 3

SELECT player, code, SUM(amount) as amt FROM table GROUP BY player

How would I get the result below?

playerA 1,2,3 15
playerB 5 10
playerC 3,4 7

View Replies !   View Related
Looping Through Results - Different Display For The First 3?
I have a simple news database table (id,title,body,date)

There is a page I've created which should show the first 3 recent articles in full and then only links to the others.

what is the neatest way to do this ? (php/mysql)

View Replies !   View Related
Display Results Even When NULL
Code:
SELECT
*
FROM
calendar_types,
calendar_allowances
WHERE
calendar_allowances.user = 'user'
AND
calendar_types.id = calendar_allow.type

View Replies !   View Related
LIMIT :: Display Remaining Results
how to display the remaining result using LIMIT function

ex. SELECT * FROM tbl1 WHERE title = 'field1' LIMIT 10

now the query will display only 10 retrieved records but what if found 20 records, that is my problem... how to display it.

View Replies !   View Related
Display Results From Multiple Rows In One Row
Let's say I have the following tables:

Musician
- id
- name

Instrument
- id
- name

Musician_instrument
- musician_id
- instrument_id

A musician can have more than one instrument.

If I query all the instruments from a specific musician: ....

View Replies !   View Related
Display All Results Vs Spliting Up Over Number Of Pages
I have built a site for a local auction house. Each auction has around 2000 lots, which are held in the table auction_items with references to another 3 tables.

I am trying to work out the best way of displaying all of the items for a given auction, whilst optimising performance.

Each site visitor typically wants to see all of the items in the list and wants the option to "show all" items in a single view.

From past hits we estimate approximately 700 hits a day, most of which will want to view the list of items.

Are there performance benefits to be gained from displaying the results 20 to a page and having the users scroll through? Rather than loading the full list once per user?

From a usability point of view they would be better off with one list that they can see "at a glance" and print.

View Replies !   View Related
Add Up Results
Not sure if I should ask this in PHP forum or this one?
I think this is a simple request. I have a table with names and dollar amounts of pledges. What I need to do is grab all the amounts for the same person and then add it up to a total amount that they owe.
ie: Table is like this.
Don $500
Joe $100
Don $1250
Don $1250
Fred $300
I need to pull all the info that are for Don and then add up the amounts, for example this one Don owes a total of $3000.

View Replies !   View Related
All Results
Anyone know how to Get all results not starting with a letter?



View Replies !   View Related
Getting Results
i use mysql 4.0.22 which means i cant use subquery's right?
Ive tried using them but it dident go well.
This is what im trying to accomplish

SELECT service FROM rate WHERE type = 'as'

service must be equal to se
SELECT se FROM autosurf where st = 0

View Replies !   View Related
Different Results
I have a nightmare of a problem, where in a Query I am attempting to calculate percentages. I had the query running on an earlier version of mysql and it worked fine, and it is now running on the latest version and doesn't return the correct value.

This is the query : Select DISTINCT std.student_f_name, std.student_m_name, std.student_l_name, lt.time_from, lt.time_to,
lt.day, TIME(rda.clockinTime),
cast(($variable1/$variable2)*100 as decimal(3,2))
from students std, record_attendance rda, lecture_times lt
where std.studentID = ?
AND rda.studentID = std.studentID
AND rda.lectureTime = lt.id
AND lt.id=?

This correctly returned 33.3 percent in the older version, however in the new version returns 9.9 %. Does anyone know how this can be fixed?

View Replies !   View Related
Multiple Results
I'm using PHP to display a list of statistic information about a
site. Sometimes I need to retrieve mixed information from the
database but I don't know which is the best method to do it.
For example I need the top requested html pages and the most
repeated value from a column. I dont know if I should make two
different queries in the php file or it's more efficient to make
only one query with an extra column like

id | ip | date | page | max |
--------+--------------+----------+----------+---------|
1 + 24.125.24.25 + 24/5/03 + index + 3 |
2 + 24.125.24.25 + 24/5/03 + top + 3 |
3 + 20.12.12.21 + 24/5/03 + index + 3 |
4 + 200.12.24.25 + 24/5/03 + left + 3 |
5 + 24.1.6.255 + 24/5/03 + left + 3 |
6 + 24.125.24.12 + 24/5/03 + index + 3 |

View Replies !   View Related
Displaying SQL Results
I have made a database with all different things (venue, team names etc), the team names display fine, but I am using different code for venues (counting) and these just won't display at all, I am really new to SQL so don't know what to do to fix it!

The code for getting the SQL is

$sql = 'select venue,count(venue) as frequency from matches group by venue limit 300';

which works fine in phpMyAdmin and displays what I want to, but I don't know how to display it on my page! I do have the sql connection info in the php page too, plus the code which is used for displaying all my other pages but doesn't want to work now! I would like a table with headers of Venue & Number if possible, then the venues and number next to them, as it displays in phpMyAdmin

View Replies !   View Related
Matching Results
Suppose you have two tables: A and B. Both tables have the same columns: col1, col2, col3, etc.
So my records are distributed in two different tables that have the same format. I know, this is not good normalization design, but that is the way they are setup right now.
The question is: how do I query both in a single sql statement, combine the results of the query get all the records from both, and list the result in alphabetical order?
I can do:

select * from A ORDER BY status;

and I can also run:

select * from B ORDER BY status;

But how do I run both at the same time and get a single output from them?

View Replies !   View Related
Count Results
does there exist a less resource intensive way on how to count the results of a query? I mean I know that way: Doing a query on mysql and then using mysql_num_rows for fetching the amount of results, but I guess there should be an easyer way, that probably uses a mySQL syntax for that? Probably COUNT()? I read through the explanation of it and believe this could be the way how to do, but I can´t figure out how exactly the syntax would look alike

View Replies !   View Related
Mysql Results
What i'm trying to do is count is say I ran this sql query - SELECT DISTINCTROW length FROM list - it would show only one of each result (if there were rows with duplicate lengths). Is there a query which I could do that would also count how many duplicates there were if any

View Replies !   View Related
Counting Results
i'm trying to find a way of counting the results in a mysql table. Say I have the fields
CAR_MAKE | CAR_MODEL | COLOUR |
Is there are way of saying
car_make=bmw
car_model=z3
colour=black
how many of these are there im my table

View Replies !   View Related
Results In Error
I'm trying to create a MySQL database using PHP with the following command: $create = mysql_query("CREATE DATABASE IF NOT EXISTS moviesite") or die(mysql_error());

This results in the following error: Access denied for user 'bp5am'@'%' to database 'moviesite'
* I am able to connect to the database using: mysql_connect
* I am able to create that very database manually using dos
* Apache loads files as it should
* PHP is parsed correctly

View Replies !   View Related
Getting NULL For Results
SELECT DATEDIFF('date_hired,'date_fired') from users

and i get all NULL for results

i think i should be getting number of days apart from the two dates


date_hired and date_fired are both date columns

so whats wrong with this

View Replies !   View Related
Getting Results From 3 Tables
I have three tables: Person with key nId plus other fields, volchar with fields nVolCharId, nId, nActivityNum and activitynames with two fields nActivityNum and txtActivityName.
One person can be signed up for many activity so I want my output to look like: LastName, FirstName, etc plus a list of txtActivityNames (eg. Smith, Bob (activities: golf, swimming, basketball)).
Is there a way to structure a query to get those kind of results so they can be displayed in table form?

View Replies !   View Related
Getting Search Results
I have a table of posts which contains parent post and replies (structure below). I am having difficulty returning search results from this. What I want to do it search all rows title and body fields for matches, however I only want to return a rows parent in the results regardless of weather the parent contains the search term or not.

What I can't figure out how to do is remove child rows from the search results while also getting the parent row if it does not contain the search term.Structure:

id
parent_id -> is 0 if post is the parent
user_id
title
body

I am also joining the results to the users table so that I can display the username associated with the post in the results.

View Replies !   View Related
Getting Specific Results
my db looks like this:

username - skill1 - skill2 - skill3
John - warrior - thief - warrior

How can i only output the fields that are warrior?

Ive tried this but it dident work:

SELECT skillsM1, skillsM2, skillsM3 FROM ugd HAVING skillsM1 AND skillsM2 AND skillsM3 = 'warrior'

Or is it necesary for me to change my db structure?

View Replies !   View Related
Group By Results In One Row
Take the following data

Code:

date | type
2005-04-02 | soft
2005-04-02 | soft
2005-04-02 | click
2005-04-02 | click
2005-04-03 | soft
2005-04-03 | soft
2005-04-03 | click
2005-04-03 | click

Code:

select count(*) as total, type, date from tbl group by type, date

which would give me

Code:

total | type | date
2 soft 2005-04-02
2 click 2005-04-02
2 soft 2005-04-03
2 click 2005-04-03

I was wondering if there was a way,perhaps with a join, to get the data into the same row?

Code:

totalsoft | totalclick | date
2 2 2005-04-02

View Replies !   View Related
Order These Results
Lets say i have the following table (1 field):

1
1
1
2
3
3
3
3
4
4

So there's 3 1's 1 2's 4 3'd and 2 4's
I want it to display the items like this

3
14
2

(the one with the most elements on top and so on)
Is it possible to do it in a query or do i need some code to count one by one ?

View Replies !   View Related
Results W/ A LIMIT BY
I have a table where I need to pull out the 5 latest records only. There is an INT 10 field called category. I only want one record from each of the following items in category (1,3,4,5,7). I can't do a Distinct because the other fields are not distinct. If I do a LIMIT BY, I can't guarantee that I'll have one of each. How do I get out the data?Here is my not working query:

SELECT username, title, category, price
FROM mister
WHERE category IN(1,3,4,5,7)
ORDER BY laststamp DESC
LIMIT 5

View Replies !   View Related
Round The Results
In another thread I got this query to work, but it comes up with 32.0513. How can I get it to round to the nearest whole number? This is the query:

PHP Code:

<?php global $database; $sql = "SELECT (100*SUM(c.cb_paiddues=1)/SUM(c.cb_paiddues =0)) as total_value 
from #__comprofiler as c 
left JOIN #__users as  u on c.user_id = u.id 
WHERE (u.usertype != 'Super Administrator') and (u.block = 0) 
and (u.username != 'guest') "; 
$database->setQuery($sql); 
$row = $database-> loadObjectList(); 
return $row[0]->total_value; 
?>

View Replies !   View Related
How Do I Limit Results?
How do i limit results?

I try using LIMIT 5

to get just 5 results but i get errors.

View Replies !   View Related
Limiting Results
I have two tables one with three rows one with several. I am left joining the second table with the first one based on shared data (a id number that matches in both tables).

I run mysql_fetch_array until I have read all the data but heres the problem. Each row in table one is being returned more than once as it matches more than one row in table 2. For each row in table 1 I want to get only the first matching row in table 2.

Does that make ANY sense?

View Replies !   View Related
Listing Results
how can I create a simple MySQL query from 2 tables (blog and news) where its just listing their results according to most recent datetime? Here's what I tried, but its vastly incorrect. Their structure is exactly the same; just 2 different tables.
PHP Code:

 SELECT 
b.id, b.status, b.title, b.body, b.a_id, b.datetime, 
n.id, n.status, n.title, n.body, n.a_id, n.datetime 
FROM blog b, news n 
WHERE b.status=0
AND n.status=0
ORDER BY b.datetime,n.datetime DESC

View Replies !   View Related
Wrong Results
I have the following select statement

Code
$query_Recordset1 = "SELECT * FROM data where('$beds like $options')";

the $beds variable is a text field, and the $options variable is a drop-down menu. Technically the query works, but when i put in 775 and click ZIP in the drop-down box it shows zip codes that dont even start with a 7, much less a 775

View Replies !   View Related
More Accurate Results
I have a script with a text field that searches a table based on what is entered in the field...however I would like it to return more accurate results...I.E, if the letters "ham" are entered it returns records that contain the the term (ham) but I need it to FIRST return records that begin with the term... I.E "hamster" not "durham"
PHP Code:

 $sql = "SELECT * FROM _table WHERE name LIKE '%".$searchTerm."%' ORDER BY name ASC LIMIT 0,30"; 

View Replies !   View Related
Correct Results From Db
I have a column of type text, in this column I am adding in numbers that relate to another column in the table. For example the column in question could end up having the following data in it: 1, 2, 6, 9, etc

The problem I am having is if I want to return all the results that relate to lets say the number 1 and if the column in question has more numbers in it than the number 1, I don't get anything returned.
Is this an error with my ASP script or the way the data is stored in the dababase. Do I need to change the data type,

View Replies !   View Related
Ordering By Most Results
In my database I have a table called imagebank and each row has field with the URL to a picture and I field that says what breed the picture is of.
How can I make a query to my database that pulls all the info from that table, and displays them in order of what breed has the most pictures.

View Replies !   View Related
Ranking Results
Im trying to display baseball team stats, along with the ranking for that particular league.
for example, there are 5 teams in the league, Team A has 12 HR, B has 15 HR, C has 3 HR, D has 3, and E has 20.
I want to show on each individual team page their stat, with the rtanking for the league.

View Replies !   View Related
Restricting Results
I have here what should be a no brainer, and perhaps it is the lack of sleep and the long hours today, but I need someone to confirm for me that my logic with the following is on target.

If I want to find all records that were dated either '0', or no older than (approx) 6 months in the past, then the following condition should work for that, correct?

UNIX_TIMESTAMP() - 6*30*24*60*60 > table.dated

The field 'dated' is of course a UNIX timestamp integer field.

View Replies !   View Related
Results Dated
I'm looking for a way to pull only the events that will happen in the next 7 days from my database. I wrote this:

SELECT date, classID FROM EVENTS WHERE classID != '0' AND date <= ( DATE_ADD( CURDATE( ) , INTERVAL 7 DAY ) ) ;


but it looks like this is just pulling all of the events from the table.

View Replies !   View Related
Results Grouping
I need to group products (and display them differently) that have the same 'name' in a list of search results. this application is like a shopping comparison site.

basically, i have one db that is a massive list of products from different vendors. a keyword search will then pull results and display them. for any products that come up twice (with the same 'name' but from different vendors) in the results, i want that result to be displayed differently than the single resluts.

View Replies !   View Related
Results Keep Changing
I have a site which lists the top 3 best pay sites.
Yesterday when i checked the top 3's (there are 3 of them)
i copy-pasted them in a document. After pressing refresh multiple times it stayed the same. However the next day when i checked the results had changed and no new votes had taken place.

This is my code:

SELECT service, count(service) voteQty, AVG(rating) AS rating FROM rate WHERE type = 'pt' GROUP BY service ORDER BY rating DESC, voteQty DESC LIMIT 3

thats for one of the 3 top 3's the other 2 are almost the same.
Why do my results keep changing?

View Replies !   View Related
Results Not Showing
i am wanting to get the highest number in a field where a members id is 1
below is what i have been messing around with so far but can not seem to get the highest figure into the $num var,
i place the query in sql and it shows the row with the highest number is as follows..

itemid
58

58 being the highest number the results show correctly, but not in the query results in php below (line 2)

please can someone help me out and correct what i might be doing wrong with these stamtments

View Replies !   View Related
Show Results Of Sum()
A text column contains these sort of numeric values:
12.34598374
0.9
17.762145
2.2169
1.333333

SELECT sum(the_values_in_text) FROM my_table;
returns 34.55836174

I need to get the result in US currency so that it
returns $34.56

View Replies !   View Related
All Results Of A COUNT
The following query works as I need it to, except that 'kingdom's that don't have any associated 'territory.tile's do not get included in the results.
Code:

SELECT name, gold, COUNT( territory.tile ) AS land
FROM kingdom
LEFT JOIN structure ON structure.kingdom = kingdom.name
LEFT JOIN territory ON structure.id = territory.structureID
GROUP BY kingdom
ORDER BY gold DESC
LIMIT 0 , 20

What do I need to change so that all 'kingdom's are included in the results, whether they have associated 'territory' or not?

View Replies !   View Related
Limit Results
Is there any way to limit the results of a query to the number of rows found minus 1? I'm trying to effectively emulate a logical or in a union query. I have three union segments, and I want either the X number of rows that the first two return, or the one row that the last segment returns (or nothing). So, I was hoping to be able to basically do something like select <...> limit (if(NUM_ROWS > 1, NUM_ROWS - 1, NUM_ROWS)).

For more of the backstory, I'm setting up alias resolution in postfix. What I need is to return the recipients (unknown number of rows) of a mail group (first segment), the owner of an alias (second segment), *or* a catch-all address for the domain if nothing else is found. I may be able to rework my postfix setup somehow, but I figured I'd ask about this first.

View Replies !   View Related
How To Join Results ?
Is it possible to join results of the select query ?

So If I get data from two rows (firstname, secondname)Can I somehow join query results like this: firstname.secondname

Example:

QUERY: SELECT firstname,secondname FROM table;

RESULTS:
John.Doe
Mike.Monroe
Kate.Moss

View Replies !   View Related
Formatting Results
I want my results to be displayed in a table with 4 columns accross then repeat down the page. I've figured out how repeat them either across continually or down, but not 4 across then down. What code do I need to format the results the way I'm wanting?

View Replies !   View Related
Contract Results
When using the MySql admin interface within my website, fields that contain a lot of data - as in text - only show the start of the input. At the top of the results table there is an arrow one can click which then shows the full contents of the cell.

How can i reproduce this 'arrow' function on a row-by-row basis with the output on a web page?. I wish to display the results of a search with one row per line. The field that contains a lump of text needs to initially show just the first few words. If i desire to read the full contents, i then need to be able to get that to open up in a new window.

View Replies !   View Related
Block Results
If I wanted to list my results in blocks of 500 records how would I do this? I looked up cursors and found it confusing. I read up about limits but then it would only list the first 500 records and ignore the rest.

The main reason I'm asking is because my Java app is crashing because of too much data being sent to it from the MySql.

The way to control data is it through MySql or Java?

View Replies !   View Related
Can I Specify Order Of Results [was: Is This Possible?]
I am trying to query a table with real estate listings. I have variables company, price, bedrooms.

I want to do a search of all listings between x and y price, and between b and c amount of bedrooms. I can do all that stuff just fine. However, I want the query to return listings from MY company first. So basically a query there company=mine and then goes through the search, and then company=any and goes through again. Any idea how to do this or what its' called?

View Replies !   View Related
Offsets On Results
How do I produce only 10 results and specify an offset (where the results will begin)? I'm working on something like a search results page on PHP and I was wondering how to do this to reduce server load.

View Replies !   View Related
List Of Results
I have a table with data

User | Value
-------------
A | 1
A | 21
A | 33
B | 41
B | 56
C | 68

and I want to produce a query that will return as the result.

User | Values
--------------
A | 1,21,33
B | 41,56
C | 68

Is this possible? How so?

View Replies !   View Related
How To Get Results From Many Tables
i need some help about getting one result out of eleven tables. every table contains the same fieldname e.g. `number` - the value in this field is unique.

any help from anyone?

View Replies !   View Related
Rank Results
I have the following sql statement (example data used):

SELECT DISTINCT ads.*
FROM ads, ad_features, ad_preferences
WHERE ads.id = ad_features.ad_id
AND ads.id = ad_preferences.ad_id
AND ad_features.feature_id IN ('1, 2, 3')
AND ad_preferences.preference_option_id IN ('77, 65, 62, 59, 52, 47, 45, 38, 91, 18, 7, 1');

I would somehow like to rank the results based on the number of matches in the 2 'IN' clauses. Is that possible? Do I need to change to a MATCH and if so can that work for 2 MATCHes and on INTEGER columns?

View Replies !   View Related
IE Loading Results
I have a page which loads a large amount of results . In Firefox the results display as they load. In IE the results only show when they are all found so it looks like nothing is happening then the page fills in one go. Is there any way to display results in IE in the same way as Firefox.

View Replies !   View Related
Sorting My Results
This is the sql Im using in a recordset using dreamweaver:

SELECT racer_name,SUM(points)
FROM race_results
WHERE `class` = 'gas'
GROUP BY racer_name
ORDER BY race_results.points DESC

Im really new to this but the "SUM" is working fine, but im having a problem with
ORDER By function,...its order by "points" which in my DB is a samllint ---- It just
needs to sort by that number (points) by largest to smallest,

View Replies !   View Related

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