Jump to content

nisroc

Members
  • Posts

    40
  • Joined

  • Last visited

Everything posted by nisroc

  1. Hello all This may seem stupid coming in here with absolutely no code to show. I am in planning of a php event calender for my work place and I am a very PHP rookie basically i am asking for directions to go with this. I have written scripts before but not like this. I currently have a database set up for the events and about to write to that databases table. I have date as a primary key and in format of date (2012-05-14). what i am trying to figure out is how do i take this date have it find the correct day on the calender? I hope someone can help me a little here i know i have asked a lot but could use a point in the right direction. Thank you, Nis
  2. That helped big time. I though browser was running slow cause of the image size now that i added that small part you suggested it is running normal again. ty
  3. What i am trying to do is create a gallery by using the paths to a folder as links, example is <a href="../gallery/scenes"> ... and ../gallery/cities.... I have a sidebar menu populated like this and works fast so i wish to keep it. Now in my main content area i have a php script that will read the directory contents and display the images in the folder into a div. I have two questions; <?php $path = "gallery/scenes"; $dh = opendir($path); while (false !== ($file = readdir($dh))) { if ($file != "." && $file != "..") { echo "<img src=\"$path/$file\" height=\"100\" width=\"100\" />"; } } closedir ($dh); ?> First is, folders are generating thumbs.db file when the images are called to the page. it has not affected me that i can see but i would like to cancel it out from the script anyway. To do so i wish to filter the db extension, but i do not know how, A little shove/push in right direction should help me here. Second Like i said in fist paragraph, i want to have a links that that point to a directory and that when clicked will trigger the script above. My problem is how would i trigger this script from a link? I really do not wish to create whole new page for each gallery. Thanks in advance for any help on these problems
  4. I have a forum which i wish to write text to a textfile. So far all has gone great until I added a function to what I want to do. Im not getting any errors but i am also not getting a textfile. Any help ... please The form; <form id="addlinks" name="addlinks" method="get" action="functions.php?action=addlink"> enter new link<input name="newlinkname" type="text" /> enter directorty<input name="newlinkdir" type="text" /> <input name="Save" type="submit" value="Save Changes" /> </form> The Function <?php function addLink() { $myFile = "testFile.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = $_GET['newlinkname']; fwrite($fh, $stringData); $stringData = $_GET['newlinkdir']; fwrite($fh, $stringData); fclose($fh); } ?>
  5. I got it working nicely thanks corbin and alex. I looked at the errors you both pointed out and studied up on them played with it a bit and it fit right in. I do have another question here. This is a small database and will only be used once within the page. This page is included into the main page. My question is if i wanted to have show previous quote, random quote, next quote can it be done? like i said this is an include page not a page that stands on its own. I worried that i will sit there and try figure out how to do this then find out the include page will open up after alone a when one of the features is used.
  6. Im very new to php/mysql and what i am trying to do is pull a random quote from a table and display it on a webpage. So far the code below is what i have but does not appear to work. On the database table I have ID and quote, id being the entry of the quote. Can anyone please help me figure out what i am doing wrong? <?php define ('HOSTNAME', 'localhost_or_hostname'); define ('USERNAME', 'username'); define ('PASSWORD', 'database_password'); define ('DATABASE_NAME', 'database_name'); $db = mysql_connect(HOSTNAME, USERNAME, PASSWORD) or die ('Cannot connect to MySQL.'); mysql_select_db(db); $query = "SELECT * FROM quotes WHERE id=1 and id=2 ORDER by rand() LIMIT 1"; $result = mysql_query($query); echo $result; mysql_free_result($result); mysql_close(); ?>
  7. What I am trying to do is make a entire static webpage but the one table cell that holds the main information to the site will change when a user clicks a link. I have been away from php for quite awhile but recall doing this with a link like, <a href="www.something.com" name="main">anchor</a>. then i would have a script that would call the main content when the page loads and when user clicks on a link the table cell changes to the new content. This is the part i cannot recall how to do. Now i have tried several methods but they keep loading the outside page as a page by itself. Any help on how i could do this?
  8. ah thanks you very much for this explanation Matthew, makes a lot more sense with the \n now and with the code was just wrong char. again thanks
  9. Just started learning php and i think all is going well, but with what i have read so far i have become confused with a couple things and hope maybe some one can explain them better than the book does. 1st. \n I have seen this used in a php before and i do understand that it to start a new line. However when ever I use it in a string i do not get a new line. Problem is i only know one type of output for php and that is a web page. how would i beable to see the effect of \n in php output? 2nd. With this code <?php $money = 30; $pet = "Kitten"; $new = sprintf("It costs $%03.2f for a %s.\n",$money,$pet); $new2 = sprintf("%’.-20s%3.2f",$pet,$money); echo $new; echo $new2; ?> My output is: It costs $30.00 for a Kitten. .-20s30.00 Everything in $new works fine but $new2 should be, "Kitten.............. 30.00". Im not sure why it is doing this. To help anyone figure out why i am using PhpEd to learn on, but after uploading it to my web hosting i got the same output. Any idea why? Thanks in advance
  10. Im trying to get a field to display on the same page by using a mysql table and a form a drop down menu / submit button. The drop down menu is populated with the names fields within the table. When I hit the submit button I want the dynamic data returned for that specific name. I am not sure how to get the forum to react this way. Any help please im very lost here [code]<form id="appview" name="appview" method="post" action="get">   <select name="select">     <?php do {  ?>     <option value="<?php echo $row_appview['gamename']?>"><?php echo $row_appview['gamename']?></option>     <?php } while ($row_appview = mysql_fetch_assoc($appview));   $rows = mysql_num_rows($appview);   if($rows > 0) {       mysql_data_seek($appview, 0);   $row_appview = mysql_fetch_assoc($appview);   } ?>   </select>   <input type="submit" name="Submit" value="Submit" /> </form>[/code]
  11. What i am actully doing here is reating a test. The test results and answers are stored in a database along with the user, ip, date, and score. Now once the test is submitted it will called their score from the database and display it on page two. The problem is I need to store a user name so that i can update records and not hagve them mixed up with someone elses. This is big  group only 25 users will be using this forum.
  12. form data is what i need. i was thinking a session, but i think that is a bit advanced for me however im gonna try it anyway.
  13. Is it possible to transfer data from one page to another without the need of a database using php? If so can someone point me to an example.
  14. Thank for  replying I tried what you said and it does work but when i use in to call the fields from the table i get nothing returned. If i echo it i get: 'q1' 'q2' 'q3' 'q4' It just does not appear to be returning the data fromn the db. Here is the refreshed code: [code] <?php $counter = 1; while ( $counter <= 4 ) { $temp = "'q". $counter. "'"; echo $row_testresults[ $temp ];  // this line hates me echo "<br />"; $counter = $counter + 1; } ?> [/code]
  15. Im trying to get this small script below to return the values from a mysql db where the firld in the table are named q1, q2, q3, etc. I have had luck up to this point but all it is returning is q1 q2 q3 q4. I have also tried echo $row_testresults["$temp"]; but had same results. there is connection to the database becuase i have tried <?php echo $row_testresults['q1']; ?> alone and got a return. What am i doing wrong here? [code] <?php $counter = 1; while ( $counter <= 4 ) { $temp = "q $counter"; $temp = str_replace(" ","", $temp); echo $row_testresults[ $temp ]; echo "<br />"; $counter = $counter + 1; } ?> [/code]
×
×
  • 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.