Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Combining Data From Two Fields, Displaying With Another Table


What I am trying to do is pull data from two tables and display it on one page. The code below doesn't display any errors, but all it prints is the results from the first query. Ideas? Thanks.

(I also need to somehow put a variable in for the warranty table data so it is tied to the product_status table data. You can see there is a WHERE in the first query of pid, but no WHERE in the second query. That is a seperate question, though. It would make this way too long, so I will post it separately). PHP Code:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Grabbing Data From A Table And Displaying It
I'm grabbing data from a table and displaying it but I want to to spand out into multiple pages...I got it all setup but when I click on the next link nothing happens... I got it setup at "3" right now just for testing..I have 5 entries in the database.. anyways could someone help me out? here is the code:

<?php

// Get connection info
include "../connect.php";
// End connection info
if(!$rowstart) $rowstart=0;
// Start database select
$result = mysql_query(
"SELECT * FROM links WHERE notactive='$notactive' order by date desc limit $rowstart,3"); //Select Database
$result2 = mysql_query("select * from links");
if (!$result) {
echo("<P>Error performing query: " .
mysql_error() . "</P>"); exit(); }
// Display the text of each host
while ( $row = mysql_fetch_array($result) ) {
if ($notactive = 1) {
echo ("<table width=500 height=57 border=0 cellpadding=0 cellspacing=0>");
echo ("<tr>");
echo ("<td align=left valign=top><strong>" . $row["name"] . "</strong></td>");
echo ("</tr>");
echo ("<tr>");
echo ("<td align=left valign=top>" . $row["desc"] . "</td>");
echo ("</tr>");
echo ("<tr>");
echo ("<td align=left valign=top><a href=" . $row["url"] . ">". $row["url"] ."</a></td>"); }
echo ("</tr>");
echo ("<br><br>");
echo ("</table>");
}
if ($rowstart>$numrows)
{
echo "<A HREF=$php_self?rowstart=rowstart-3>";
echo "< Previous Page</A>";
}
echo "|";
$numrows=mysql_num_rows($result2);
if($rowstart+3<$numrows)
{
echo "<A HREF='$php_self?$rowstart=rowstart+3'>Next Page></A>";
}
?>

Grabbing Data From A Table And Displaying It
I'm grabbing data from a table and displaying it but I want to to spand out into multiple pages...I got it all setup but when I click on the next link nothing happens... I got it setup at "3" right now just for testing..I have 5 entries in the database.. anyways could someone help me out? here is the code:

<?php

// Get connection info
include "../connect.php";
// End connection info
if(!$rowstart) $rowstart=0;
// Start database select
$result = mysql_query(
"SELECT * FROM links WHERE notactive='$notactive' order by date desc limit $rowstart,3"); //Select Database
$result2 = mysql_query("select * from links");
if (!$result) {
echo("<P>Error performing query: " .
mysql_error() . "</P>"); exit(); }
// Display the text of each host
while ( $row = mysql_fetch_array($result) ) {
if ($notactive = 1) {
echo ("<table width=500 height=57 border=0 cellpadding=0 cellspacing=0>");
echo ("<tr>");
echo ("<td align=left valign=top><strong>" . $row["name"] . "</strong></td>");
echo ("</tr>");
echo ("<tr>");
echo ("<td align=left valign=top>" . $row["desc"] . "</td>");
echo ("</tr>");
echo ("<tr>");
echo ("<td align=left valign=top><a href=" . $row["url"] . ">". $row["url"] ."</a></td>"); }
echo ("</tr>");
echo ("<br><br>");
echo ("</table>");
}
if ($rowstart>$numrows)
{
echo "<A HREF=$php_self?rowstart=rowstart-3>";
echo "< Previous Page</A>";
}
echo "|";
$numrows=mysql_num_rows($result2);
if($rowstart+3<$numrows)
{
echo "<A HREF='$php_self?$rowstart=rowstart+3'>Next Page></A>";
}
?>

