Printing Query Results


echo 'Applicant: $database["APPLICANT"] <br/>'
echo 'Loan Number: $database["LOAN NUMBER"] <br/>' ;


Applicant: $database["APPLICANT"]
Loan Number: $database["LOAN NUMBER"]

Everything connects fine and queries alright but, why won't this output correctly? I did a quick fix for it: Code:

print "Applicant:" . $database['APPLICANT'] . "<br/>";
print "Loan Number:" . $database['LOAN NUMBER'] . "<br/>" ;

Output (what I wanted):
Applicant:Nick's School
Loan Number:006-03-ECA


Printing Results From Query

i am trying to print results from a mysql query, which works and displays. what i was wondering is how i can echo my results in a table, but limit the amount of colums to 5 before starting a new line?

here is my working query;


my$limitarrayiscurrentlysetat20whichwouldbefineifiwantedtodisplayeachresultinarowbutasiwantcolumns20columnsacrossmakesthepagetoowide,soiwantedtosetittoshow5columsaccross,thenstartanewlinewithanother5andsoon. howcanicodethisdifferently.

View 2 Replies View Related

Printing Ordered By Query Results As A Header And Table

My goal is to create an HTML table that lists the title, type, size, and date of a document sorted by the project to which the document belongs. Like this: I can get the data out of MYSQL with


I can create the table with project as a column with


But I'm stumped as to where to go from here. Basically I want to print the project_name as a <h2> before the table with the relevant documents listed in the table. I know it must be so simple and basic, but I am completely missing it and have spent hours looking for a solution on the web. What am I missing?

View 1 Replies View Related

Printing Search Results

How would I go about printing a list of search results? I have my query down fine:

$query = "SELECT data1, data2 FROM table WHERE name = '%$var%' ";
$result = mysql_query($query);

I need to know what to do after this so that all results are printed in a table that includes 'data1' and 'data2'. I'd imagine this is done using 'while()' loops but I've never worked with one before and especially not in this context.

View 3 Replies View Related

Printing Results In A Simple Table

I have a MySQL table with a structure similar to this: Code: [Select]id1 id2 title url dateI would like to print out a simple table in PHP that with the following structure sorted in reverse chronological order for the most recent 10 entries (date above = date submitted) from the MySQL table: Code: [Select]title id2How could I do this?

View 1 Replies View Related

Comparing Results And Only Printing NONE Duplicates?

I know this may seem trival, but I have been stuck trying to figure this out. I have two mysql result queries that I am trying to compare to each other and then only display the ones that do not match each other.

$result202 = mysql_query("SELECT * FROM (SELECT * FROM scheduledjobs WHERE propid='$propid201' AND departclean='ON' AND date<'$workdate' ORDER BY date DESC) AS foo GROUP BY propid");

while ($row202 = mysql_fetch_array($result202))
$propid202 = $row202['propid'];
$lastdate202 = $row202['date'];
/*echo "$propid202 - These are just departures with a last date of $lastdate202<br>";*/
$result203 = mysql_query("SELECT * FROM (SELECT * FROM scheduledjobs WHERE propid='$propid202' AND arrivalchk='ON' AND date BETWEEN '$lastdepart' AND '$workdate' ORDER BY date DESC) AS foo GROUP BY propid");


That is the code thus far and each query gives me the result that I am looking for. I am trying to compare the $propid202 and $propid203 to one another and only print the $propid202 results that do not match the $propid203 results.

View 2 Replies View Related

Printing Mysql_fetch_array Results In Multicolumn Table

I'm not sure if this qualifies as a mysql or a php question so I'm
asking in both groups.

I am pulling the results of a mysql query from my database and want to
print the results into a two column table. I know how to get the results
into a single column table just fine using:

