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




Display Database Output In Mutli Column Html Table


I am building an HTML form using data from a mysql query. The data to be displayed on the form is 1 column from the db - but multiple rows. Because there are many rows (well, only about 100+) in the table I want to be able to put 2 or 3 (space permitting) rows from the result on each row of the HTML table with a checkbox beside each entry from the db table. The idea is that the user will scroll down the list and check up to 4 or 5 boxes before submitting the form and I didn't want them to have to scroll ALLLL the way to the bottom (100+ rows). I understand how to get data from a db table and put it into an html table, but I cannot figur out how to put more than 1 row from the result on to the same row of the html table.

I hope I haven't confused anyone reading this -- If I am way off base with what I am trying to do please give me alternatives. I am trying to avoid paginating the data for a couple reasons a) clicking a next and/or prev button is more hassle than just scolling down a list and b) the data in the column being displayed is only about 35 - 40 characters and it seems to be if i only placed one result row on each html table row, there would be a lot of wasted space.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Display Sql Query Output In Html Table
As evident from a previous post, I am a php noob. I would like to
display MySQL query results in an html table with one of the row values as a
category and the rest of the data displayed under the relevant category.

I can get as far as displaying the data in a nice readable format but I
don't know how to have the records placed under their corresponding
category. This is my code thus far (sans the html output):

....ORDER BY cat ASC'
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
printf("%s Class: %s Description: %s", $row["cat"]$row["title"],
$row["desc"]);
}

