Alternating Row Colors With MySQL Results
Is there any way i could make a image for the alternating row colors instead of a strait bold color, for instance:
$color1 = "#CCFFCC";
$color2 = "#BFD8BC";
Would there be anyway to link an image in there? I have tried it this way:
$color1 = "<img src='..style1.jpg'>";
$color2 = "<img src='..style2.jpg'>";
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Alternating Colors In While Loop
I hope I'm not fixing to embarrass myself by asking this, because I have a feeling it is really simple, but has just eluded my brain waves. I have a table with several rows which is populated by a database in a while loop. I don't know how many rows the query will return as it is different everytime. I would simply like to alternate the background color of the table for each row. I have tried this but keep running in to some problem.
Alternating Row Colors On Query Generated Table?
Is there some way to make a table have alternating colors for rows when you're generating the table data with a WHILE statement? You know, row 1 has a gray BG, row 2 is white, row 3 is gray, 4 is white, etc, for as long as there's data. Here's what I'm using right now: $query_RSwho = "SELECT * FROM tbl_indv ORDER BY name ASC"; $RSwho = @mysql_query($query_RSwho, $connection) or die("Couldn't query: " .. mysql_error()); while ($row_RSwho = mysql_fetch_array($RSwho)) { if ($row_RSwho['name'] != "X") { $names .= "<tr align=left><td width=120>".$row_RSwho['name']."</td><td align=left> -- ".$row_RSwho ['email']."</td></tr>"; } } So, in that WHILE section, is there a way to alternate bgcolor table cell tags?
Alternating Row Colours
I am trying to get alternating row colours but cannot get this to work. Here is what I have, Code:
Alternating Colours For Every Other Record...
I was just looking at some site, and was wondering how they do it so its sort of like this: Record 1 - Back colour = Red Record 2 - Back colour = Blue Record 3 - Back colour = Red Im sure its not too difficult, just wondering how its done.
Search Results ($num_rows) Does Not Match $search Results (PHP,MySQL)?
For example, when I do a database search for a term I get 2 results but the $num_rows says there are 3 results. I suspect it's because there are similar keywords within different search fields of the SQL statement. But I am stumped as to how I can change this. Any Suggestions? the code:
Background Alternating Colour Code
Im having problem making my background alternate between colors. Following is my code, the result alternates 2 colors ok, but prints each entry from my database 30 times. Code:
Calculating Colors
wondering if anyone has built or knows of a script out there that will calculate and output all of the websafe colors as hex values.
Manipulating Colors With Php
Say I have a user submitted hex value of #CC0000 (red). Is there a way to darken it (to value #660000 for instance) on the fly?
Changing Colors
I have this form where you can submit a DJ line up for an event. I want the user to be able to change the font color whenever they wish, and when they hit enter, for it to skip a line. I would like the to be able to do this without them knowing how to use the <br> and <font> commands. Kind of like you see on a phpBB board or something But is there a way to make this button, and when the click it, it keeps the text that they have already entered into the textarea adds a [ i ] or whater and then when they click the button again, it inserts the [/ i ] without altering the text they already typed. it would be much like the buttons you use to do your PHP and color changes in this forum, but without the pop-up window to enter your code into.
Display Alternate Colors For Each Row
I wrote a code to display some values taken from text file in the webpage. I am using a function to display alternate colors for each row. I am getting breaks at the end of each column which I should not get. Code:
GD Choosing What Colors To Display
How can i use the GD Library to only show the White (or the hex value of white) pixels of a image? Imagine i have a 8 color picture in PNG format. This is to use on a color puzzle that im trying to build... 1 - The user sees a completely BLACK image with the original size of the picture 2 - the user selects GREEN (from a color palete) 3 - the image updates and shows all BLACK/GREEN pixels (using something like "ShowImage.php?c=BG" or anything else) 4 - the user selects RED (from a color palete) 5 - the image updates and shows all BLACK/GREEN/RED pixels (using something like "ShowImage.php?c=BGR" or anything else) and so on... Is this possible using the GD Library? I can read the file from PNG and show it (using the gd library), i can even change the pallete of the image based on another file's pallete, but i wanted to dynamicaly change which colors to show on screen, based on user input.
Imagecopy Save Colors
is there a way to copy two images using gd and save the colors? I've been able to get the two images copied but the second image color changes based on the first ones color. I want to preserve both colors independently of each other.
Random Text & Background Colors?
Is there a way to generate colour hex strings that are guaranteed to be dark and thus good as random-generated text colours? something like ------------------- srand((double)microtime()*1000000); function tc() { $frag = range(0,6); $text = "#"; for ($i = 1; $i <= 6; $i++) { $text = $text . $frag[mt_rand(0, count($frag)-1)]; } return $text; } $text = tc(); -------------------- is what I have in mind.... but I really don't know how the hex codes for rgb realte to "darkness" And while I'm on the subject, whats the converse (for pale colours, for backgrounds) look like?
Gd Library Bug? Image Lost Colors
is it a php bug or i do smth wrong? From site I`m taking images (those thumbs) and its name at right. Then i generate with those elements png image I make big ligh yellow rectangle with smaller rectangle: once grey, once white. At those rectangles i put names (with ImageTTFText) and images (imagecreatefromjpeg). And finall image look... ugly. Look at this, most colors are lost http://www.linux.webd.pl/allegro/ I have to admit that if i do not attach thumb images, colors are good. Can i fix something or i it is libgd bug?
Print Table With Background Colors
I've a table in wich I've this CSS: ..oddrow{background-color:#FFFFFF} ..evenrow{background-color:#CCCCCC} The oddrows are white and the even are grey. BUT ! when I do print the table, there is nothing !!!
Detecting HEX Codes For Similar Colors
Is there any way by which i can detect the HEX codes for similar colors if i input a color code ? What i mean if if i enter the color code for an Orange, the output should be another shade of Orange. This can be seen in action at http://feeds.feedburner.com/~fc/GotChance?bg=FF9900&fg=000000&anim=0 If you change the "bg" parameter, the background color changes to that color and a similar shade is applied to the smaller background. How do i do something like that ? Also, how to i find HEX codes for complement colors ?
Background Colors On Display Pages
Is it possible to display table data using a while loop, yet have each output row with a certain bg color depending on a value within that row. For instance, if I'm dislaying the incomes of various businesses, I want to show the business with a positive income with a green background, and the business with a negative income with a red background. Is this possible?
Using GD Library To Create An Image Overlay For Colors?
I'm creating a script that will generate a user avatar based on some inputted variables, like armor type and color. my biggest hurdle right now is trying to figure out how to add color to a section of an image using GD. Say someone wants their helmet to be green (now, only one part of the helment should be green, the rest should stay grey). I thought about making a mask in photoshop of the area that is to turn color, make that white, and the rest of the image transparent. So you now have 2 images. The greyscale helmet, and the mask that fits OVER the helmet image which you intend to color and blend. Still with me? If so... I've done that. I've got my helmet image, and the mask which covers the areas I want to change color with solid white. Now, my issue is, if I add color to my mask image, and then overlay it, the transparency of the mask is GONE. The whole image becomes green! Only the white is supposed to turn green!
MySQL Results Not Working So Hot
Ok. Here I am again....probably posing a question with a solution so easy that, after looking at it for an hour, I can't figure out. Ok. here's the deal. please review the code below. Looks simple enough, right?
If/then Within MySQL Results List
I want to list job opportunities for a facility. If there are jobs in the database, I can list them without a problem. But if there are no jobs, I'd like to echo a line something like: "No jobs right now, come back later." But I can't get that line to echo. PHP Code:
Mysql Writing Results From 51 To 100
Can someone write me a mysql_query code which will get me results from 51 to 100 from $database? Don't suggest me working with indexes, because i'm also deleting some rows (for example #1 is filled #2 is not, #3 is...)
Show Next Results Of MySQL DB
How do I get it so that php reads in the first 10 results out of a MySQL database. Then when Next or something is hit it displays the next 10 results and so on.
MySQL Results To Return Only One Value
For example, I have a column that has three different values, 1, 2, & 3. In the database, there may be over 500+ entries with one of these values assigned to it. How can I get MySQL to return just 1, 2, & 3 only once rather than several hundred times.
Hyperlinked MySQL Results W/PHP
I was wondering how results to db querys have attached links to each individual result? I have a good grasp of basic PHP & MySQL, but don't understand how that works. For example, if you have a db of products, all with individual id #, how do you get one product from the query a <ahref>? Could someone explain?
Compiling MySQL Results
Does anyone know how to compare multiple results from a MySQL query? For example, I would like to query the database and collect all the results into a variable (perhaps $totalresults). Then, I would like to use a single statement to compare each of the results within $totalresults to the statement's conditions.
Getting Results From MySQL Database In PHP
I am trying to write a php page which connects to a MySQL Database which is supposed to get the results from a table within a database and display the results in a table. Below is the code that I am using:
Limit Mysql Results
I have a script which has a mysql query which returns 20 results - I want to add some validation so if my variable ($var) is empty, it only allows the user to select the first 5 results my code is: - $sql = mysql_query("SELECT * FROM greetingcards_cards WHERE category='$cat' LIMIT $from, $max_results"); while($row = mysql_fetch_array($sql)){ $image = $row['url']; $cardid = $row['cardid']; echo "<br><img src="$image" /><br><a href="?function=sendmessage&cardid=$cardid">Pick this card</a><br>";} I want it so that if the variable is empty, instead of displaying "Pick this card" it displays - "You must register to pick this card" and have a different hyperlink Is this type of validation possible? if so how is it done?
PHP MySQL Order Results
I'm using: $sql = "SELECT * from $myTable ORDER BY `points` DESC LIMIT 5"; in a whileloop to display the top five scorers but would like to put their position next to the results (eg, 1, 2, 3, 4 and 5) Is there an easy way to do this?
Convert MySQL Results To XML
I just got Dreamweaver CS3, and I love the built in SPRY framework. It allows you to create web applications that use a table listing, and details listing very quickly. Unfortunately the only data the SPRY framework can accept is XML. Is there a built in function to convert from a $row result from MySQL to XML? Code:
Mysql Results - Ordering Them.
i need an mysql query to rank the results, like SELECT field FROM table and to order them greatest to least by the value of a different field.
Mysql Results Pagination
I have a php code to split the results of a sql query over pages taht works great... But I need to add some feature, I need to add that if there are more than * pages it shows me "..." instead of the hole numbers of pages.. Code:
Sum All Of My MySQL Integer Results?
I have a bunch of rows, and for each row, the column "rating" has a number from 1-5. I need to add all of these together, so like if there were 3 rows with 5 for rating, it would return 15. If it's possible to do it with an SQL statement, I'll like it to average them.
Splitting MySQL Results
So I have a database, and I want to split the results into 2 columns. I don't want to alternate them, but have the first half in the left column, and the second half in the right column. How can I handle this so that it does it automatically no matter what number of entries (and so that if it's an odd number, the one overflow is on the left).
Parsing PHP Code In MySQL Results Set?
I have a PHP script that pulls content from an MySQL database and returns a result set. Is there a way I can put PHP code within a field in the database and have that code parsed as PHP code on returning a results set? If possible, I want just one field of the database parsed for PHP code. The results set is return as a straight result, not within a loop. Just inserting the <? PHP code thus ?> returns that as sources code not parsed.
Populating Array With Mysql Results
I'm returning a result set of one field in a table, and want to populate an array with the results. I can't for the life of me figure out a simple way to do this without using mysql_fetch_array() to cycle through the results, append that to a var, then explode that into a var and pass that. PHP Code:
MySql - Outputting Results In Groups
I want to output mysql data by groups (states). However each time php/mysql comes to a new state in the results I want it to print the state name before putting the results. Does php have some sort of memory function to recognize when the state has changed?
Mysql Results Output Problem
I trying to set up some subdomains and I'm at the early stages of just testing the the thing . I have set up a small test DB, with the following fields, company, id, url. I have also set up a test page to see if the output corresponds with the subdomain name. If the domain exists the result with echo "domain exists" if not it will output "does not exist". But the page just says "does not exist" all the time even though the domains are set up.here's the code:
Exploding Results Of Mysql Query
I have a table with times and dates listed like this: 0000-00-00 00:00:00 2003-09-20 20:26:22 etc etc What I want is to query the DB for the field (matchdate) and then get it to explode the ' ' to give jsut the date for me and then put it into a dropdown in a loop. this may sound easy but i too sleepy to work it out and searching aint good.
Store Mysql Results Into An Array
i just started using php. i've used it before as a maintainer. fun stuff. well now i'm the writer. i want to abstract all the DB commands away from myself and all other developers. so i'm writing a function to query the php database from all users of the database and store them into an array as a return value so that i can seperate my database code from my html creation code. 1. is there a way to put all my database functions into a php file and include that file into all my other php pages? similiarly to a #include in C++ or a import package name in Java? 2. my code to run down the fetched results and store them into an array doesn't seem to be working the way i want it to. if i print out the results from the mysql returned fetch the data is fine. however the array seems to print out "Array[elementnumber]" instead of the value. Code:
Mysql Results <-- Previous Row, And Next Row, Showing Next Ok
I query a database and return a result on the column "reference". There might be 7 listings. Each row is displayed in a table, with links through to a detail page. I am working on having a "previous" record and a "next" record link on the detail page. This code below works, for the "next" record, by searching the values in the array $myarray for the variable $ref. It then returns the key value and the key value, as a number, is deducted by one and plus'd by one to give me the previous row and the next row. Returning the value of the next row works a treat, but for some reason the previous row, deduct 1, while it echoes a value to screen, doesn't work. This is the code: (query database and then:) //$ref is a variable carried into the page $num_rows = mysql_num_rows($result2); $i=0; while ($i < $num_rows) { $next=mysql_result($result2,$i,"reference"); ++$i; $myarray = array("$i"=>"$next"); foreach($myarray as $key=>$value) { if ($value == "$ref"){ $b=($key); $c=($key+1); $a=($key-1); }} if ($a == "0") { echo "No Preceding Record"; } else { if ($key == "$a") echo "<a href=../detail/index.php?name=$value>Previous Record</a>"; } if ($key == "$b") echo "This is the current Record"; if ($num_rows < $c) { echo "Records End"; } else { if ($key == "$c") echo "<a href=../detail/index.php?name=$value>Next Record</a>"; } } } else {
JOIN Table Results W/MySQL
I have a query with a simple JOIN. For example: SELECT * FROM Companies INNER JOIN CompanyTypes ON Companies.CompanyID = CompanyTypes.CompanyID The query returns all fields from both Companies AND CompanyTypes. I would like all fields from Companies only.
Counting Results From A Mysql Database
I want to know how many results throw a query in order to know if they have reached a limit.I.E. $sql = mysql_query ("select * from classifieds where user='$username'"); while ($row = mysql_fetch_array($sql)){} I want to check lets say that only 10 classifieds per 'username' can be created. If ten or more classifieds are in the database for that 'username' then show error message.
|