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!
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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!
Displaying Single Row For Same Column No
I have a table as follows: ---------------------------- Auth Name | Paper No ----------------------------- Gupta 7 Daiya 7 Daiya 8 I want the above table to look like if two rows have the same paper no ----------------------------------------- Auth Name | Paper No | Paper No ------------------------------------------- Gupta 7 Daiya 7 8 Can you please modify the below code: if ($result){ echo "<table border=1>"; echo "<tr><td><b>Author Name</b></td><td> <b>Paper No</b></td></tr>"; $numOfRows = mysql_num_rows ($result); for ($i = 0; $i < $numOfRows; $i++){ $name = mysql_result ($result, $i, "aname"); $email = mysql_result ($result, $i, "apno"); echo "<tr><td>$name</td><td><a href="abstract/$name.pdf">$email</a></td></tr>";} echo "</table>";}
Displaying MySQL Column Names Using PHP
I'd like to be able to display the column names of a table on a page. Is there a way to read that information in using SHOW? And then to display that information again? Or would I have to store these names in a seperate table and display these values? I tried this, but it sure didn't work: $result = mysql_query ("show columns from industries"); print ("<table>"); if ($row = mysql_fetch_array($result)) { do { print ("<tr><td bgcolor=#cccccc>"); print $row["field"]; print ("</td><td bgcolor=#cccc00>"); print $row["type"]; print ("</td><td bgcolor=#cccc00>"); print $row["null"]; print ("</tr>"); } while($row = mysql_fetch_array($result)); } else {print "Sorry, no records were found!";} print ("</table>");
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.
Displaying Information In Prev/next Link?
I have Prev and next link in which it takes information from a Customer table in the database. It supposed display the information in a table but the information doesn't show. The Prev links show. PHP Code:
Selecting And Displaying Information From 2 Tables
I have 3 tables in my database: The client table holds the client name, address, city, state, zip, sub_category and category (and a few other fields but that is not important). In the sub_category and category fields in the client table are just numbers which match the id numbers in the other 2 tables. the category table holds the id number and title the sub_category table holds the id number, title and category (which is just a number that matches the id number in the category table. Hopefully that all makes sense. Now what the problem I have run into is I have a table on my page that loads all businesses for a category. So if a user clicks on the Dining button on the home page a list of all restaurants will display in my table. Well I want the table to show the sub_category the business belongs to, however the field in the client table is just a number. How do I get it to show the text (title) of that sub_category? Code:
Displaying Information In A Update Form
I can display the information in a table. But now I need to display it in a form, so I can edit it and then upload it to the database. I have the form from my upload page, But I can not seem to get the information to appear back in it. Code:
Displaying Database Information In Columns
I have a database with products in and I want iT to automatically show every product on the page. Now I am able to do this easy enough but what I am struggling to do is that I want the products to be displayed in 3 columns. I can get them to display one under the other easy enough but I want them to be in rows with 3 columns instead.
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.
Sending/displaying POST Information Without Using Forms
What I need to do is build onto an existing login form, using POST forms. I would like to have to have to access the existing code, so what I ultimately have to do is write a PHP script that will spoof a form POST. I have found 2-3 different examples, however none of these will send the post, and then go to that page. All that these scripts do is send the post, and keep you on the existing page. The return from the form cannot be displayed in the page with the script on it because of licensing issues. So the script needs to send the POST information to that page, just as a regular form.
Displaying Information From A Database In A Text Field,
I am trying to create an admin page, but before I get anywhere near that, I need to understand how to get data froma database to show up in appropriate form fields *text, textarea, etc...* I am able to get content from my database to show up in my template, now I want to create a page that allows a user to click on a link for which they want to edit the information (name, and bio) So I want that page to show up with a simple form, a text field displaying the name, and a textarea displaying the bio information, so that they can modify it and save it to the database. how do you get the information to show up in the form fields? Code:
Previous And Next Links And Displaying Database Information
I would like to display a listing of files on a web page as follows: If there is only one file: display the section name and then display the current file. If there is more than one file (for the first page): display the section name, the current file and a few archive files. If there is more than a page full (for each additional page): display the section name, and the next set of archive files. This is the code I have been working with (it's a bit ugly, suggestions are welcome). For some reason the second page of listings skips the first item. 1st page lists items 0 through 4, second page skips item 5 and starts displaying item 6. function display_table($sec_id, $num_item){ GLOBAL $link; $updir = "../uploads/"; //maybe this should be a GLOBAL variable??? if (isset($_GET['start'])){$start = $_GET['start'];}else{$start = 0;} //GLOBAL $start; //query DB $query_total = "SELECT file_id FROM files WHERE file_section_id =" . $sec_id ; $query = "SELECT file_id, file_meeting_date, file_meeting_time, file_title, file_modified, file_section_id, sec_name, sec_id, sec_disp_archive FROM files f, section s WHERE f.file_section_id =" . $sec_id . " AND f.file_section_id = s.sec_id ORDER BY file_modified DESC LIMIT " . $start . "," . $num_item; $result = mysqli_query( $link, $query ) or die(mysqli_error($link)); $result_total = mysqli_query( $link, $query_total ) or die(mysqli_error($link)); $num_rows = mysqli_num_rows($result_total); //print $query; //create hyperlinks and display table //display current file /* print "START: " . $start . "NUMBER: " .$num_item . " ROWS: " . $num_rows;*/ /*$obj = mysqli_fetch_object($result);*/ if ($num_rows > 1){ //Display current and archive files //only display current table if start is not set (not on page 1) $obj = mysqli_fetch_object($result);//Call DB $content = "<div id ='MainContent'><p><b>" . $obj->sec_name . "</b></p><table width=ï`%' border=Ƈ'>"; if (!isset($_GET['start'])||$_GET['start']==0){ //for 1st item display file info $content.= "<tr><td colspan=Ɖ' align='center'>Current</td></tr>"; $content.= "<tr bgcolor='#CCCCCC'><td width=ཝ%'>Meeting Date</td><td width=ཝ%'>Meeting Time</td><td width=ཞ%'>File</td></tr>"; $content .= "<tr><td>" . date("F jS, Y",strtotime($obj->file_meeting_date)) . "</td><td>" . date("g:i A",strtotime($obj->file_meeting_time)) . "</td><td><a href='" . $updir . $obj->file_title . "'>" . "View Current File" . "</td><tr>"; $content .="</table>"; print "START: " . $start . "NUMBER: " .$num_item . " ROWS: " . $num_rows; //DEBUG
Displaying Select Information From XML Search Results
I am new to both php and xml. I have a school assignment to update an existing php-based website where I have to display search results from an online library. I can use a url search which returns an XML file that includes tags such as position, title, url, description, date, etc. I only want to display the title, url (preferably the title should be a link to the url), and description for all of the results on my website's search results (different template as well). What classes/functions are available to help me do this? I would appreciate any guidance as well as links to online tutorials etc. that would point me in the right direction. I have read about the general aspects of php, and I have experience with Java and C; but I don't know about xml at all. By the way, the website is running on the school server and has php version 4. I don't think I'll be able to install php 5 but I can probably upload some helper files or something.
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:
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'?
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.
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.
Populating Table Information
I am trying to dynamically generate bgcolors with to help populate some information for a site. Here is the code:
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.
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.
Locating A Table To Input Information To
my code works properly. But the database connection is failing to find the the table. I am using the code below and the echo message ''error finding database table'' the name of the table is fine. ANy suggestion Code:
Hyperlink In Table For Editing Information
What I have is a table with 3 columns, and in the first column, I have it linked to editpost.php? with the id behind it. I need to somehow get that id into the editpost page to bring up the info in 3 text boxes for the user to edit. Not sure as to how to do this. Code:
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:
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 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 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."; ?>
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...
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:
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:
How To Query From One Column Then Sort Using Another Column
I am trying to get the last 100 albums I entered into my database using the album_id (Highest being the latest entry) then sort them alphabetically using the album_title column. I can get the latest 100 easily but cannot figure out how to also sort the results by the album_title before I display them. This is what I have so far which gets what I want but not in alphabetical order. <?php $sqlquery = mysql_query("SELECT * FROM albums ORDER BY album_id desc limit 100", $db); while ($result = mysql_fetch_row($sqlquery)) { echo "<a href='music_info.php?album_id=$result[0]'><span style='text-decoration: none'>$result[1]</span><br></a>"; } ?> I have been trying to add a second ORDER BY to the query like so. $sqlquery = mysql_query("SELECT * FROM albums ORDER BY album_id desc limit 100 ORDER BY album_title", $db); but this obviously isn't the way I should be doing it.
|