Grabbing Data From A Table And Displaying It
I'm grabbing data from a table and displaying it but I want to to spand out into multiple pages...I got it all setup but when I click on the next link nothing happens... I got it setup at "3" right now just for testing..I have 5 entries in the database.. anyways could someone help me out? here is the code:

<?php

// Get connection info
include "../connect.php";
// End connection info
if(!$rowstart) $rowstart=0;
// Start database select
$result = mysql_query(
"SELECT * FROM links WHERE notactive='$notactive' order by date desc limit $rowstart,3"); //Select Database
$result2 = mysql_query("select * from links");
if (!$result) {
echo("<P>Error performing query: " .
mysql_error() . "</P>"); exit(); }
// Display the text of each host
while ( $row = mysql_fetch_array($result) ) {
if ($notactive = 1) {
echo ("<table width=500 height=57 border=0 cellpadding=0 cellspacing=0>");
echo ("<tr>");
echo ("<td align=left valign=top><strong>" . $row["name"] . "</strong></td>");
echo ("</tr>");
echo ("<tr>");
echo ("<td align=left valign=top>" . $row["desc"] . "</td>");
echo ("</tr>");
echo ("<tr>");
echo ("<td align=left valign=top><a href=" . $row["url"] . ">". $row["url"] ."</a></td>"); }
echo ("</tr>");
echo ("<br><br>");
echo ("</table>");
}
if ($rowstart>$numrows)
{
echo "<A HREF=$php_self?rowstart=rowstart-3>";
echo "< Previous Page</A>";
}
echo "|";
$numrows=mysql_num_rows($result2);
if($rowstart+3<$numrows)
{
echo "<A HREF='$php_self?$rowstart=rowstart+3'>Next Page></A>";
}
?>

Grabbing Data From A Table And Displaying It
I'm grabbing data from a table and displaying it but I want to to spand out into multiple pages...I got it all setup but when I click on the next link nothing happens... I got it setup at "3" right now just for testing..I have 5 entries in the database.. anyways could someone help me out? here is the code:

<?php

// Get connection info
include "../connect.php";
// End connection info
if(!$rowstart) $rowstart=0;
// Start database select
$result = mysql_query(
"SELECT * FROM links WHERE notactive='$notactive' order by date desc limit $rowstart,3"); //Select Database
$result2 = mysql_query("select * from links");
if (!$result) {
echo("<P>Error performing query: " .
mysql_error() . "</P>"); exit(); }
// Display the text of each host
while ( $row = mysql_fetch_array($result) ) {
if ($notactive = 1) {
echo ("<table width=500 height=57 border=0 cellpadding=0 cellspacing=0>");
echo ("<tr>");
echo ("<td align=left valign=top><strong>" . $row["name"] . "</strong></td>");
echo ("</tr>");
echo ("<tr>");
echo ("<td align=left valign=top>" . $row["desc"] . "</td>");
echo ("</tr>");
echo ("<tr>");
echo ("<td align=left valign=top><a href=" . $row["url"] . ">". $row["url"] ."</a></td>"); }
echo ("</tr>");
echo ("<br><br>");
echo ("</table>");
}
if ($rowstart>$numrows)
{
echo "<A HREF=$php_self?rowstart=rowstart-3>";
echo "< Previous Page</A>";
}
echo "|";
$numrows=mysql_num_rows($result2);
if($rowstart+3<$numrows)
{
echo "<A HREF='$php_self?$rowstart=rowstart+3'>Next Page></A>";
}
?>

Displaying Data In Html Table.
I wondered if anyone could offer some guidance, I trying to write a
php script to connect to a database, and display the records in a
table.

I found the code here in a php4 text, and when I run this directly
through the php intrupeter, the line Successfully connected is display
and 4 as the number of rows.

The database table we connect to, has three field username, firstname,
surname.

When I tried a while loop, to display the data in a table. No values
were displayed.

