Jump to content

atravotum

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Everything posted by atravotum

  1. If its in a database as a post then to the best of my knowledge its been stripped of its previous html format. You would have to write a function that runs through the post, looks for a particular string say http://www.blah.com, omits it and replaces it with your html tag upon printing to the screen. There are a variety of string functions in php that could do this pretty painlessly.
  2. Hmm I wish I had a direct answer for you, however I do have a far fetched idea. When I was coding the mail function I had this... $to = $_POST["to"]; $from = $_POST["from"] . "\r\n"; $subject = $_POST["subject"]; $message = $_POST["message"]; $headers = "From: $from"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail($to,$subject,$message,$headers); The only difference in our two scripts is I create the mime, and content type last, you pile stuff on after it. Try calling that last and see what you get, just a thought.
  3. Hmm I'm not quite sure on some of the code you have, its not code I have used however... If I had to take an educated guess you should be able to put replace your for each loop, with the while loop i gave you. Since they both aim to accomplish the same task.
  4. This topic is getting heated. Just a small note though, Almost 99% of the time designing a website to be pixel perfect is a very bad idea. There is not to many ways to guarantee your viewer is going to see it as perfectly aligned as you have it :/. The whole key to your site is to make sure everyone is able to view it accurately, rather it be odd ball screen resolutions, or outdated browsers you have never even heard of. If your a business and some 80yr old man goes to your site and cant find the checkout button cause you made it pixel perfect and he has a screen res not even existent today you just lost business.
  5. I think this is what your aiming for //Process to pull the data from a file, one line at a time. Then checks if the line has data, if it does send it to be processed and stored. $file=fopen($file_temp,"r")or exit("Unable to open file!"); $i=0; while(!feof($file)) { $strings[$i]=fgets($file); if((trim($strings[$i]) != "") && $strings[$i] != NULL) { echo $strings[$i]; } $i++; } fclose($file); Thats a piece of code i used to pull data from a csv file line by line store it to an array throw it into a function to handle the commas and return the separated value. Hope it helps!
  6. Session start needs to be at the top of the page
  7. Im going to have to take guilty's side on this one film god. There is absolutely no reason not to use tools given to you. Making more work for yourself is hard enough. Copy and pasting is nowhere near as proficient as using say Visual web developer to literally create your pages for you every new file. That would be like me saying "No its much easier to type this to you in binary what use would i have for a keyboard." Get to a level where you do this for a living and need to produce high quality work in a time crunch and you will find tools work a lot better. There is nothing wrong with hard coding when you have to (most server side languages you will, most scripts your write you will). But when your designing a site that has scripts you need to hard code why not punch the GUI out the way quick and easy? Not to mention does your notepad do a browser or cross platform check? Theres time lost, does it have a built in color wheel when you need to hit the right shade? Theres time lost, does it auto tag things for you? Theres more time lost, does notepad publish your site for you? Nope more time lost....
  8. I'm not trying to top on the negative here however... The design def needs some work. My first thought was front page editor. While I am still new to web design (sorta) I work with web pages all day. Trouble shoot them really, I see a lot of template driven site, and that looks very template driven. There is not to much dynamic to it. Also as a graphic designer your site is going to say worlds about you. Imagine when you go to buy a car lets say. If you walk up and the owner of the car is driving a beat up pinto whats the first thing thats going to run through your mind? Your website IS YOUR BUSINESS CARD point blank. From my point of view at work I get to take a unbiased look at a lot of sites. My job again is to analyze and troubleshoot. Statics show most common readers will not stay longer then 7 seconds on your page unless you can hook them before that. Your content HAS TO BE CLEAR AND APPARENT. The site has to be pleasing to the eyes, or no one will want to sift through it. Also to a point I agree a portfolio should contain work others may find relevant however it should as stated above still only contain your best work. The portfolio is a section of your accomplishments, putting anything undone, or half done well says to customers "Hey I don't finish things, or I do not give it my all". I am not trying to be harsh (seems to be a theme on this topic). But you asked for honest opinions, I would say try to take this project from a more professional stand point. Be your worst critic you will come a lot further!
  9. Well yes it can, but it can assign values to variables within classes as well. Consider it sorta like " 's ". So dog -> bark() would be like saying dog's bark function. Or dog -> health = 20; Would be like saying Dog's health equals 20. So it is really just to access code more or less within an object or in this case a class.
  10. lol sorry, i was assuming that was a given
  11. I actually read through it to compile the example for you. I have used it in c++ before for pointers i think but that was while ago. The cool thing about classes is you can create new ones on the fly. So if you were making like a pet program to train them you could copy the dog class on the fly and assign it an instance so it can hold variables like health, and weight, and be separate from the other instances of the dog classes. Thats the cool thing about oop (object orientated programming).
  12. To further that point say you had a class named dog. You could code functions within dog like say bark. So if you wanted to call bark you would use that sign example class Dog { public function bark() { echo "Roof!"; } } //Then to call it you would say $dog -> bark(); This would echo "Roof!";
  13. I was actually wondering that myself
  14. There not to much different then tables really. <div style="overflow:scroll;">Content Here</div> That would give you a div that will scroll. Div layers are good cause you can target them with CSS easily, and create ones that scroll both directions, only 1 direction. Can position them practically anywhere. I would google it if your interested. Might make your project a bit easier.
  15. Nothing displayed ??? However I would agree with the above mentioned. I'm not sure why you need the send button in an iframe (or why you even need one using ajax) but it would be best to keep the send button on the stationary page. This way the only thing you would need an iframe for is for the messaging window. I would suggest just using a scrolling div layer however, i have built a chat using php and found it to be easiest. Ajax can update it all the same.
  16. I agree with the method above, you will have to create a statement that runs a check for the link clicked, then pulls the data from a database and displays it. However I was going to mention... If you wanted to take it a step further and have the content update upon clicking the link w/out having to reload the page you should look into incorporating ajax into your script. You could use the ajax to send an xmlhttp request to pull the data and update a div layer holding your body content without needing extra pages, or reloading the page as the usual php request methods do.
  17. I feel your pain I was writing a program that did a similar function. What I ended up doing was writing an entire relay script to interact with my databases. This is the function i setup to pull data out of tables dynamically. // get - retrieve data from the database. Gets stored to a singe array. function f_get_all($db_name, $db_user, $db_pword, $db_table) { /// Connect To Database $con = mysql_connect($db_name, $db_user, $db_pword, $col); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db($db_user, $con); //Pull the data from the database, and store it to an array. $result=mysql_query("SELECT * FROM $db_table"); $i = 0; while($rows = mysql_fetch_array($result)) { for($j = 0; $j<$col; $j++) { $rows_temp[$i][$j] = $rows[$i][$j]; } $i++; } // Disconnect from database. mysql_close($con); //Return the array return $rows_temp; } //This is the call to the function, which stores data in a multi-dimensional array $rows = f_get_all($db_name, $db_user, $db_pword, $db_table); That should pull all fields out of the database and store it to a multi-dimensional array. You then run a loop to count how many rows, and how many columns the array has. Set up an (i,j) for loop to push them all to a table. Hope this helps.
  18. I have recently been introduced to the wonder that can be AJAX. As is I am a preferred php coder, and would like to keep it that way. From everything I read php can do anything asp.net can do. I'm not going to get into that whole enlarged debate, but point being I prefer php. This being said I would very much like to stick to php. My complication lies in support for AJAX. Now I know AJAX does work with php. However when looking for examples of what AJAX can do I was able to find very lush visual examples that only seemed to be in asp.net. The php examples I found in theory could do the same I suppose, but I was unable to find any of those lush examples using php to work with AJAX. ??? So the question came up is php equivalent in terms of power to asp.net when using AJAX. Or to restate can php do everything in AJAX that asp.net can do? If anyone has any thoughts, or comments feel free to share, I want to soak in whatever I can get. Hopefully I can stick to my beloved php.
  19. Ok nvm I managed to get a work around. The basic problem I think is simply MYSQL does not like odd field names. I just created the first data row as the field names works like a charm. Thnx to everyone that tried to help.
  20. This may be a bit much but what I do to test my code is upload it to my web host. There are providers out their that offer free hosting if you own a domain name. I use godaddy, buy a .info or something for like $4 and get a free hosting account for the year. Just make sure to pick linux to test the php, found that out the hard way! But $4 a yr for a workable environment i thought was pretty good. Lol plus you would be a customer so you can always call and complain when something breaks
  21. Sry about the code thing I was not aware. I don't post on forums often. Answering the mad, I have tried declaring it as an array and if it was static data normally you would, but $col is already an array so it double declares it and produces $col to = array when it gets into the relay script.
  22. sry i typoed *fix below* the 3 lines WERE commented out properly for($i=0;$i<count($col);$i++) { //$col[$i] .=" varbinary(".strlen($col[$i]).")"; //$bob=$col[$i]; //$bob.=" char(15)"; //f_mod_table($db_name, $db_user, $db_pword, $db_table, "ADD", array($bob)); }
  23. Ok so here is the run down. I am trying to make a script for one of my bosses at work. The point is to upload a csv file, convert it to separate fields and store it to a database. Now the upload works fine, the conversion goes smoothly. But when i try to upload it to a database the fields just are not being created. This involves 2 scripts for truncating purposes I will post what is needed. Please any help is appreciated. Note: Im convinced the problem is converting it to a mysql friendly format, as if i pend varchar(blah) to the end of anything it post some of the fields but not all. Script pulling the csv file, converting it, then punches to a relay file. <?php REQUIRE 'relay.php'; global $strings, $cmd, $db_name, $db_user, $db_pword, $db_table, $file_temp; $db_name=$_POST["name"]; $db_user=$_POST["user"]; $db_pword=$_POST["pword"]; $file_temp="supdashboard.csv"; $db_table = "test"; $col=array("bob", "frank"); //f_mod_table($db_name, $db_user, $db_pword, "csv", "ADD", array("bob varchar(15)"));//$db_name, $db_user, $db_pword, $db_table, $cmd, $col); //f_store($db_name, $db_user, $db_pword, "csv", array("bob"), array("uhhh")); //Output a line of the file until the end is reached $file=fopen($file_temp,"r")or exit("Unable to open file!"); $i=0; while(!feof($file)) { $strings[$i]=fgets($file); str_handle($strings[$i], $i); $i++; } fclose($file); for($i=0;$i<count($col);$i++) { //$col[$i] .=" varbinary(".strlen($col[$i]).")"; /$bob=$col[$i]; /$bob.=" char(15)"; /f_mod_table($db_name, $db_user, $db_pword, $db_table, "ADD", array($bob)); } //f_delete_table($db_name, $db_user, $db_pword, $db_table); f_create_table($db_name, $db_user, $db_pword, $db_table); f_mod_table($db_name, $db_user, $db_pword, $db_table, "ADD", $col); //f_store($db_name, $db_user, $db_pword, $db_table, $col, $data); //Process the strings to convert into data to be uploaded to the database. function str_handle($tmp_str, $i) { global $col, $data; if(($i == 0) && (strlen($tmp_str)!= 0 )) { $i=0; $x1=0; $x2=0; while(strpos($tmp_str,",") != false) { $com=strpos($tmp_str, ','); $par=strpos($tmp_str, '"'); if(($par < $com) && substr($tmp_str, 0, 1) == '"') { $tmp_str = substr($tmp_str,($par+1)); $par=strpos($tmp_str, '"'); $x2=$par; $col[$i]=substr($tmp_str,$x1, $x2); $tmp_str = substr($tmp_str,($par+1)); } else { $x2=$com; $col[$i]=substr($tmp_str,$x1, $x2); $tmp_str = substr($tmp_str,($com+1)); } $i++; } } elseif(($i != 0) && (strlen($tmp_str)!= 0 )) { $i=0; $x1=0; $x2=0; while(strpos($tmp_str,",") != false) { $com=strpos($tmp_str, ','); $par=strpos($tmp_str, '"'); if(($par < $com) && substr($tmp_str, 0, 1) == '"') { $tmp_str = substr($tmp_str,($par+1)); $par=strpos($tmp_str, '"'); $x2=$par; $data[$i]=substr($tmp_str,$x1, $x2); $tmp_str = substr($tmp_str,($par+1)); } else { $x2=$com; $data[$i]=substr($tmp_str,$x1, $x2); $tmp_str = substr($tmp_str,($com+1)); } $i++; } } } ?> This is the relay script executing the push (i coded it as well but it has tested successfully on many trials when testing with static data) This is just the function in question also. //Add or delete fields from an existing table function f_mod_table($db_name, $db_user, $db_pword, $db_table, $cmd, $col) { // Connect To Database $con = mysql_connect($db_name, $db_user, $db_pword); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db($db_user, $con); // Counts the size of $col $num = count($col); // Checks to make sure $cmd is valid if($cmd != "ADD" AND $cmd != "DROP") { echo "Invalid paramater passed into $cmd. Needs to be either \"ADD\" or \"DROP\"."; } //If command is valid perfomrs either add or drop function per number of columns else if($cmd == "ADD") { for($i=0;$i<$num;$i++) { $sql="ALTER TABLE $db_table ADD COLUMN $col[$i]"; mysql_query($sql,$con); echo $col[$i]. " Stored! <br/> "; } } else if($cmd == "DROP") { for($i=0;$i<=$num;$i++) { $sql="ALTER TABLE $db_table DROP COLUMN $col[$i]"; mysql_query($sql,$con); } } // Disconnect from database. mysql_close($con); } Again any help would be appreciated its a freelance thing for my boss so hes not going to kill me anytime soon, but i would still like to put it behind me.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.