Jump to content

kate_rose

Members
  • Posts

    121
  • Joined

  • Last visited

Posts posted by kate_rose

  1. Thank you Jessica & Psycho. The loop is working correctly now - I hadn't written one like this before & didn't realize the dif. between = & ==.

     

    Psycho, I think day of the year is probably better because the first 2 days of the month will display the same slide. The images won't be dynamic & the max will be 5 so I probably won't need a DB. & it is a good idea to use an array (I do with some of my other bits on this site). I appreciate the advice, I can obviously use it.

     

    Kate

  2. Hi,

     

    I haven't done that much in php so thanks for you patience if there are really obvious errors or bad practices

     

    I am trying to rotate the content of a div depending on the date between 3 different images (each day a new image is displayed and after 3 days it starts over - in the future we may need to add more images). For some reason my code always displays the second image of the three no matter what the day is. Here is my code.

     

    <?php
    $num_slides=3; //let the variable num_slides = the number of slides to be shown (in this case 3)
    $day_month = date('d'); //load the day of the month into $day_month
    $slidenum = $day_month % $num_slides; //let $remain = the remainder after $daymonth is divided by $num_slides
    $slidenum = 0; //override normal $slidenum generation for debugging
    if ($slidenum=0)
    {echo <<<EOL
    		 <div id="learning_outside_top">
    <a href="learning_outside/learning_outside_main.php" title="link to hands on learning page" alt="link to hands on learning page"><img src="images/learning_outside_research_top.jpg" onmouseenter="this.src='images/learning_outside_research_top_mouseover.jpg'" onmouseleave="this.src='images/learning_outside_research_top.jpg'"/></a>
    	</div>
    <a href="learning_outside/learning_research.php" title="link to undergraduate research FAQ page" alt="link to undergraduate research FAQ page"><img src="images/learning_outside_research_bottom.jpg"/></a>
    EOL;
    ;
    }
    elseif ($slidenum=1)
    {echo <<<EOD
    		 <div id="learning_outside_top">
    <a href="learning_outside/learning_outside_main.php" title="link to hands on learning page" alt="link to hands on learning page"><img src="images/learning_outside_internships_top.jpg" onmouseenter="this.src='images/learning_outside_internships_top_mouseover.jpg'" onmouseleave="this.src='images/learning_outside_internships_top.jpg'"/></a>
    	</div>
    <a href="learning_outside/learning_internships.php" title="link to undergraduate internship FAQ page" alt="link to undergraduate internship FAQ page"><img src="images/learning_outside_internships_bottom.jpg"/></a>
    EOD;
    ;
    }
    else
    {echo <<<EOC
    		 <div id="learning_outside_top">
    <a href="learning_outside/learning_outside_main.php" title="link to hands on learning page" alt="link to hands on learning page"><img src="images/learning_outside_class_based_top.jpg" onmouseenter="this.src='images/learning_outside_class_based_top_mouseover.jpg'" onmouseleave="this.src='images/learning_outside_class_based_top.jpg'"/></a>
    	</div>
    <a href="learning_outside/class_based.php" title="link to undergraduate hands on learning in classes page" alt="link to undergraduate hands on learning in classes page"><img src="images/learning_outside_class_based_bottom.jpg"/></a>
    EOC;
    ;
    }
    ?>
    
    

     

    I am sure that the $slidenum part of this is working correctly because I have echoed that. Even when I insert a line that sets $slidenum = 0; (like in the code above) it still only shows the second image which is created by the echo EOD section of the code. It is probably just something I am missing after staring at this too long but I could really use another set of eyes.

     

    Thanks,

     

    Kate

  3. Zane,

     

    I think that did it.

    I guess I need to read about classes because I thought you hade to have a div id= statement to get the div to display. I had no idea you could use this sort of syntax

    echo "<div class='imageClass'>"; //display div named $div
    

    to get a div to display . . . It doesn't make much sense to me because I don't see where my named div "$div" is used in this statement

     

    I will go read & try to figure it out.

     

    Thanks again,

     

    Kate

  4. Hi,

     

    I am trying to create a bunch of pics html linked to more info on a page in a grid format. The pic names and link urls come from a mysql db and I use a php code & embedded css (see code below) to dynamically create divs for each pic and display them on the page linked to more info.

    <div id="systems_visual_library">
    <?php //this php code displays all the pics of systems and species and links them to the appropriate content from urls provided in the mysql table titled "systems_list"????
    mysql_connect("55555555555","5555555","555555") or die(mysql_error()); // mysql connection to server
    mysql_select_db("NRM_faculty_profiles") or die(mysql_error()); //use the NRM_faculty_profiles DB
    //SYSTEM & SPECIES LINK BOXES
    $data = mysql_query("SELECT * FROM systems_we_study") or die(mysql_error()); //get all the data from systems_list
    $div_name = "#system_pic_linkbox"; // sets $div_name variable = to "#system_pic_linkbox"
    while($info = mysql_fetch_array( $data )) //loops through each instance in the array executing commands inside { } for each instance
    {
    $count = $info['count']; // loads the # of the picture/link in the table into the variable $count
    $div = $div_name . $count; // concatenates $div_name & $count so you get "system_pic_linkbox1","system_pic_linkbox2" etc.
    echo "<style type=\"text/css\">
    $div {
    width: 162px;
    height: 121px;
    display: inline;
    margin-top: 10px;
    margin-left: 10px;
    }
    </style>"; // creates a div names $div
    $url = $info['url_link'];//loads the url in the url column into $url
    $jpeg = $info['jpeg_source'];//loads the jpeg source in the jpeg column into $jpeg
    echo "<div id=\"$div\">"; //display div named $div
    echo "<a href=\"$url\"><img src=\"$jpeg\" /></a>"; //displays the jpeg image linked to the url inside the div
    echo "</div>";
    }
    ?>
    </div>
    

    So the mechanics work fine but instead of displaying in a grid the divs are just stacked on top of one another with no margin between at all see what I mean -->(http://cherokee.tosm...ied/systems.php). I sized the container div so they would display 4 across. I also tried "float: left;" but it doesn't change anything.

     

    Thanks,

     

    Kate

  5. This DB was created in mysql workbench and it won't let you use any weird characters like "&" or "$" when you name a column. However it does automatically add a "$" to the begining of any column name where the data it contains will be strings. That was the whole problem. I just had to go back and manually delete the "$" at the begining of each column name.

     

    Thank you all for you time and patience.

     

    Kate

     

    P.S. I will fix my spelling ManiacDan.

  6. So as you might be able to tell I am pretty new at this so the pause has been me trying to figure out how to implement "SHOW CREATE TABLE"

    I ended up using this

     

    $showme = mysql_query("SHOW CREATE TABLE youtube_playlists");
    echo $showme;
    

     

    It outputs "Resource id #3"

     

    Pikachu - I have tried using the $ in my code so it looked like this

    $data = mysql_query("SELECT * FROM youtube_playlists WHERE $catagory='individual'") or die(mysql_error()); //untested code where selector
    

     

    but I get this error

    "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '='individual'' at line 1"

     

    Also all of the many examples leave off the $. I figured it just designated the mysql datatype as a string.

     

    Kate

  7. I just tried subbing in name again & got the same error with this code

    $data = mysql_query("SELECT * FROM youtube_playlists WHERE name='Dr. Phil Gipson'") or die(mysql_error()); //untested code where selector
    

     

    error reads "Unknown column 'name' in 'where clause'"

     

    but when I use the column 'name' in this context the code works fine

    while($info = mysql_fetch_array( $data )) //loops through each instance in the array executing commands inside { } for each instance
    {
    echo "<b>Name:</b> ".$info['$name'] . " <br/>";
    $name = $info['name']; //untested code
    }
    

     

    so is my problem with the whole DB or something????

  8. I do suck at spelling but I just double checked and even if "catagory" is spelled wrong it is spelled wrong both in my DB & in my script.

    $data = mysql_query("SELECT * FROM youtube_playlists WHERE catagory='individual'") or die(mysql_error()); //untested code where

    [/code}

     

    & of course I can't show you my mysql workbench view since I can't paste in an image but trust me it is "$catagory"

  9. Pikachu2000,

     

    I understand what the error message means but I do have a column named catagory in my table. That is why I am confused. I tried using "$catagory" instead of "catagory" but that just gave me a syntax error.

     

    I even tried subbing in the "name" column name as a test to see if there was something wrong with the "catagory" column name but I get the same error. It seems weird to me since I use the "name" column later in the script and that works fine??

  10. Hi,

     

    I have read a bunch about this error but I can't figure out what I am doing wrong. I am trying to use a where selector to limit data I pull from my mysql database. The code runs fine before I add the where selector but gives me the "Unknown column 'catagory' in 'where clause'" error as soon as I add it in. The code is

    mysql_select_db("NRM_videos") or die(mysql_error()); //use the NRM_videos DB
    $data = mysql_query("SELECT * FROM youtube_playlists WHERE catagory='individual'") or die(mysql_error()); //untested code where selector
    echo "<p><b><u>NRM Faculty</u></b></p>";
    while($info = mysql_fetch_array( $data )) //loops through each instance in the array executing commands inside { } for each instance
    {
    echo "<b>Name:</b> ".$info['$name'] . " <br/>";
    $name = $info['name']; //untested code
    $url = $info['playlist_url'];//untested code
    echo "<a href=$url>$name</a>"; // untested code
    }
    
    

     

    Usually this error is because someone didn't have required column in their database but I am pretty sure I do. Here is what my DB looks like (hmm . . . I tried to paste in an image of the DB from captured from Mysql workbench but it keeps deleting it in the preview)

     

    So I will type it I suppose

    $name							 $playlist_url					 $catagory
    Dr. Brad Dabbert		 http://www.youtube.com/playlist?list=PLKzzRdXA6QxWsrTsADIAQBAaazxd1vQAo	 individual
    Dr. Phil Gipson		 http://www.youtube.com/playlist?list=PLKzzRdXA6QxWkCO46zKStmFcoXw__GZd8 individual 	
    Dr. Rob Cox			 http://www.youtube.com/playlist?list=PLKzzRdXA6QxWn2ke9-vicexA_vngeU1z2v individual
    

    well that was a pain - anyone know how to display an image without it getting axed??

    Anyway

    I know it looks like I don't even need the where selector because my DB is so simple but I am just trying to get the code to work and have not yet entered all the data in the DB.

     

    Thanks for your help,

     

    Kate

  11. Jessica,

     

    I looked at all the links you posted & in fact read them all before I got started on this. I thought I had better not use the single quote variety of string because the html I have has a lot of "s in it. So can you be specific about what issues I have?? An example would be really helpful. Do I need to concatenate in my echo commands every time I let a piece of php peek through?? I didn't think I did.

    So my understanding is when I use an echo command it goes like this

    echo "non-php non-php non-php"php php php"non-php non-php non-php" etc.

    and them I am just using the \ to allow the "s to show through for the html

     

    darkfreaks,

    I am trying to get this code at least apparently error free before putting it up on my server so I don't have the php error to put up. I am using dreamweaver as my code editor and it says I have a syntax error in the 1st 2 echo commands (oddly not the 3rd one though).

     

    Thanks,

     

    Kate

     

    I will go see what errors I am getting in php now that I have access to the server so I can report back

  12. Hi,

     

    I have a simple piece of html generated by fireworks to show a graphic with 2 links that looks like this

    <img name="desert_springs" src="[url="http://cherokee.tosm.ttu.edu/ttunrm/Splash/systems_species_studied/desert_springs.jpg"]http://cherokee.tosm...rt_springs.jpg"[/url] width="230" height="169" border="0" id="desert_springs" usemap="#m_desert_springs" alt="" /><map name="m_desert_springs" id="m_desert_springs">
    <area shape="rect" coords="0,40,230,169" href="[url="http://www.myweb.ttu.edu/darogows/research/rogowski_research.html"]http://www.myweb.ttu..._research.html"[/url] title="link to rogowski lab web page (desert springs)" alt="link to rogowski lab web page (desert springs)" />
    <area shape="rect" coords="0,0,230,40" href="[url="http://cherokee.tosm.ttu.edu/ttunrm/splash/systems_species_studied/systems.php"]http://cherokee.tosm...ed/systems.php"[/url] title="link to NRM systems we study page" alt="link to NRM systems we study page" />
    </map>
    

     

    it works fine when I paste it into my div but I am trying to create an MD array with the names of the graphics as the key and 2 values [0] - a link url and [1] - a bit of text & use array_rand to pull a random graphic name so the content of the div will change on reload of the page

     

    A sample of my MD array looks like this (I didn't include the whole thing because its very big

    $systems = array(
    "desert_springs" => array( "[url="http://www.myweb.ttu.edu/darogows/research/rogowski_research.html"]http://www.myweb.ttu..._research.html"[/url], "link to rogowski lab web page (desert springs)" ),
    "ephemeral_waters" => array( "[url="http://myweb.ttu.edu/kerrgrif/Research.htm"]http://myweb.ttu.edu...f/Research.htm"[/url], "link to Griffis-Kyle research lab (ephemeral waters)" ),
    "systems_agave_weevil" => array( "[url="http://www.rw.ttu.edu/perry/agave_weevil.html"]http://www.rw.ttu.ed...ve_weevil.html"[/url], "link to perry lab research (agave weevil)", ),
    "systems_amphib_conservation" => array( "[url="http://myweb.ttu.edu/kerrgrif/Research.htm"]http://myweb.ttu.edu...f/Research.htm"[/url], "link to Griffis-Kyle research lab (amphibian conservation)" ),
    );
    

     

    So to reproduce basically what I have in the first html code snippet but with a random graphic name I am using this php code

    $rand_system = array_rand($systems, 1);
    echo "<img name=\""$rand_system"\" src=\"[url="http://cherokee.tosm.ttu.edu/ttunrm/Splash/systems_species_studied/%22$rand_system%22.jpg\"]http://cherokee.tosm...d_system".jpg\"[/url] id=\""$rand_system"\" usemap=\"#m_"$rand_system"\" alt=\"\" border=\"0\" height=\"169\" width=\"230\"><map name=\"m_"$rand_system"\" id=\"m_"$rand_system"\">";
    echo "<area shape=\"rect\" coords=\"0,40,230,169\" href=\"".$systems['$rand_system'][0]"\" title=\"".$systems['$rand_system'][1]"\" alt=\"".$systems[$rand_system][1]"\">";
    echo "<area shape=\"rect\" coords=\"0,0,230,40\" href=\"[url="http://cherokee.tosm.ttu.edu/ttunrm/splash/systems_species_studied/systems.php\"]http://cherokee.tosm...d/systems.php\"[/url] title=\"link to NRM systems we study page\" alt=\"link to NRM systems we study page\">
    </map>";
    

     

    But I am getting a syntax error for the 1st two echo statements and I just can't seem to find the problem. Maybe just tired eyes but . . . please help . . . admitedly I am pretty new at this or getting started again after having kids anyway

     

    Thanks,

     

    Kate

  13. Christian,

     

    I am pretty sure I looked at the code at one point with view source.  It looked fine.  I am also pretty sure that I created the file as a php file and it has the correct extension.  I will double check at work in the morning.  I know other php files seem to work OK on our server but this is the first one I have tried to create.  If I need to I can bug my administrator again tommorow.

     

    Thanks for your help.

     

    Kate

×
×
  • 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.