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;

// initiate query
$results = mysql_query("SELECT * FROM tests WHERE member_id='$_SESSION[SESS_MEMBER_ID]' ORDER BY id DESC LIMIT $page, $limit");
while ($data = mysql_fetch_array($results))
<? } ?>

my $limit array is currently set at 20 which would be fine if i wanted to display each result in a row but asi want columns 20 columns across makes the page too wide, so i wanted to set it to show 5 colums accross, then start a new line with another 5 and so on. how can i code this differently.

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

$q = 'SELECT DISTINCT project_name, document_name, document_type,   
document_size, date_last_modified FROM documents LEFT JOIN projects ON   
documents.project_id = projects.project_id ORDER BY project_name ASC,   
date_last_modified DESC';        

I can create the table with project as a column with

if ($r) // ran OK,

echo '<table summary="A listing of the project documents"> // Table header.

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.

$dbname = $_POST["dbname"];
$quantity = $_POST["quantity"];


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

Copyrights 2005-15, All rights reserved