Printing Query Results

Aug 4, 2005


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

View 1 Replies


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Copyrights 2005-15, All rights reserved