Could anyone possibly demonstrate how to display the username,
firstname, surname values in a basic table?

<?php
function db_connect(){
global $MYSQL_ERRNO, $MYSQL_ERROR;

$link_id = mysql_connect("localhost","user04", "password04");

if(!$link_id){
$MYSQL_ERROR = "Connection failed";
return 0;
}
else if(empty($dbname) && !mysql_select_db("database04")){
$MYSQL_ERROR = mysql_error();
return 0;
}
else return $link_id;
}

!$link_id = db_connect();
if(!$link_id) die(error_message('Error connecting'));

$result = mysql_query("SELECT * FROM users");
if(!$result) error_message('Error in selection');
else echo "Successfully connected. ";

$query_data = mysql_fetch_row($result);
$total_records = $query_data[0];

if(!$total_records) error_message('No records');
else echo "$total_records.";
?>

How To Combining 2 Db Fields Into One Selection?
In my db I have 2 fields: first_name and last_name & I want to combine these 2 fields in my drop-down menu.

What I have now is showing only the first_name -- I know that it needs to go into the third option in here, I'm just not sure how to get both of them into it. I can get the first_name OR last_name, but not combined. Code:

Combining Serialized Data
I have some data I want to serialize but I want to combine them.

something like
serialize($data1).serialize($data2)

and then later on I need to deserialize them back into two seperate
variables. I'm not sure how I can go about this? Obviously I could seperate
them by some token and use that but I'm not sure how safe it is. Is there a
better method? or a token that I know I can used.

I guess I could do something like this

$str = serialize(array(serialize($data1), serialize($data2)))

then
$t = unserialize($str);
$data1 = unserialize($t[0]);
$data2 = unserialize($t[1]);

but seems like the long way around?

Outputting A Table Or Form Using SHOW FIELDS FROM Table
In the code the MySQL database was queried using "SHOW FIELDS FROM table" which and the returned results of column names was then use to build an output for a form and a table with php using a series of if statements along the lines of if the returned field name matches something echo a text input field.

I have never seen this done this way before, so I want to get the opinion of the devshed user. Does it seem like an unsual long process to build up a form. Is there a security advantage doing it this way? Has anyone ever done it this way before?

Returning Table Name As Well As Fields From That Table
I am returning all fields from news and from regional, however I want to determine where the fields have come from when I ouput the data, therefore I need to return the table name with the fields. Is this possible? Code:

Displaying Text Fields On User Input
How would I echo a particular amount of text fields depending on how many the user selects from a drop down menu that I have already created. For example say the user selects 4 or whatever other number from a drop down menu how would I echo 4 or whatever the amount of text fields for a user to input text into? An example would be an airline website were you select how many people are travelling and then it echo fields for those people to enter their names.

How To Get The Fields From A Table
Because the fields i make in the table are very subject to change and i want to know them without to have written in the php code. So i want to know all fields names from a table in a mysql database.

Table Fields
how can i get field names of a table

Problem Sorting By 2 Fields From Table
As part of a rating system on my site, data for the total rating and also the number of votes gets added into a table. I am currently trying to query this table to get the highest rated row of data.

This worked fine when I only had "ORDER BY rating DESC LIMIT 1" at the end of my query - It would select the row where the rating was 5 out of 5. I realised that if 2 rows had the same rating, I could not determine which one to select. So i tried changing the code to: "ORDER BY rating, num_votes DESC LIMIT 1". For some reason, this now selects a row where both the rating and num_votes values are 0.

Just in case you need to see the entire query, here it is:

Adding Fields To An Existent Table Through PHP
Is something like this possible? A PHP script that would add for example 3 new fields to a table that already has 5.

Merging Mysql Table Fields
How can I merge multiple fields of a table for my query.

suppose I have 2 table

table1
=============
field1      field1
=============
Lam         20
Ld            9
Auz          3

so I want to check where does keyword "Ld9" Exisit

