How Do I Split Into 3 Columns With Array?
The script below works great, however it displays 396 thumbnails. What I would like to do is organize the look and feel better. I want o be able to display the thumbnails in 3 columns rather then scrolling down for ever looking at all the pictures. So how would I make it to break into 3 columns? .....
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Split Text Into Two Columns
I want to be able to split the contents of a text field into two or maybe three columns. The text field contains text AND HTML mark-up. My initial thought was to find the middle character and then go to the nearest space and split the text that way, but it sometimes splits in the middle of an HTML tag: not pretty! My next idea was to strip the HTML tags from the text and then split it up and then reapply the HTML tags, but I am not sure this would work either. Has anyone come across this problem and do you have a solution or know of one? I would really appreciate it.
Split Up An Array From The DB
I have a complicated one mostly logic. Tried some stuff with no results. Problem: I have a DB that should have been 2... no fault of mine. Needs: I have an array I want to break up based on same values in a column and print out each of these new groups separetly * there is 6 possible values in the column to be seperated * 6 new arrays I have the idea butt he code is complex for my level.
Split An Array
array("a", "b", "c", "d", "e"); I want to now be able to load "b" into a variable ($var) then print it out print $var
Sorting A Multidimensional Array On Two Columns
I'm working on some low-tech sort of content managing system. It uses textfiles as a kind of database so the users don't have to install SQL on their server. Now I want to perform some sorting on my files. These are the contents of one of those files. PageName;Template;Menu;Sub; Introductie;1;1;1; Opnemen;1;2;0; Voorbereidingen;1;2;2; Kwaliteit;1;1;0; Blabla;1;2;1; I first read this file into $someArray with file() and then I parse each row with explode() into columns. So $someArray[2][2] contains the value 2 and $someArray[0][2] contains "Sub". I want to sort this array on both Menu and Sub and write it back to the file. It should look like this. PageName;Template;Menu;Sub; Kwaliteit;1;1;0; Introductie;1;1;1; Opnemen;1;2;0; Blabla;1;2;1; Voorbereidingen;1;2;2; I want to make a list of menus and their listed submenus in the proper order, as you can see . What is the clever way to do this? At this moment I use a loop that sorts the submenu in a loop that finds the right menu in a loop that sorts the menus. No, it's not you, I don't understand it myself anymore. That's because I don't understand most of the array principles and functions.
Split A File Into An Array.
I know how to load a file into a script, I was just wondering how to take this information, which is from a text file, and put the text in there into an array. For example the text string is this "netprofit 2.3% schools 4.5%" I want to be able to break this apart and list the values into a table. I want to open the file, and be able to list the values, 2.3%, and 4.5% from a array. Do I need to use the explode function to do this?
What Is Best Way To Split Numbers Into An Array?
Looking for a function to split numbers into an array for use in a simple graphical counter. Objective: $count = 12345 //want to end up with $array[0]=1 $array[1]=2 $array[2]=3 //and so on then I can do this $size=sizeof($array); for ($r = 0; $r == $size; $r++) { echo "<img border=Ɔ' src='_borders/$array[$r].gif'> "; }
How To Sort An Array, Leaving One Or More Columns Unsorted?
to PHP and have very little knowledge of programming in general, so I may be missing something obvious, but I can't find a solution to the following difficulty in either the PHP manual or Google. I have a tab-delimited text file containing numerous lines of data, which is searched for matches to a query from an HTML form. I want to be able to sort the resulting two-dimensional array of matches by one column only, leaving the other columns unsorted. For example, if three lines match "bar0", foo02 bar01 foobar foobar foo03 bar02 foobar foobar foo01 bar01 foobar foobar should become foo02 bar01 foobar foobar foo01 bar01 foobar foobar foo03 bar02 foobar foobar not foo01 bar01 foobar foobar foo02 bar01 foobar foobar foo03 bar02 foobar foobar The following method works for sorting on the second column, but seems both inelegant and inflexible (especially if I want to sort on the third or fourth column instead: #v+ <?php $data = file("filename.txt"); $sortkey = 0; foreach($data as $line) { // if the line matches a regex, do this: $temp = explode(" ", rtrim($line," ")); $newdata[]= array($temp[1], $sortkey, $temp[0], $temp[2], $temp[3]); $sortkey++; } if(sizeof($newdata) > 0) { sort($newdata); foreach($newdata as $line) { echo $line[2]." ".$line[0]." ".$line[3]." ".$line[4]." "; } } ?> #v- Is there a less clumsy way of doing this kind of thing without having to use a "real" database? I've tried all the inbuilt array-sorting functions, without any success so far.
How Do You Split A String Using Split()?
I have this PHP statement which works fine and breaks down a string of lines delimited with a into an array. $arrList=split("", $strList); But what I really want is to be able to tell it to split out only the strings that start with the letter "b". E.g. I thought this would work "bW" I tried every regular expression but cant figure it out. I could use some other function combinations to achive this but I though if there is a way to do it with just split()...
Sortable Columns
Hi there, I am new to this Forums...I am currently learning PHP and I was wondering if any of you guys knows how to make columsn in a table sortable. What would I have to change in the code? Thanks!
UPDATE Columns With PHP
So you know I'm going through Kevins book. I'm updating data in a test table. I'm adding names to each joke, say I have 7 jokes and 3 of them go to the same person. I can update each one seperately but I can't find a way of bulk updating. In this case it's not a problem. I've looked though Kevins book and a couple of others but can't find anything. Tried several sites to but I may just be searching wrong. I can do this: mysql> UPDATE Jokes SET AID="1" WHERE ID=2; but I'd like to update WHERE ID equals 2,3,4,5 all at once.
Columns In Html
I am trying to make a table with two columns. I am really close. The problem is the table's first row has three TD's. ie one two there four five six seven PHP Code:
Sortable Columns
Does anybody know here how to make columns in a table sortable? I know that with a sql query I can accomplish that. PHP Code:
Grouping The Columns
Let's say I have a very simple Table: +---------------------+ | id | name | level | +---------------------+ | 1 | Adam | 1 | | 2 | Jack | 7 | | 3 | Bill | 1 | | 4 | Pete | 3 | | 5 | Ross | 7 | +---------------------+ but I want the PHP to output their id's and names, but group their Levels together like so: Level 1: Adam (id: 1) Bill (id: 3) Level 3: Pete (id: 4) Level 7: Jack (id: 2) Ross (id: 5) And then afterwards, If I create someone with a new level, PHP will automatically create a new heading (e.g. Level 10) and put the corresponding names under it. How should I approach this? Should my PHP contain two "while"s? Or do I use the SQL <group by> function?
Displaying Columns With A Value
what is the most efficient way to display column names from a database that only have the value '1' in its fields?? I cant seem to work it out, could someone give me a code example??
Creating Columns
I've been using this code to split records from a db into columns when it displays the data. Items are shown with 3 on a row and then a new row starts. It works really well but if ever there is only one item on a row it causes me a problem in this instance. I have far left and far right columns which display a background image, which is a border. The problem is this only works if there are three columns visible in a row. Is it possible to manipulate the following code so that there are always three columns present, they're just empty if there's no more records to fill them? Code:
Count The Number Of Columns
I was wondering if there is a way to calculate the total of columns in a table? (something like $totalRows= mysql_num_rows($Recordset1); , but than for columns)
Best Practices For Sortable Columns
I have several forms that display information from the database after users log in. I would like the column titles to be sortable so that when the user clicks on a column heading, the data re-displays in sorted order of that column. Next time they click on it, it toggles the order from ascending to descending, and then back to ascending again. Since I have many forms and each form has different columns, I was wondering if there was a method that would be better than a brute force approach. What are the best practices for this functionality?
Query Results In 2 Columns?
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?
Index On A Combination Of 2 Columns ?
on a Mysql table i have 2 columns: - banner views - banner clicks now i want an index on the MySQL table so that i can make an overview with the order set to bannerclicks/bannerviews so i need an index on (bannerclicks / bannerviews ) is there a way to do this in MySQL without the need of an extra column ?
Searching Several Columns In MYSQL
I wonder if anyone can point me in the right direction on this, I am trying to search multiple columns on a single database and display the info. I have this set up but it only queries one. $query_rsSearch = sprintf("SELECT * FROM database WHERE column1 LIKE '%%%s%%'", $colname_rsSearch); The above works fine for one column but I am having difficulty making it search more than one, I have been trying this method. $query_rsSearch = sprintf("SELECT * FROM database WHERE column1,column2 LIKE '%%%s%%'", $colname_rsSearch); But continually get error messages?
Combining Two Columns In A Select
I have two tables with the same fields, and I wish to select one field from them. However, i don't want two columns in the result, i want one column which is the first table's column and the second table's column combined. (this is so I can order them and have the order include both tables) Code:
How To Sort 32 Photos Into 8 Columns?
i want to sort a collection of photos into 8 columns...but i don't know how to do it? Let's say a user inserts 26 photos and i want to sort it in 8 columns and 4 rows, how can it be done?
Database Tables And Columns
Is there an easy way to display in my browser window all of the tables and their corresponding column names for a selected mysql database?
How To Make Table's Columns?
I have some pictures in database and I want to show it on my webpage. The problem is, I want to make those pictures are shown on a table with 3 or 5 columns before new rows. For example, I insert this code <?php while ($data = mysql_fetch_array($show){ echo"<table> echo"<tr><td><img src='$url/thumbnails/$data[image]'></td></tr></table>"; to show the pictures from database, the pictures will be shown vertically with only one columns. Could anybody tell me how to get some columns before new row? I hope you understand my question. I have no idea how to find the keywords for googling.
Total Table Columns
I have a report that pulls data from a mysql table and generates a html table with the data. I need to sum up the columns into 2 separate fields I think I need to access the result from the query but do not know how. Code:
ORDER By (dividing Two Columns)
Im making a gallery which allows users to rate the images. I have two columns noOfRatings (which hold the no of tiems an image has been rated) and totalRatingScore (which holds the total of all the ratings for that particular image) I want to make a sort option e.g 'sort by highest rated' Is there a quick way to return the recordset ORDERED by highest rated.. i wa thinking somethign along the lines of SELECT * FROM TABLE ORDER BY noOfRatings/totalRatingScore Can i do it this way or is some special techinque needed?
Putting Results Into Columns
I am creating a directory of businesses for a web site. There are 8 main categories (dining, bars, entertainment, etc) and when a user clicks on a category it takes them to a page that lists all the businesses (and phone numbers) in that category in alphabetical order. The problem I have is that it does so in one big long column. Can anyone help me alter the code to display the results in 3 columns? I do want to keep them in alphabetical order, however if that is straight across or down does, it does not really matter to me. And I am fine with losing the Character (A, B, C, etc) header above each set if needed. Code:
Combining A Few Columns Into One Column
I am transferring data from one script to another script and the new software that I downloaded requires that I have multiple items separated by | in one field. The way I have it now is in 4 different fields. The way it is set up is like this: Table Freelancers Field1 expertise1 Field2 expertise2 Field3 expertise3 Field4 expertise4 Each of these fields have one integer in each of them representing a specific occupation. Each freelancer had 4 occupations that they could choose. This is the data from the old site. On the new site, there is also a list of occupations (in a text file) that is different from the old list. For example, web design = 4 on the old site, and web design = 24 on the new site. So I want to take the 4 occupations (expertise1, expertise2, expertise3, and expertise4) and combine them in a 5th field. I set up a 5th field called specif_occupation to combine the data in ... the information should look something like this when combined |4|5|8|14|76| I only need to know how to combine the 4 fields into 1 field. I could figure out the rest (probably, I'm out of practice).
Split Q
is there an easy way to split a string on SPACE except if that SPACE is within QUOTES? i.e. - $str = red green blue yellow "blue green" returns [red,green,blue,yellow,blue green] ?
Select Distinct Values In Only 2 Columns
I have a table where a customer may have multiple accounts. I want to eliminate duplicate values for Customer_ID and Account_ID -- regardless of their state or region. I tried this, SELECT (DISTINCT Acct_ID, Cust_ID), Address, City,State, Zip,Country, Contact, State_ID,Region_ID, FROM t_table but it doesn't work. This (below) does work, but it gives 2 records. One record when a person is listed once in a target state, and a second record if that person is listed in an overlapping region. SELECT DISTINCT Acct_ID, Cust_ID, Address, City,State, Zip,Country, Contact, State_ID,Region_ID, FROM t_table (this is the same as) SELECT DISTINCTROW Acct_ID, Cust_ID, Address, City,State, Zip,Country, Contact, State_ID,Region_ID, FROM t_table Is there any other way to select distinct values in only 2 columns?
Equal Height Columns With 1px Border
I need content boxes equal height with 1 px border, i tried this one http://www.positioniseverything.net...ple/equalheight , but i think it doesnt work standard for a 1px border, is it a good idea to measure the text with php to solve this?
Displaying Rows Of Data As Columns?
Does anyone know of an efficient way to retreive data from a mysql db and display the record rows as collumns? I have been doing this: <display headers> <while ($row = mysql_fetch_array($result)) { > <display row 1 of result> <display row 2... } > <end table> but I want to do this instead: <col 1 header > <row 1 col 1> <row 2 col1> <row3 col1> <col 2 header> <row 1 col 2> <row 2 col2> <row3 col2> <col 3 header> <row 1 col 3> <row 2 col3> <row3 col3>
Columns In A Form Select Element
Can this be done. I am wanting to have columns in my forms select element. I have data of varied length from three fields. Can this be done, or should I try and stuff spaces into the select element to asume columns
LEFT JOIN, Two Similar Columns
In my left join there are two columns that have the same name.. How can I get their different values when rgetting them through an array?
Searching Multiple Mysql Columns
I'm currently building a database of local businesses, I'm quite new to using php and mysql. While I'm mostly managing to stumble my through it, a couple of things are confusing me. This is one of the things. If anyone can help, that would be really great. Ok, so I've build a search page, and a results page and it works great but there is one problem. Currently it will only search through the 'name' column, but I'd also like it to search through the 'type' column at the same time. This is the code I'm using to fetch the results $colname_Businesses = "-1"; if (isset($_POST['search_par'])) { $colname_Businesses = $_POST['search_par']; } mysql_select_db($database_HBBA_DATABASE, $HBBA_DATABASE); $query_Businesses = sprintf("SELECT * FROM Businesses WHERE name LIKE %s", GetSQLValueString("%" . $colname_Businesses . "%", "text")); $query_limit_Businesses = sprintf("%s LIMIT %d, %d", $query_Businesses, $startRow_Businesses, $maxRows_Businesses); $Businesses = mysql_query($query_limit_Businesses, $HBBA_DATABASE) or die(mysql_error()); $row_Businesses = mysql_fetch_assoc($Businesses); I'm not sure what to add in to make it also search through the 'type' column or where to put that. Can anyone point me in the right direction?
Dynamically Create A Table's Columns
What I'd like to do, is take the selected rows from my database, generate columns dynamically to reflect the "size" column, and then dump the data respectively into the table that is generated. Here's what I've got so far: Using this database: What I've done is given each row/column a designation by assigning a X,Y value (tag_no, size). I created an array that uses a key in the same X,Y format. I loop through the rows to dump the array value that corresponds to the key. The data doens't display correctly if I there are multiple tag_no's that have the same sizes, with different quantities. 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.
Want To Split Text With The Tab
i want to split a text by using <tab> as a key but how i detect that is the <tab> for example: 0807040009298 19862.090 16611.969 11980 M i try to split to individual record but i cant.
Split/explode - There Must Be A Way!!
I have a text string, say $text = "abcdefg" and I want to split/explode it up so that each individual character is stored in an array. I've tryed explode, but it wants a delimiter - any ideas?
Preg Split
Trying to split a string where there are occurances of a space, a comma, a newline (char 10), or a return (char 13) using the preg_split function, but not sure how to write the regular expression for this...
Explode, Split, Or Something Else
I have a string that looks something like: <some stuff><some more stuff><etc>. I want to seperate the information based on ">", but by using explode and split it gets rid of ">". I don't want that to happen. Is there a built in function that I am overlooking that will do this?
|