premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
[SOLVED] How to group by name with color group ?
premiso replied to plodos's topic in PHP Coding Help
<?php function random_color(){ mt_srand((double)microtime()*1000000); $c = ''; while(strlen($c)<6){ $c .= sprintf("%02X", mt_rand(0, 255)); } return $c; } $data = mysql_query("select * from data where country='greece' group by name ORDER BY id ASC"); //ORDER BY id ASC // define our variables $colors = array(); $last_name = ""; $output = ""; while($info=mysql_fetch_assoc($data)) { if ($last_name != $info['name']) { do { $color = random_color(); } while (in_array($color, $colors)); $colors[] = $color; } $output .= "<p style=\"TEXT-ALIGN: justify\"> \n" . " <font color=\"#".$color."\" face=\"Verdana\" style=\"font-size: 7pt\"><br> \n" . " " . $info['name'] . "<br /><br /> \n" . " </font> \n" . " <font face=\"Verdana\" style=\"font-size: 7pt;\" color=\"#".$color."\"></font> \n" . " </p> \n\n"; $last_name = $info['name']; } echo $output; ?> I must have been in a nice mood (or really bored). I re-formatted your html output, simply because you were taking the time to indent it but not properly breaking it (the \n) so now when you view the source it should look "pretty" and easier to read. Also removed some non-essential excess lines. Notice the do while, it stores the last color used in an array, this is to ensure that the colors are unique by looping until it gets a unique color. The color randomizer will only run if a new name exists. Added the ORDER BY id ASC clause to the SQL query. Tested with an Array I created and seemed to work just fine. I also changed the 7 or 8 prints to be appended to an output. Then you just echo or print that output after the while loop. More efficient. I also properly indented your script for easier readability. Also had to move the $color generator into the while loop, how else do you think it would be re-generated to be random? -
Unfortunately we do not know your setup. We also do not know what you have tried to do in the past. Compiling PHP with the Oracle functions, should work with oracle database. I have never compiled PHP with that, but the manual should explain everything that you need to do get it working properly. We cannot see your server and do not have access to it. Nor would I want access. When you say "vendor" you mean your host, if it were me I would ask for an in-depth explanation on how to set the variables or what they need. If you have changed the mssql_connect function to the oci_connect function and you have Oracle enabled on the server, then make sure your connection string is correct. See the function manual for proper usage. If, however, Oracle is installed as a PHP extension correctly, the manual pages for the Oracle functions should help you figure out where you are going wrong. If you did in fact just rename mssql_connect to oci_connect without modifying the parameters, that may as well be the issue. But you will also have to redefine the database host and user/password if it has changed.
-
http://us3.php.net/oracle
-
If your output is www.aaa.com/ and you just want www.aaa.com simply use substr... $url = substr($url, 0, (strlen($url) - 1)); Should chop off the last character for you.
-
Pay attention in class, read the chapter, and more importantly....TRY IT YOURSELF FIRST. PS: Daniel, that is the best bit of PHP Code I have ever seen written. That would definitely get me an A on this homework assignment if I turned it in!
-
[SOLVED] Displaying images from a directory...
premiso replied to jderosa3's topic in PHP Coding Help
What happens if you add the http://www.xyz.com onto the path? echo "<img src='http://www.xyz.com{$jpg}' /><br />"; If that does not work try this to remove the initial dot: $jpg = substr($jpg, 1); echo "<img src='http://www.xyz.com{$jpg}' /><br />"; And see if that makes the image display. -
[SOLVED] Displaying images from a directory...
premiso replied to jderosa3's topic in PHP Coding Help
Why do you have the initial . ??? Try removing that and see what happens. @xtopolis glob carries the directory path with it, if it was specified in the search terms. -
[SOLVED] Displaying images from a directory...
premiso replied to jderosa3's topic in PHP Coding Help
mmm no. $dir = "./flash/portfolio/branding/images/"; $jpgs = glob($dir . "*.JPG"); foreach ($jpgs as $jpg) { echo "<img src='{$jpg}' /><br />"; } But that will only pull JPG that end in all caps. So if the .jpg is all caps or all lowercase modify accordingly. -
need help with condition to be specified inside a cell
premiso replied to alexmathayes's topic in Javascript Help
I think you need javascript. But I also know that your description is, as Ken put it, far too confusing. Take a deep breath and explain a bit better with some example code. I am moving this to the Javascript form, as I think you want this action done on the client side without a page reload. -
[SOLVED] Displaying images from a directory...
premiso replied to jderosa3's topic in PHP Coding Help
If all you are looking for is a file name. Try glob. $jpgs = glob($dir . "*.JPG"); foreach ($jpgs as $jpg) { echo "<img src='{$jpg}' /><br />"; } A bit less code and easier, in my opinion. As far as it showing an x, the path needs to be relevant to the actual web path not the server path. So make sure that is what it is doing. -
The code can be improved, but it all depends. To resize an image you tend to need about 2-3 times the size of the picture memory limit, but again it depends on the code. Because you have to read in the picture, create it as an image then take that image and resize it to a new image (unless you want to original resized) then you have that image. But my bet is your code is eating up the memory in an non-efficient manner and can be cleaned up to use less memory. Show some code and maybe we can help you make your code more efficient.
-
In this calc_title.php?id=20&type=games&s=6&i=1&list=coll&collection=yes&trade=yes&unmark=Unmark+for+trade There is no "&submit=Submit Changes". Thus $_GET['submit'] is never being set. I do not know if submit buttons do not pass their value through to get. I never use GET for forums unless it is a search form, so yea.
-
http://www.google.com/#hl=en&q=php+myspace+clone&fp=aaV-kzfDWBk You can find "clones" but you will have to pay. To make a site like myspace is basically just a blogging network. WordPress MU maybe the solution for you as it is free and is a multiple user blogging software.
-
$_GET['submit'] You do not have "submit" set in your get data. It never gets passed the first if.
-
Put them outside of the root directory and make a download script to access/dish out the file to the user. Alternatively, you can just make the link available to the user and not the world. If google cannot see the item it will not index it.
-
The programmer who thought it up decided he wanted to say hello to the world, and not the earth. And since the phrase was so "catchy" it just stuck through out programming history as the basic item to do to show how a program can output data. The gist, someone thought it up and implemented it and it just stuck over time cause people liked it.
-
Are you sure about that. Because according to the error, it is not defined. I would verify that the product.inc.php is in the correct spot and has the code (meaning you were not editing a different file by accident).
-
Good Programming and Web Design Books
-
Not to mention if it is equal to 1 in the first place, how will it ever be equaled to 25 ???
-
Too bad books do not show proper code (although that one is not too far off). <?php session_start(); if (isset($_GET['logout'])) { if (isset($_SESSION["auth_username"])) unset($_SESSION["auth_username"]); echo "You are now logged out. <a href='login.php'>Login Again</a>"; // note change this to be your login page form. exit; } $passwords = array("jordan" => "monkey", "gareth" => "rhino", "chris" => "lion", "vanessa" => "tiger"); if (!isset($_POST["username"]) or !isset($_POST["password"])) { echo "You must enter your username and password"; exit; }elseif (isset($passwords[$_POST['username']]) && $_POST["password"] == $passwords[$_POST["username"]]) { echo "Login successful"; $_SESSION["auth_username"] = $_POST["username"]; }else { echo "Login incorrect"; } ?> Using isset on data that may or may not be there is good practice to avoid notice errors. Rename auth.inc to auth.inc.php as with the .php it will hide your code. .inc anyone can see the code. <?php session_start(); if (!isset($_SESSION["auth_username"])) { echo "You must be logged in to view this page"; exit; }else { echo "Hello, you're logged in!<br /><a href='login.php?logout=true'>Logout?</a>"; } ?> Now, "how it is not working" I do not know. It seems legit and fine to me, please elaborate on that for further help fixing. You also have to remember everything is going to be case sEnSiTive. Are you sure the session was not set previously? Try closing the browser then going to a page that you include the auth part in. EDIT: Added a logout feature for you. Try logging out then going back to the login page. This way you can easily test it without having to close the browser each time to logout.
-
If you want to just "make" sure that something is do-able, why not create a test script and code something into it...that will tell you without having to modify your entire code. Hell I still create small test scripts to test theorys, new functions, or code I am modifying and planning on implementing before I modify my script to use that code. This way I can fix any issues that arise at the source and not have to worry about going through my script and fixing it there. Less code to look at the easier to fix in my opinion. Just do not be afraid to create a test script and test stuff out. It will not bite you, I promise.
-
It will be, but with CSS/Javascript you can hide the iframe until the link is clicked. Once the link is clicked you change the source of the iframe to be what you want and un-hide it. As far as my code not solving the issue, I did not think it would, you probably left the "target=" part inside of the link which as you can see I did advise you to remove that out of the link. Since there is no "frame1" on that page the target opens in it's default behavior (a new window).
-
http://www.google.com/#hl=en&q=javascript+dynamic+iframe
-
$sql = mysql_query(sprintf("SELECT email, level FROM $tbl_name WHERE email='%s' and password='%s' and confirm='%d'", sanitize($_POST['email']), $md5pass, (int)1)); //......... // A matching row found (thus the name/pass found) - authenticated list($email, $level) = mysql_fetch_row($sql); Notice that you were fetching the row twice. Chances are the second row never existed thus level was never being properly set. The above is how it should be done. Also notice I defined the two columns that you were using and in the order that I listed them to prevent other issues from occurring. This way you know what data to expect.
-
I think you want to look at Javascript/CSS for this. As it will not require a page reload. If you want it to work though, remove the target="frame1" out of the link, as there is no frame1 on that page since the if statement has not ran and change your if to be this: if (isset($_GET['v'])){ echo" <iframe name='frame1' src='{$_GET['v']}' width='500' height='330' scrolling='no' frameborder='0' style='margin:0px auto;' ></iframe> "; } But, I think you are confused with PHP. I would recommend you look into using Javascript/CSS for this part. As that seems to me to be what you actually want to do and not have to have a page reload.