so what will me my query for
select * from table1 where field1+field2=$keyword

Two Auto Incrementing Fields In One Table?
I have been trying to get two different rows to auto increment in the same table? If so how do i do it? it says u can only have one primary (obviously) and that is the auto incrementing field. Is there any way around this?

here is the mysql error form phpmyadmin...

#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key

Search 2 Fields In A Mysql Table Using Only 1 Input Box
I would like to search 2 fields in a table using only 1 input box in php, at the moment I have 2 input boxes one for the Town search and one for the County searh, I would like 1 input box that would search the 2 fields. Here is my PHP Code:

Change Values Of All Fields In Table In PhpMyAdmin
I would like to be able to change certain values in every row of a table. There are about 1000 or so row, and I need to change the values of certain fields to all the same value, and wondered if that was possible easily (and not having to do each row individually) in phpMyAdmin?

Grab Data From A Table, Echo, Then Insert It Into A New Table...
I'm trying to do is count the number of times usernames shows up in a table. I then want to reinsert that information into a different table with the Username in column1 & the occurrences in column2 for every user that is echoed on the page. Code:

Using PHP To Sort Data In MySQL Table 1 By Values In Table 2
I have a MySQL database with 2 tables in it. products and prices.. Products has a field in it called 'prodno'. Prices has a field in it called 'prodid'.

There is one of each item in products and each product has it's own unique 'prodno'

There are multiple instances of each product's pricing in prices.. One for each price.. So if a product had multiple prices depending on quantity it would have an entry for each price.. Example:

id = 1
prodid = 7001
qty = 300
price = 12.5

id = 2
prodid = 7001
qty = 400
price = 15.5

I was wondering if I could query the database getting info from the products table but sort it according to the prices in the prices table.

Kinda like doing a "SELECT * FROM products" ordering it by the lowest price value from each item..

This is all very confusing to me, and I'm the one writing it. Let's try one last time..

Query the database selecting * from products (I plan on using all the info in products) and ordering them by the lowest price for each item in the prices table. I've tried sorting the results of just a basic SELECT * FROM products using Javascript and PHP but with pagination in the results it makes it a bit hard.

Displaying # Of Records In A Table
Can anyone throw me a link to some prefab code, or a tutorial on how I can get a page to display the number of records that meet a certain criteria.

example:
I have a page that stores information on audio FX. I'd like to include a feature that would let the users know how many items are in a particular section.

Player (10)
Items (5)
Weapons (0)
etc.

All help appreciated,

Displaying A HTML Table With PHP
I'm new to PHP and I'm trying to get my head around databases at the moment. So far I have a page that kinda takes the mickey and takes a few details from you, it then creates a cookie that can be removed later. It also prompts you to add the data you gave to a database.

All this works perfectly, but when it comes to displaying the results of the database, all I can show is the first entry in the table. Can someone please tell me how I'm supposed to see all of them?

I've read other articles but they don't make much sense to me.

BTW, the database details are as follows:

Database name: visualanteorg
Table name: people
Fields: id, name, shoe_size, job

As you will see if you choose to look at the pages, getting the information out is not a problem, it's just formatting it how I want it, so each entry appears under the other in the table.

Displaying Table In Php Code
I have a PHP script that has a drop down to select a record, then it should display some text from a database and then display a table of information below it. But, the table is displaying at the top instead. Code:

Update Table While Insert Data To Another Table
it seem like mine coding din work.
[php]<?

include("checkin.html");
$conn=mysql_connect('localhost','root','') or die ('Could not connect to server');
$today = date("Y.m.d");
mysql_select_db('hms', $conn);

$ok = mysql_query("INSERT INTO check_in(ID,room_no,datein)values ('$ID','$room','$today')", $conn);

