Printing Query Results

Aug 4, 2005

Code:

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

Output:

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

ADVERTISEMENT

Printing Results From Query

Mar 13, 2010

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))
{
?>
<td><?=$data["day"]?></td>
<? } ?>

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

Mar 4, 2010

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.
<thead>..........

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

Sep 12, 2001

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

<?php
$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

Feb 25, 2010

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?

Feb 27, 2010

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'];
if($lastdate202<=$lastdepart){
/*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");

[Code]...

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

May 1, 2006

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

Mar 24, 2011

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?

Jul 15, 2010

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?

<?php
// CHANGE THE VARIABLES BELOW
$EmailFrom = $EmailFrom;
$Subject = "Proposal Submission";
[code]....

View 1 Replies View Related

Error When Printing Results Of SELECT FROM WHERE With Variable?

Jun 4, 2011

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

Jul 7, 2010

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();
try{
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
/*** fetch into an PDOStatement object ***/

[Code]....

View 2 Replies View Related

Printing A Variable From A Query

Jun 25, 2007

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

Sep 17, 2010

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.

<?php
$dbname = $_POST["dbname"];
$quantity = $_POST["quantity"];

[code]....

View 9 Replies View Related

MySQL Query Not Printing Out Data?

May 31, 2011

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

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

[Code]....

View 2 Replies View Related

Results On Multiple Pages: Storing Search Results Or Query Again

Nov 15, 2005

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?

Jul 11, 2010

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

[code]...

View 8 Replies View Related

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

Dec 28, 2009

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:

[code]...

View 3 Replies View Related

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

Apr 29, 2011

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)

[code]....

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

Jul 17, 2005

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
expecting!

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

<select name="type">
<?PHP
$mod = ("select name from modules");
$modnames = @mysql_query($mod);
$getfulltype = ("select modules.name 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>");
}
}
?>
</select>

View 10 Replies View Related

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

Mar 1, 2007

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

Aug 4, 2006

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?

Jun 18, 2011

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>" ;
code....

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?

May 11, 2011

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

QUERY 1 RESULTS
Accommodation 1
Accommodation 2
Accommodation 3

[Code]....

View 3 Replies View Related

Getting Too Many Results From A Query!

Jul 16, 2005

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:

<FORM>
Search for lastname: ____________ [Submit]
</FORM>
<FORM>
Search for email: ________________ [Submit]
</FORM>

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
query."));
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_email."<BR>"
.$alt_city.", ".$alt_state." ".$alt_country."<BR>
<A HREF=delete.php?aritstID=".$alt_artistID.">DELETE THIS
LISTING?</A><BR></CENTER>";
}
}

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

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

Jul 14, 2005

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

Code:

View 2 Replies View Related

Query For # Results Only

Sep 23, 2005

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

Jan 15, 2007

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

Dec 3, 2007

i'm looking to create a ranking system similar to the one on nexon.net. 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.

1
2
3
4
5
6
7
8

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

4
5
6

View 1 Replies View Related

SUM Of Query Results

May 3, 2006

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

<?php
$query = "SELECT * FROM Leads WHERE Date = '$Today' AND Source = 'MFE.com' ORDER BY CustomerID ASC LIMIT 0, 1000";
$result = mysql_query($query);
$num=mysql_num_rows($result);
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?

Jun 7, 2011

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:

<?php
$BASE_URL = "https://query.yahooapis.com/v1/public/yql";
$key="my_key";
$secret="my_secret";
$title="harry potter";
$sindex="Books";
$rgroup="Images,ItemAttributes";
$events="";

[Code]...

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

May 15, 2007

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

Oct 30, 2009

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

[Code]....

View 3 Replies View Related

Query Results In 2 Columns?

Jul 16, 2005

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

Nov 21, 2006

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"
..mysql_error());
$query="SELECT FNAME, LNAME FROM (table) WHERE FNAME=('$FName') AND
NAME=('$LName')";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
mysql_close($connection);

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
}
else{
do this
}

View 8 Replies View Related

Grouping Results Of Query

Jul 17, 2005

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:

<CFOUTPUT GROUP='State'>
#State#<BR>
<CFOUTPUT>
#Firstname# #Lastname#
</CFOUTPUT>
<BR>
</CFOUTPUT>

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

Jul 17, 2005

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

while(odbc_fetch_row($result)){
$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
database?

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!

Aug 31, 2002

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

Feb 23, 2006

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 ('');
}else{
echo ('$result');

View 2 Replies View Related

SQL Query - Results From Another PHP Page ?

Jul 16, 2005

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

Jul 17, 2005

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

Query In PHP Won't Return Results In There's Only 1

Jul 17, 2005

$sql = 'SELECT `PageTitle` '
$sql .= 'FROM `Pages` '
$sql .= 'WHERE `PageID` = 1 LIMIT 0, 30'

I have run this query in MySQL control panel and it works perfectly.
When I try to do it via PHP I get no results.

If I select all rows (i.e I don't specify a "WHERE") I get one fewer
rows returned than there actually are.

View 2 Replies View Related

Link The Query Results?

Jul 13, 2006

Imagine I have a select query which returns various records, let´s say 20 lines. I have for example columns named place, name, club, points. I do a search with some form values and it returns the results on a normal table bellow, this is how it works now.

Is it possible to make each line of the result clickable, so it can open a popup with details about that specific line? Let´s say I wanted to see details of one club (it´s another table) by clicking a line in which that club is presented.

View 14 Replies View Related

Query Results And Arrays

May 11, 2006

I have a simple query below: Code:

$query2 = "SELECT CustomerID FROM Purchased_Leads WHERE CompanyID = &#55615;&#56946;' ORDER BY TransactionID DESC LIMIT 0, 41";
$result2 = mysql_query($query2);
$row2 = mysql_fetch_assoc($result2);
$custid = $row2['CustomerID'];

It should return 5 or 6 results depending on the CompanyID. What i need is to then get the results into an array that would look like so:

Array ( [0] => 11111 [1] => 22222 [2] => 33333 [3] => 44444 [4] => 55555 )

I just am unsure of how to go about that. I'm sure i'll probably have to loop through the results but i guess i'm still of unsure how to do this.

View 2 Replies View Related

Drop-down From Query Results

Mar 23, 2007

I've got a form that pulls data from a MySQL database and populates the form and allows the user to edit the info and submit the changes to the database. All works fine when I'm working with straight text boxes (which comprises the majority of the form). The problem arises when I'm dealing drop-down select boxes. Essentially, what I want to do is to populate the drop-down with all choices but have the one "selected" that was previously in the database. The MySQL tables look like this:

leave_type TABLE which has leave_type_id and leave_type_name

absence_actions TABLE which has absence_id, personnel_id, leave_type_id, etc...

So, I'm looking at grabbing all of the results of the leave_type table to populate the dropdown and then grabbing a specific row from the absence_actions table and making the dropdown "selected" based on the leave_type_id from both tables. Does anyone have any idea on how to code something like this. This seems like a common problem but I can't find anything on google. Perhaps I don't know how to phrase my query.

View 1 Replies View Related

Outputting Query Results

May 22, 2005

How would I take the results of my query and output them to a table on my web page?

View 1 Replies View Related

ADVERTISEMENT