Display HTML Before PHP Output?
I have a menu that outputs an RSS newsfeed using a PHP script (CaRP -
however it ALWAYS displays the PHP
outputted HTML before the embedded HTML. This happens regardless of the
order; HTML first PHP second, or visa versa. I am assuming that the PHP
engine writes the PHP output first by default??

Is there a way to force the PHP to output in the order it is
"written"...at least, can I control it?

Valid MySQL Database/table/column Name Regexp
regular expression in PHP which could be used to
check that a proposed (My)SQL database/table/column name is valid, i.e.
shouldn't result in an SQL error when created?

The user of my (hopefully to be opensourced) program has the ability to
create database/table/column names on the fly.

I'm aware of obvious characters such as ., [space], things like >, etc.,
which won't work, but haven't been able to source a definitive list,
including having googled the MySQL site.

Obviously certain characters need to be filtered out, as noted above, but
I want to be as unrestrictive as possible; hence just [a-z]* isn't good
enough because things like _ are acceptable.

Ideally, I'd prefer a regexp that applies to _all_ vendors' databases, not
just MySQL as I'm about to migrate the program to being
database-independent, probably using PEAR DB, but even a MySQL-specific
regexp would do the job.

In the longer term, I plan some sort of entity conversion script so that
theoretically any character could be used, using some sort of escaping
mechanism probably.

Tricky Html Table Output
I have a bunch of Result objects in an array. I want to output a summary table for those results. A Result object has the following attributes:

1. species
2. tissue
3. stage
4. gene
5. sex
6. replicates
7. value

The db query returns the rows sorted by species, then tissue, then stage, then gene, then sex. The object attributes will be the table headings (<TH>).
Each row of the <table> will be divided into 3 subrows- 1 for each sex: male, female, mixed ( it's all PG here!) .

All of the above is straightforward. However, I would like to print the value of attributes 1-4 only if it is different from the row above: ie

Species |Tissue|Stage|Gene|Sex ...
bug|ear|first|brca|male
...|...|...|...|female
...|...|second|...|male
spider|toe|creepy|hox2|female

The only php solution I've come up with is putting all the object attributes into a multi-dimensional array and then checking if current value=old value as I nested loop my way through the array. Needless to say, not very elegant.

Any thoughts on how this could be cleaner? I can just output the table with all the values filled in (that's easy), but I believe the relavant data pops out more if there is less verbiage.

Output Query Results To Html Table
I have a MySQL table "products" and I want to output product's data to html table as below:
- A products contain 4 fields: image, name, description, price.
- 4 products is nested in 1 html table 4 rows x 4 columns.

Code:

Output Database Entries In A Table
I'm trying to display the entries in a table of two columns, one entry per table cell - in other words, two entries per row, number of rows based on number of entries in the database. But it still doesn't seem to work. It displays one entry per row... I don't know where the problem is. Here's my code:

Display Results From Query In HTML-table
I'm working with PHP3 and Oracle 8. Can anyone tell me how to display the results from a query into my HTML-table?

Getting Results To Display In Two Columns Of A HTML Table
How can i get the following script to display in two columns of a HTML table? At the moment i have it displaying in one column. If there are 5 results from the DB then the left HTML table column will display the 1st, 3rd and 5th result. The right HTML table column will display the 2nd and 4th results. Code:

PHP Function To Display A Database / Table Structure?
My webhosts cpanel is down for maintenence, including phpMyAdmin, and I need to view my database structure... Is there any function in PHP to display the database structure (like the "Export" function in PHPMyAdmin)?

Display Items From A Mysql Database In A Table
I am trying to display items from a mysql database in a table but I need it to start a new table row each time multiples of 3 rows of the database table have been displayed like the following example:

item 1   item 2   item3
item 4   item 5   item 6

Does anybody know how I can make this work using php.

Storing Some Html Text In Database & Display Them
i have some text in HTML format ..i just want to store HTML text in database and retrive and display them as a HTML ...

HTML Table Fetched From A Database
I want to generate a HTML table based on names fetched from a database. The tricky part is that I want to generate the table so that the names is written on both the top row and the left collumn. Should look something like this

----------------------------------------------
| ||NAME 1 | NAME 2| NAME3|
|NAME 1| | | |
----------------------------------------------
|NAME2| | | |
----------------------------------------------
|NAME3| | | |
----------------------------------------------

Hope that anybody has a idea how to solve this.

Multiple Column Output
I want to display a prod catalog wid prodname, color, image etc as 2col x 3 rows, like:

prod1 | prod2 |
colr1 | color2 |

prod3 | prod4 |
color3 | color4 |

and so on...

I have this code, which gives the desired results, but all columns in one line.. i.e.

prod 1 | prod2 | prod3 | prod4 |
color1 | color2 | color3 | color4|.. and so on

i want two columns for each two products, and then rest of two down.. adn so on PHP Code:

Output Column Names
How can I search through a table and output the name of each column?

Two Column Display.
I'm trying to display records in two columns. Here's my logic so far...

$numRows=get the total number of rows
$x=divide total rows in half (rounding up for odd #'s)

do a fetch_array on the query

I store the columns into two table cells, I start the main table here Start first table cell. First column of data=do a for loop from $i=1 to $x break into HTML and start the content. End First table cell

Start Second table cell. Second Column of data = do a for loop from $j=1 to $numRows-$x break into HTML and do content. End Second table cell

If anyone sees something inherently flawed with this or just knows a better way, hints and examples are always appreciated. I am an admitted newbie and very used to ASP, so I I think the problem comes from not being able to advance to another record manually. But then again, I really don't know what I'm talking about.

Display One Column But Store Another Value
So my form is going to contain some drop down boxes and I want to display the name of my "category" [use category table shown below] but store in the database the "category.ID" for the particular category. I have been able to grab the "category" names from TABLE:category and get them to display in the dropdown box, just need to be able to store the value "category.ID" of what we choose into another TABLE:call in field "call.category"

Hope you understand what I'm trying to say. BTW, this is currently working fine in MS ACCESS, but we want better use in mySQL/PHP on our Intranet. Code:

Mysql Php Display Column In Dropdown?
is it possible to show a column from mysql in a dropdown and then when that row is selected to display the information in an editable form ??

Two-column Display Ordered Alphabetically
I'm trying to list meteorological data reports, from an ever-varying number of locations, in two columns, side-by-side - the first half of the reports listed alphabetically in the left column and then the second half of the reports listed in the right column so that the list runs alphabetically down the first column then goes to the top of the second column and continues down from there.

In the example below, numbering the locations for the purpose of the example, it has to be something like this, using, say, 60 locations - Code:

How To Display Newly Added Mysql Column
I have a mysql table and i want the user to add columns using a php
interface and then display the table with the newly added column. I
was thinking about putting all the columns names in a special table
but there must be another more efficient way.

as an example this is my query to display the table:
$result = mysql_query("select * from news");
while($r=mysql_fetch_array($result))
{
$title=$r["title"];
$message=$r["message"];
//display the row
echo "$title <br> $message <br>";
}

now if the user alter the table and add a column "rank", how can i
update my query automatically so it can display the newly added row
(or column)?

Column Table
I have a table of records; the records belong to different user ids and are distinguishable by a reference number, Each record has a price. so theres a price column.

The problem isnt getting the total of the whole column. the problem is getting the total for the specific user id and displaying it at the bottom of the price column.

Column Data From One Table To Another
im trying to get the vend_name column data from one table(manuf) into another table (products2) that has the same vend_name column which is empty but has a vend_code column as a key identifier.

im wondering if theres a way to put the data from the vend_code column and vend_name column from the first into an array so that i can populate the vend_name column of the 2nd table

this is what ive come up with below, it seems to be just puting the last record into those two array variables PHP Code:

Building Table By Column Rather Than By Row
I'm currently looking for a way to populate some html tables of varying lenghts and widths, pulling the data from arrays. I want to achieve this with a function in order to make this as dynamic as possible. example: function build_table($data){ ... }

$data would be an array containing a varying number of sub-arrays, the first array would populate the first row (column headings) and each subsequent array would be the data for each column rather than each row. Code:

Check If A Table Has A Column Or Not?
I've got a training center for a bunch of different animals, but these animals don't have the same stats. So, basically, I want all of the animals to be available to train, and if they try to train an animal, I need code that checks if there is a certain column in a table, or if that animal has a specific stat. How would I do this?

Create A One Column Table
Using the following code, how do I create a one column table, with "Firstname, Lastname & Sex" as the heading.

Also, how do I display the row data (i.e Firstname etc) using the following format?: Code:

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!

How To Check For An Existing Column In An Table?
how can i check with php a table for a column. if it doesn't exist i
want to create it.


Updating Column In A Table Using Phpmyadmin
i have about 60 records in a table and in each there is a column called itemtype which is empty i need to update all of them to T how can i do it easily

SELECT * FROM Table WHERE Column IS NOT NULL
I am running the following MySQL query:

<?php
$sql = mysql_query("SELECT * FROM comics WHERE story_arc IS NOT NULL") or die (mysql_error());
while($row = mysql_fetch_assoc($sql)) {
echo $row['title'];
}
?>

The problem is that it is outputting all 4000+ records, when it should only be about 100. Is there an error with my 'IS NOT NULL'?

Showing Everything In A Column In A Mysql Table
Need to know how to echo an entire column in a MySQL table. I've tried various things but they only echo the one at the top.

Search Only Works With Table Column Name
I have tried several different codes to create a database search of a table that includes column name "Product," "Price" and "InStock."  I am trying to search the "Product column and in each code when I enter a term I know to be in the table it comes up with an error (usually "Unknown Column 'input' in 'where' or

mysql_fetch_array(): supplied argument is not a valid MySQL result resource in").

The only way the search works is if I enter the actual name of the Column (in this case "Product") and it displays the entire table.

Recursive Array From A Twin-column Table
I have a MySQL table with two columns: catagory and parent. Parent contains the parent catagory of the catagory. I need to query the db ONCE, assigning the info to an array, then create a recursive array parenting catagories and grouping accordingly.

List Db Results Vertically In 2-column Table
i'd like to display mysql query results in a two column table, however, with the results displaying vertically starting in column 1 then continuing into column 2.

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!

Select From Drop List To Fill Table Column With Text -- HOW ?
I want viewers to compare state laws on a single subject.

Imagine a three-column table with a drop-down box on the top. A viewer
selects a state from the list, and that state's text fills the column below.
The viewer can select states from the drop down lists above the other two
columns as well. If the viewer selects only one, only one column fills. If
the viewer selects two states, two columns fill. Etc.

I could, if appropriate, have a separate htm page with the text for each
state -- california.htm for example. When the viewer selects California from
the drop down list, the column below would "fill" with California.htm.

Or, I could conceivably use a text or mysql database with two fields for
each record: state_name and law_text -- but it would probably be easier to
use separate htm files, since there will only be about 20 states involved,
and the "database" would never have a large number of records.

The table width would be 100% and each cell would be @33%

My site is designed with FP 2002 and runs on Apache/FreeBSD. I have just had
Apache-ASP installed but I have not yet configured or used the module.

Displaying Output In Display Area
the following is an example code only. i want to display the echo output commands into an iframe or equivilant within the page itself and not on a new page as the default does.

if im using the incorrect terminology please forgive me. but i cant think of a better way to explain it and so far no one seems to have the slightest clue what i mean at all:

Grab Content From HTML Table And Place Into MySQL Table?
I am in the process of helping a co-worker upgrade some of his old static html pages into dynamic MySQL driven pages. He currently has a lot of pages with huge tables displaying data. Does anyone know if there is a script or class that can convert a table to a .sql file for upload?

Having Trouble In Adding 1 To A Database Column
I am making a voting poll. The trouble is that I can't make the database add 1 to the column that has been selected.

Database Column Type And Length
Does anyone know how to extract the Database column type and length from a PEAR class? I'm using PHP with postgresql Basically, I'm running a query object which is returning a series of rows (see below). I'd like to extract the column type and length as well.

$FieldFetch = "Select * from Person";
$FieldResult = $DBSession->simpleQuery($FieldFetch, DB_FETCHMODE_ASSOC);
$FieldCount = $DBSession->numRows($FieldResult);

Problem Displaying One Column Of One Row From A Database With PHP.
I have a small script with PHP that queries a MySQL database to pull
out one row, where I want to be able to access each of the columns
separately. I have tried several different variations and am able to
get the entire row to print, but when I attempt to access the
individual columns I get an error. Here is what I have so far:

if (isset($_POST['memberNo'])):
$link = mysql_connect('...','...','...');
mysql_select_db("...");

//Perform a test query
$query = "SELECT * FROM users WHERE 'id' = " . $_POST['memberNo'];
$result = mysql_query($query) or die(mysql_error());

$line = mysql_fetch_assoc($result);
print $line;

//Close connection
mysql_close($link);

The point of this code is to retrieve the user information to validate
the login information sent in the previous form. I do not get an
error with this code, but it also does not print anything. I know
there is an entry in the database that matches data sent in the
$_POST['memberNo'] variable, it is the only entry in the database.

Changing the 'print $line;' to 'print $line["id"];' does not display
anyting either.

Changing Database Column Datatype
I want to know, how do you change the data type of a column in MySQL, without stuffing up the database.

Display MySQL Output Multiple Times
Hey, being a newbie at all this, I was wondering what's wrong with my code:

Creating "newspaper Column" Output
Anyone out there have any tricks or scripts to take some text of
unknown length and display it in two (or more) columns of equal
height?

The text may or may not contain "hard-coded" linebreaks or other
formatting such as [UL]s.

why there's not a columns tag in HTML is mystery:

<COLUMNS col=3>
wouldn't this be grand
</COLUMNS>

Search And Replace Database Sites Column
Im trying to search and replace database sites column options with $snr which is set by the user.

Database Column Matching Elements Of PHP Array
I've got a PHP array with 10 user ID values. I want to run a SELECT query to find all the rows where the UserId column matches something in my array.

Output Into Table
I'd like to output some query results in a table, each result in it's own column and row. Here's an example --

***********************************
IF ($result){
echo "<center><table><tr><td>";
while ($r = mysql_fetch_array($result)) {
$number = $r["stock_number"];
$description = $r["item_description"];
echo "$number<br></td>";
echo "<td>$description<br>";
}
echo "</td></tr></table>";
} else
{
echo "No data.";
*********************************

Except it doesn't work correctly. What is the proper way to accomplish this?

Table Output With While Loop
I'm trying to get a basic format of outputting a table with x columns when using a while loop? Like, PHP Code:

Table Output As Hyperlink ?
i am trying to create a table generated from a MySQL query with some of the output as hyperlinks. in this way i intend that the users of the site click to see the customers registered and then click on the "hyperlink" of their customer id, which will navigate them to details about that user on another php page. PHP Code:

How To Output From File Into Table?
I have this bit of code that opens a file, reads it line by line, and
prints the filename into an image on screen, so i get a big list of
images on the page.

However I want it to output into a table so I can have 2 photos side by
side as it goes through, is there any way of manipulating the code to
output one line into one cell and the next line into the next cell then
back to the first cell again???

<?
$data = file('gallery/captions');

foreach ($data as $line)
{
list ($q, $a) = explode('|' , trim($line) );
echo "<img src='gallery/images/$q' height=100><br>";
echo "$a<br>";
}

?>

What Is Indexing In Mysql And How It Will Be Useful And How We Can Retrieve Database Content Easily From A Database Table Containing About 5lakhs Datas
I need to select data from a database table containing huge amount of
data. Now I am storing data using one primary key and I am just using
simple select statement, and this process gives me the output but it is
taking long to execute the query. As much I had heared I want to use
some indexing or cluster indexing which might help me but I am not so
familiar with these things.


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