if( $ok ){

$up = mysql_query("UPDATE studtable SET checked = 'checkin' where [ID] = '%ID');

if(mysql_affected_rows( $up ) == 1)
{
echo'Checked IN!'
}else { echo'No such student to check in' }}
else { echo'Check In FAILED, please check again'}?>[php]

Testing If Two Fields Have Data In Them
Im trying to test if two fields have been entered at the same time
I have tried many combinations but cant get it. My last effort was

if(isset($_POST['Link'] && isset($_POST['uploadedfile'])){
die('You can't select to upload a link and a file at the same time.');
}
else
{
STUFF HERE;
}

but still cant get it to work.

Displaying Information In A 1 Row/2 Column Table
I'm very new to php scripting and haven't quite figured out what I need to do here.

I need to display information in a 1 row/2 column table. I have the MySQL query working fine, but the scripting part in php is killing me!

In the first column a graphic about 70x70 will be shown (plus some additional padding). In the second column will be the description information. The second column will be around 400 pixels wide.

How do I set this up in php? It's easy enough in HTML, but I've about killed myself trying to figure out how to properly lay this out in php!

Displaying Array Results In Table
I'd like to display the results of an array in a table format with the Alias, Alias Destination & Username as column headings & the results underneath. PHP Code:

Displaying Records In A Split Table?
trying to split up results of a query into a split table. example: PHP Code:

Displaying Table Field List
I got a function that displays a list of the fields in a certain mysql table.  I got it off of this site.  The problem is that it only displays the word Array and I'm not sure why.  This is the code for the function: Code:

Displaying A Table Using ID Number As Hyperlink
i am able to insert and display data to the end user, but i am trying to let the end user edit a row. I am unsure how this is usually done, but i am have the following code to display by data

 echo "<table border='1'><thead><tr>";
            for($i = 0;$i < mysql_num_fields($sql_result);$i++)
            {
             echo "<th>".mysql_field_name($sql_result,$i).
                  "</th>";
            }
     echo "</tr></thead>
           <tbody>";
     for ($i=0;$i < mysql_num_rows($sql_result);$i++)
     {
        echo "<tr>";
        $row = mysql_fetch_row($sql_result);
        foreach($row as $value)
        {
           echo "<td>".$value."</td>";
        }
        echo "</tr>";
     }
     echo "</tbody></table>";

The user have a jump menu (combo box) to pick the table they need to show information on, so the columns displayed are going to vary, but i have a column called ID which is the same in each tables which is the index (auto increment) field.

I was thinking about using this number comnbined with a hyperlink, so the user can click it to take them to a page to edit that row.... But i have no idea how to do this, or if there is an easier way which i just do not know; or how do most people achieve what i require...

REQ How Would I Compare Multiple Date Fields In One Table To Find The Latest Entry Opps
i didn't explain it correctly before
my table is like this

example fields:
ID name username outcome date1 date2 date3 (etc..) - date15 price1 price2 price3 (etc..)

I know that Mysql query order by will compare records on a specific date, but how do i compare
multiple fields within the same record. Want to find the latest date within the record..

Form Fields Not Carrying Data
I'm having a problem with the following form; Code:

Defaulting Data In Form Fields
in a lengthly form, is it possible to use PHP3 to automatically fill form fields with data that has already been entered into a previous place on the same form?...or from a previously filled out form?..likewise, is it possible to perform a math calculation on a number entered into a field and have the result automatically defaulted to another subsequent field?

Enter Data Into PDF Form Fields
Is it possible to use PHP to fill in fields in a PDF form? The form can be found at :PDF form The background to the question is that I have a client who has a debt collection database system written in DataEase that ouputs County Court Summons data on to Court Summons Stationary. This is hit and miss on the printing margins depending on OS system or printer.

The system is being written in PHP so the summons forms could be produced in HTML if the existing PDF form isn't a viable solution.

Displaying A URL Stored In A Table As An Image On The Page?
In a table in my database I have a column for storing the URL of an image of a product. What PHP code would I use to display the image? PHP Code:

Displaying SELECT Results In A Formatted Table
I was wondering how to show a table with a max limit of 20 results per page. I have various data being pulled and its putting it in a table, but its displayed all in one row. I want to format it so its a 4 column/5 row table. With that I then want the page to generate a numbered list at the bottom that calculates how many pages it takes to show 20 items on each. Code:

Displaying SQL Query Results In 3 Column Table
I would like to be able to display the results of an sql query in an html table, but the results need to be displayed in three columns, for example:

Column 1   Column 2   Column 3
Result 1     Result 2     Result 3
Result 4     Result 5     Result 6
Result 7     Result 8     Result 9

I've tried to find the answers on the internet but i can't find anything that suits my needs!

Reading Form Data In Fields Are Unknown
I have a project where the users can modify their forms and thus their form field names. Is it possible to simply read what is passed through the headers without knowing the names of the fields.

Displaying Multiple Queries To Same Table Excluding Different Rows!
i've got a table with 224 town listings and their ID's in it from 6 counties, and I want it to displayin a 6 columned table, each county getting their own column. Anyway, here's what I've got and what's happening: PHP Code:

PHP Script To Sort Data/create Pages According To Fields?
Someone fills out 3 fields. (There will be more but this is just to
give you an idea)

1. Country
2. State
3. City

I want this script to generate a web page and list the people by
information submitted.

eg. Everyone that put in USA will be listed on a page.

or

Choose California and everyone that typed in California will be listed
on a page.

I can also create links with criteria at the end. eg.
mysite/search.php?=montana

This script will also accept data from people. So people will visit,
type of the form and if the information is valid (not spam) then
they'll be in a database and able to be sorted.

Looking For A PHP Script To Sort Data/create Pages According To Fields.
eg.

Someone fills out 3 fields. (There will be more but this is just to
give you an idea)

1. Country?
2. State?
3. City

I want this script to generate a web page and list the people by
information submitted.

eg. Everyone that put in USA will be listed on a page.

or

Choose California and everyone that typed in California will be listed
on a page.

I could also create a link with the search term at the end. eg.
mysite/phpsearch=?montana

This script will also accept data from people. So people will visit,
type on the form and if the information is valid (not spam) then
they'll be in a database and able to be sorted.

Redundant Data Display Based On Multi-value Fields
I have a website where I want to send an email out to a bunch of users of all the new content posted that day. My content is tagged in different genres or groups. A piece of content can have multiple tags. So an example would be that my content is called "Video Program A" and it has been tagged in the vocabulary "Genre" as "Horror" and also as "Narrative". So in my email, if a piece of content has been tagged more than once, all the other fields get printed out multiple times, too. How can I make it so that even if the there are multiple termname and vocabname data, the rest of the data (title, description) only gets printed out once? Code:

How To Populate Data Into Text Fields On Page Load??
I am creating an account management page that shows the user's contact information and I would like to populate the textfields so that the user doesn't have to type in all his information when he wants to change something.  I want to have him type in only the information he wants to change or update. 

I already have the data displayed on the page. But now I would like to take the data and fill in the textfields with it.

How To Transfer A Data With An Id To Another Table From A Table?
how am i going to transfer let say a name identified using the suer id and copy the name to the other table having the same user id>?

Moving Data From One Table To Another Table
Does anyone know how to move one row from a table in a mysql database to another table using php?

Displaying Data
Probably a really stupid question to ask, but if i have a number in mysql lets say 180000 and it represents a price is there a way to change that to 180,000 without saving it in the database like that?

Displaying Wrong Data?
I have a PHP script that inserts data into a database: PHP Code:

Displaying Data In Php - Like HTML?
How do I display data from MYSQL in PHP in an attractive and structured table(HTML) format? For example: I want my database to display all the reviews of a particular movie(like metacritic.com) like this: Code:

Displaying Data From Array
I have a data stored in an array. Want to display it in Internet Explorer... However,could not display it.


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