Jump to content

JD*

Members
  • Posts

    230
  • Joined

  • Last visited

Posts posted by JD*

  1. I'm trying to set up a page that will use the prototype ajax.updater to update table cells. This is for an election, so I have a gird that has the candidate names across the top and the polling district along the side. What I'd like is for this page to watch another page, which will query my db every x seconds and pull the results. Then, if there is a change, have the first page see that change and update the appropriate table cell (possibly with the effect.highlight).

     

    I have the table set up, and every cell has an id of the location_candidate (numerical ids) and I was following a tutorial on making a digg spy clone, but I got a little lost, so if anyone can help me on the way, I would much appreciate it.

  2. Try this:

     

     

    <?php
    print "<table width=\"800\">";	
    print "<tr>";						
    for($i = 0;$i < mysql_num_fields($data);$i++)
        {
        print "<th>" . mysql_field_name($data, $i) . "</th>";				
        } 
    print "</tr>";			
    for ($i = 0; $i < mysql_num_rows($data); $i++)
        {
        print "<tr>";
        $row = mysql_fetch_row($data);
            for($j = 0;$j < mysql_num_fields($data);$j++) 
                {
                  if(mysql_field_name($row[$j]) == "your_field_name_here")
                  {
                    if($row[$j] >= 2.9999)
                    {
                      $class=" class=\"red\"";
                    } 
                } 
    echo("<td $class>" . $row[$j] . "</td>");
    }
        print "</tr>";							
        } 
    print "</table>";
    ?>
    

  3. Hello everyone,

     

    I'm looking for a simple example of a digg-like comment fetcher to use on my site.

     

    I have a bunch of news articles that I want to make editable when you click on the title...right now, it looks like a list:

     

    Article 1

     

    Article 2

     

    Article 3

     

    And when you click on any of those, it does a slidedown to reveal:

     

    Article1

    Edit  Delete

     

    Article 2

     

    Article 3

     

    So what I'd like to do is replace the "Edit" part with my tinymce instance, do a DB query to grab the entry for the supplied ID, and then present it, along with the delete button.

     

    If someone can point me in a direction for this, I'd be very grateful...just having trouble figuring out a way to start.

  4. Where are you pulling "time" from? It could be as simple as:

     

    $result = mysql_query("SELECT * FROM database WHERE date > '2007-11-10' AND date < '2008-01-07'");

     

    But it all depends on how you are getting your ranges

  5. O.k., in that case, I would say you need a second page (call it image.php), that will accept an ID and do this:

    [code]<?PHP
    if(isset($_GET['id']))
    {
        include ("condb.php");
        $query="select * from subject WHERE ID = '".$_GET['id']."'";
        $result=@mysql_query($query,$con) or die(mysql_error());
    
        header("Content-type: image/jpeg");
        echo $result['Image'];
    } else {
        echo '';
    }
    ?>
    

     

    And then, on your main page, do:

     

    //view all subjects with the images.
    <?php
    include ("condb.php");
    
    
    $query="select * from subject ";
    $result=@mysql_query($query,$con);
    
    $result = mysql_query($query) or die('Error, query failed');
    
    while ($result2 = mysql_fetch_array($result))
    {
    echo $result2['ImageTitle']."<br />".$result2['ImageSubject']."<br /><img src=\"image.php?id=".$result2['ID']."\" /><hr />";
    }
    mysql_close();
    ?>
    

     

    That (or something very similar) should work for you.[/code]

  6. what are your seasons that you want to change it on? You can use the date command to find

    out the current date,time, month, etc and then compare it to your pre-made selection, ie:

     

    <?php
    if(date("m") >=11 && date("m") <=04)
    {
      //winter
    } elseif(date("m") >=05 && date("m") <=06) {
      //spring
    } elseif(date("m") >=07 && date("m") <=10) {
    //summer
    } else {
    //fall 
    }
    ?>
    

  7. You can always add this to the top of your page:

     

    <?php error_reporting(E_ALL ^ E_NOTICE); ?>
    

     

    This will report any errors (I'm guessing error reporting is shut off if you're only seeing a blank page right now), and then you can remove it when you're done developing your site.

  8. As far as I know, you cannot use the "header" function after you have already sent data. What you want to do is this:

     

    //view all subjects with the images.
    <?php
    include ("condb.php");
    
    
    $query="select * from subject ";
    $result=@mysql_query($query,$con);
    
    $result = mysql_query($query) or die('Error, query failed');
    
    while ($result2 = mysql_fetch_array($result))
    {
    echo $result2['ImageTitle']."<br />".$result2['ImageSubject']."<br /><img src=\"".$result2['Image']."\" /><hr />";
    }
    mysql_close();
    ?>
    

  9. You would put in a link to your profile page along with a url variable with the submission id and then, on your profile page, it would use that ID to get and display your info from the database

     

    while($info = mysql_fetch_array( $data ))
    {
    Print "<p><a href='profile.php?id=".$info['submission_id']."'>".$info['col_2'] ." <img src='/imgs/bg/boats.jpg' width='73px' />".$info['submission_id'] . "</p>";
    

     

  10. O.k, so here is how I would do it:

     

    Have a page with a form on it that will accept the video ID. When they submit, have it submit to the same page and it should do the following:

     

    Check to see that the youtube video exists.

     

    Figure out the URL to the flv file on youtube (check the source)

     

    Use popen() to wget the file, do the ffmpeg conversion. popen is useful because it will launch a process in the background, which means that the page doesn't need to stay open for this to keep working. I'd suggest writing a perl script to do the wget and ffmpeg commands, and have PHP to a popen on the perl script. (this is how I've gotten it to work in the past).

     

    Finally, when done, have it put the URL into a database, or move it to a new folder, or whatever you need so that it can be displayed on your website.

     

    The page itself should follow a form like this:

     

    <?php
    if(isset($_POST['Submit']) && $_POST['Submit'] == "Get It")
    {
      // Do your popen on the perl script here, along with anything else
    } else {
      //Put your form code here, along with a Submit button with a "value" of "Get It"
    }
    ?>
    

     

    This will allow you to do everything on one page.

     

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