while($row = mysql_fetch_array($result)) {
print "<table border=2><tr><th>" . $row[name];
print "<tr><td>";
print mysql_field_name($result, 0) . ": " . $row[ID]."<br>";
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 mysql_field_name($result, 4) . ": " . $row[telephone]."<br>";
print "</td></tr>";
print "</table>
print "<br><br>";

and it works fine. But my efforts to get the reults into a two column
setup have become frustrating. My latest attempt was:

while($row = mysql_fetch_array($result)) {
print "<table border=2 width=&#3990;%'>";
print "<tr>";
print "<td>";
print "<b>" . $row[name] . "</b><br>";
print mysql_field_name($result, 0) . ": " . $row[ID]."<br>";
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 mysql_field_name($result, 4) . ": " . $row[telephone]."<br>";
print "</td>";
print "<td>";
print mysql_field_name($result, 0) . ": " . $row[ID]."<br>";
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 mysql_field_name($result, 4) . ": " . $row[telephone]."<br>";
print "</td>";
print "</tr>";
print "</table>
print "<br><br>";

View 1 Replies View Related

Save Results As Variables Instead Of Printing Them In An Array

I am using the following code that gets what is between <p> and </p>. Instead of displaying the result in an array how can I save every paragraph in a new variable?

View 1 Replies View Related

Variables Not Printing In Email Form Results?

My form validates and submits fine, but the variables are not being printed in the emailed results.take a quick look at my processing file and tell me why this might be?

$EmailFrom = $EmailFrom;
$Subject = "Proposal Submission";

View 1 Replies View Related

Error When Printing Results Of SELECT FROM WHERE With Variable?

EDIT: I had a typo in my original post....the issue is a bit more complicated...i had a variable passed in not a raw string.I want to print out stories from a mysql database that are specific to a certain person: so i have code that is similar to:

$stuff ="jamie"
$query = "SELECT * FROM person_stories WHERE person =$stuff";
$result = mysql_query($query) or die ("didnt work");[code]...

I keep on getting "didnt work" ...I know that my table person_stories is empty but is this the same thing as an error? The table will obviously not always be empty so I need to be able to use this block of code to go about business.

EDIT 2: The actual error is:

Unknown column 'jamie' in 'where clause'

This is bizzare since it shouldn't be interpreting jamie as the column!

View 4 Replies View Related

PDO Query Not Printing Anything

I have the following function which enables a query to run with a where condition. But it seems not to be producing any results.

I can connect to the database so that is not an issue.

public function executewhereQuery(Array $tableData, $fieldType, $table, $tableField){
$dbh = $this->connect();
/*** fetch into an PDOStatement object ***/


View 2 Replies View Related

Printing A Variable From A Query

Ill just post my code rather then trying to explain myself i will just get confused.

$query = 'SELECT COUNT(*) FROM performer WHERE performer_type = "Band"';
$result = run_sql( $query, true );
$print= mysql_fetch_assoc( $result );
print $print

When I view the page it prints out "Array".

View 14 Replies View Related

When Printing Db Query Only The First Result Is Not Displayed

I am trying to learn. What I'm doing is querying(did I spell this right?) a mySQL database and putting the results into a table on a webpage. I have worked for hours on this and I finally got the answer I was looking for...almost. The problem is that the first result is not displayed. For example, my table in the database looks like:

Item Number <-- Column Names
Him 5
Fim 20
Kim 8
Lim 12

The results that are printed in the table are:

Fim 20
Kim 8
Lim 12

The number of rows that the SQL returns is 4 so I don't understand why I cannot display all 4 rows in the table. Line 64 is where the while loop starts where I think something is wrong. What am I doing wrong? PS. There are a lot of commented lines that I couldn't get to work but are there for my reference, I apologize for not taking them out. I may have left something out that I missed.

Edit: No errors. Just the first row in the mysql table is not showing up in the table on the webpage.



View 9 Replies View Related

MySQL Query Not Printing Out Data?

I'm trying to retrieve some data from my table only for some reason I cant get it to return anything.

$curr_uemail = mysql_query("select * from produgg_users where = ".$usersClass->userID().") or die(mysql_error())");
$arr_uemail = mysql_fetch_array($data);
while($arr_uemail = mysql_fetch_array($data))


View 2 Replies View Related

Results On Multiple Pages: Storing Search Results Or Query Again

Suppose I have a search result with different pages. I could store the results and get them out of the database with a simpler query for the next page. Or I could query again and display only a portion of the results (eg from 20-30). What would be the most efficient. How would bulletin boards do this, or google?

View 2 Replies View Related

Ordering Mysql Query Results - Calculate Results And Order?

i have two tables called teams and results and basically the the results table will store the results of each match the team has. what i need to do is when i select all the teams i need the team with the most results to be ordered first and descending from there.

man united 12 pts
liverpool 9 pts
etc etc

the tables im using are below if anyone could tell me the best way of calculating the results and ordering them


View 8 Replies View Related

Paginating Query Results - Can't Get All Results From Database

I am trying to Paginate Query Results. The values are passed through a form allowing users to search a database based on certain criteria they select. Now I got two problems though,

1) I can't get all the results from the database(as not all the criteria is working) ?

2) If there is more than 1 page, the next page does not carry over any more results, its just blank even though there should be more results. Here is my code:


View 3 Replies View Related

Adding Results From Query 2 To Query 1 - Cannot Use Object Of Type Mysqli_result As Array

I make two queries and I'd like to add rows from query 2 to query 1. Also, suppose getResult1() returns no column called "item2"

$result1 = getResult1();
$result2 = getResult2();
foreach ($result2 as $res)


There error I get here is on line

$result1[] = $data

and reads

Fatal error: Cannot use object of type mysqli_result as array

I think I get what is happening, but I'm not quite sure how to fix it.The rows are ultimately getting converted to JSON, and I can do that that with an array of arrays.I've fixed the problem by converting $result1 into an array of arrays. I do this using a while loop and a fetch_array() call, but is there a quick way to just convert $result1 into an array of arrays instead of a record set?

View 3 Replies View Related

Trouble With Join Query's, Query Just Dosent Produce Results

I have the following code which I am having difficulty getting to
work. I think it may be a problem with the $got query that is being
run as if I set that to a set value then my site seems to run ok, but
I also have checked the data whichi is being held in $detailsrow[1] by
echoing them and it is perfect. I have also sutstituted the values and
ran the query in mysqql directly and it gives me the exat results I am

Ive been on it for hours now and I cant get it to work so any help
will be fantastic,

<select name="type">
$mod = ("select name from modules");
$modnames = @mysql_query($mod);
$getfulltype = ("select from modules, devices where
modules.code= $detailsrow[1] and devices.type = $detailsrow[1]");
$got = mysql_query($getfulltype);
while($row = mysql_fetch_row($modnames))
if ($got == $row[0])


echo ("<option selected value="$got">$got</option> ");

else {
echo ("<option value="$row[0]">$row[0]</option>");

View 10 Replies View Related

Execute An Update Query Based On The Results Of A Select Query

I'm trying to execute an update query based on the results of a select query... This doesn't work - any ideas? This is the code I'm trying to get to run (it updates all products which are set to arrive by a certain date if that date has arrived or passed - and there are products that should and should not be updated in the db this is being tested with...): Code:

View 7 Replies View Related

Display Results From The Results Of Query

Currently I have a search that when someone types for example m32 in to the box, the results are all 'jobs' that are like the postcode 'm32' from the pick up location. It also searches the delivery postcode field, so if there was a job either picking up from m32 or delivering to m32 the results would be displayed. PHP Code:

if ($display == "searchpostcode") {
$sql="select * from tablename WHERE q34 = 'Multiple Sources' AND q39 = 'Job Available' AND q17 LIKE '%$searchpcode%' OR q34 = 'Multiple Sources' AND q39 = 'Job Available' AND q19 LIKE '%$searchpcode%' ORDER BY `id` DESC ";

When you type MK in to the search box the results work well, it pulls the 2 jobs because one has a MK pick up post code and the other has a MK delivery post code. This is ok and works well. however now I also want to have a seperate search that goes like this. Lets say I live in Manchester and type M32 in to the search box.

View 4 Replies View Related

Multiple Query Data Into Single Html Table (Mysql) Array Not Printing In Correct Position?

I got code snippet from this site, which I used as shown below

$data = array();
while($row = mysql_fetch_assoc($num1)) {$data['row'][] = $row;}
while($row = mysql_fetch_assoc($num2)) {$data['row2'][] = $row;}
$count = count($data['row']);
echo "<table>" ;
echo "<tr>";
echo "<td width='300' bgcolor='#99CCF5' align='Left' style='padding-left:30px'><b>Country</b></td>" ;

which gives a reult like below. where the correct result should be like this

that is if any value in a column is empty the next adjucent value gets that position. How can I make this correct? that is if any value is empty that column must be empty.

View 1 Replies View Related

2nd Sql Query Also Returning Results From 1st Query?

What would be the correct way to close a mysql query?

At current the second query below returns results from the 1st query AND the 2nd query The 3rd query returns results from the 1st, 2nd and 3rd query.etc etc.

At the moment I get somthing returned along the lines of...

Accommodation 1
Accommodation 2
Accommodation 3


View 3 Replies View Related

Getting Too Many Results From A Query!

This is very peculiar -- for some reason, I'm getting 6-8 results from each
of these queries, although only one listing matches. I have a pair of forms
on one page:

Search for lastname: ____________ [Submit]
Search for email: ________________ [Submit]

This goes to a searchresults.php page:

if ($searchname !== "") {
$query="SELECT artistID,firstname,lastname,email,city,state,count ry
from artists WHERE lastname='$searchname'";
$result=mysql_query($query) or die(mysql_error("Could not execute
while($row = mysql_fetch_array($result)) {
$alt_artistID = $row['artistID'];
$alt_firstname = $row['firstname'];
$alt_lastname= $row['lastname'];
$alt_email = $row['email'];
$alt_city = $row['city'];
$alt_state = $row['state'];
$alt_country = $row['country'];
echo "<CENTER><HR>".$alt_artistID."<BR>"
.$alt_firstname." ".$alt_lastname."</A><BR>"
.$alt_city.", ".$alt_state." ".$alt_country."<BR>
<A HREF=delete.php?aritstID=".$alt_artistID.">DELETE THIS

The second section is identical except for:
if ($searchemail !== "") {
$query="SELECT artistID,firstname,lastname,email,city,state,count ry
from artists WHERE email='$searchemail'";

I don't understand why I would get 6-8 records when you can look at them and
see that all but one clearly do not match...?

View 2 Replies View Related

Sql Query Results

I am making an online dictionary of golf terms. I have a mySQL db filled with terms and the table structure looks like this:

id: int, primary key, auto_increment

alpha: enum ('select one','a','b','c', ... 'x','y','z') default - select one

term: varchar - 50

definition: varchar - 300


View 2 Replies View Related

Query For # Results Only

I'm doing a query to echo the # of total results. There is a three way inner join/select max being used. Anyway, how or even should I integrate the # results with the query. That's all that is being returned. There will be over fifty queries on the page (a reports page) covering regions of the United States. The values are constantly changing.
count / num rows?

View 2 Replies View Related

Query Only Results

A person is searching for a "hotel room". They're going to be in town for 3 days. We have a DB full of rooms from various properties. Many properties have more than one room available. Some have availability for day 1 and day 3, some for day 2 and day 3 -- and some for all three days. Some have availabilty for all 3 days -- but in different rooms.

I need to find only the rooms that are available for 3 continous days -- so that the guest doesn't have to move rooms. Right now something like this returns everything available -- not just the rooms available all three days. $sql="SELECT room FROM inventory WHERE date>$start_day AND date<$end_day". Can anyone please do up a quick sample query for me?

View 3 Replies View Related

Query Results

i'm looking to create a ranking system similar to the one on Basically, i have the ranking system set up, i'm just having trouble with the search function. When a user searches for someone in the rankings, i want it to display the results above and below it. e.g.


Say i want to search for 5, i want it to display.


View 1 Replies View Related

SUM Of Query Results

I am using the following query to find the total times each lead has been sold.

$query = "SELECT * FROM Leads WHERE Date = '$Today' AND Source = '' ORDER BY CustomerID ASC LIMIT 0, 1000";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {

$CustomerID = $row['CustomerID'];
$query1 = "SELECT COUNT(CustomerID) AS qtysold FROM Purchased_Leads WHERE CustomerID = '$CustomerID'";
$result1 = mysql_query($query1);
$row1 = mysql_fetch_assoc($result1)

View 3 Replies View Related

Get More That 10 Results For A Query Using YQL?

I am trying to use YQL in php to get product information from Amazon using the amazon.prodlist table and Amazon Product Advertising API.

The query that I used:

select * from amazon.prodlist where Title='harry potter' and SearchIndex='Books' and ResponseGroup='Images,ItemAttributes'

It returns only 10 results. How can I get it to display more that 10 results on the same page? Also, without pagination.

The full PHP code:

$BASE_URL = "";
$title="harry potter";


This displays 10 results on a page. Whereas, when I search for 'harry potter' in 'Books' on Amazon website, I get more than 3k results. Is there any way to get all the results on one page itself?

View 1 Replies View Related

Using Query Results

Can you use a queries results only once? In this script I'm looping through a query and saving some values in an array. A little further through the script I need to use the same query for output. When I loop through nothing is echo'd to the browser. When I output a row count it shows that the correct number of records, so they must still be there.

View 5 Replies View Related

Results Of Query = To 0 Are Ignored

how I could make an entire line of a query result not show up if the result is equal to "0". I have copied the code below and made the area bold that I believe needs to be changed.

// Make a MySQL Connection
// Construct our join query
$query = "SELECT sunocoimport.duns_num, custmast.gl_num, custmast.division_num, custmast.customer_num, sunocoimport.summary_date, sunocoimport.cc_fees, custmast.fee_percent, custmast.clear FROM sunocoimport, custmast WHERE sunocoimport.duns_num = custmast.duns_num";


View 3 Replies View Related

Query Results In 2 Columns?

I'm struggling to figure out how to do this properly. I have done a mySQL
query to extract a list of names, and done a mysql_num_rows to determine how
many results I've gotten. I want to split the list in to two columns. I've
created $percol = $mysql_num_rows/2 but I'm not quite sure how to "loop"
through the first half of the list, echo </td><td> and then list the
balance. Can anyone give me some guidance on how best to structure this?

View 1 Replies View Related

Finding The Results Of A Query

I am working on a script that will query a database for a FNAME/LNAME
combo. If it finds the combo, I need it to do one set of instructions.
If it doesn't find it, I need it to do something else. What I can't
figure out is what variable to check against. Here is what I have for
the relevant part of the script:

$connection = mysql_connect($hostname, $username, $password);
mysql_select_db($databasename) or die ("Cannot connect to database"
$result = mysql_query($query) or die('Query failed: ' . mysql_error());

I tried checking the value of $result to see if it changed depending on
whether or not it found the selection. It does not. I just can't figure
out what to use for:

if (some expression){
perform this code
do this

View 8 Replies View Related

Grouping Results Of Query

I'm brand new to PHP (just starting today to convert tons of
ColdFusion/Access code to PHP/MySQL). There is a function in
Coldfusion that I can't find an equivalent to in PHP. Here is
what I am trying to do:

If I have a query that results in this information:
State Firstname Lastname
Idaho Terry Pratchet
Vermont Dan Brown
Vermont Bob Smith
Virginia Alice Johnson
Virginia David Jones

I would like to output the info like this:

But all I can find in PHP is a way to loop through the query
and show every row... if you are familiar with Coldfusion,
what I am looking for is something similar to this:

#Firstname# #Lastname#

Is there a function that does this in PHP, or do I need to
write code that watches the value of 'State' and manually
takes care of things whenever it changes?

View 6 Replies View Related

ODBC Query Results

Consider the following:


$username = "foo";
$password = "bar";
$host = "db";

$connect = odbc_connect("$host", "$username", "$password") or die;

$query = "SELECT id, name, address, city, state, comments1, comments2
FROM data.table1, data.table2 WHERE id = '";

$result = odbc_exec($connect, $query);

$id = odbc_result($result, 1);
$name = odbc_result($result, 2);
$address = odbc_result($result, 3);
$city = odbc_result($result, 4);
$state = odbc_result($result, 5);
$zip = odbc_result($result, 6);
$comments1 = odbc_result($result, 7);
$comments2 = odbc_result($result, 8);
print("ID: $id<br>Name: $name<br>Address: $address<br>City:
$city<br>State: $state<br>Zip: $zip<br>Comments1:
$comments1<br>Comments2: $comments2<br>


Only one record is returned from data.table1 (containing the id, name,
address, city, state, & zip). However, there are multiple records
returned from data.table2 (records from comments1 & comments2). What
is happening is that when I run this script, all of the data returned
from data.table1 is printed over & over again along with each record
returned from data.table2. How can I make it such that id, name,
address, city, state & zip are only printed once - and allow comments1
& comments2 to be printed multiple times for each occurance in the

I've thought about just creating a second database query for the
records in data.table2, however I need the join I'm getting by using
the existing query.

For what it's worth, I'm connecting to a DB2 database using PHP /
Apache on Linux.

I'm confused by this.

View 2 Replies View Related

Losing Query Results!

If I make a query;

$result = mysql_query($theQuery, $db);

and then make use of the query results like so;

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

//do something with query results}

I can't use $result again, I have to make another query! Why is this and is there any way around it?

View 3 Replies View Related

Multiple Sql Query Results

I'm trying to do a query from 2 databases. Basically i have
catagories within 2 databases. If both catagories return 0 rows then it
does nothing but if one or both have rows returned then i need it to
echo a result. I guess where i'm wondering if there's an OR statement i
can use or something to that effect...

something like

if($numrows == 0 OR $numrows2 == 0) {
echo ('');
echo ('$result');

View 2 Replies View Related

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")

View 4 Replies View Related

Sql Query Results And Scrolling

I make a mySQL database query and display the first 10 results. Then
the user can click on "next" link to get the next 10 results. How can
I do that without issuing the sql query again? Can I keep the results
from the first query?

View 3 Replies View Related

Copyrights 2005-15, All rights reserved