Jump to content

selliott

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Posts posted by selliott

  1. Hello, I have this code to generate a drop down list of years, but need to adjust it so that when a date is selected, it takes you to  /schedule?Year=(selected year here)  Thanks :)

     

    $thisYear = date('Y');
    $startYear = "2009";
    $selectYear = ($thisYear);
    
    print 'Year: <select name="Year">';
    foreach (range($thisYear, $startYear) as $year) {
    $selected = "";
    if($year == $selectYear) 
    { 
    	$selected = " selected"; 
    }
    print '<option' . $selected . '>' . $year . '</option>
    ';
    }
    print '</select>';
    

  2. bwawhahahaha...

    let me laugh to myself..

     

    simple.. try add random after catid

    example:

    mypic.php?catid=3

    change into

    mypic.php?catid=3&time=3648364

    fyi: 3648364 is random number

     

    it happen 2 me.. and i don't know why my image always repeated..

     

    fyi.. my script for image like this

     

    mypic.php?id=134

     

    and i try 2 upload new image to id 134..

    when i refresh.. WAKZZZ the image don't shown right T_T

     

    and i discover about cache .. cache that always browser do in soo you can save a lot space and time with it.

     

    and that's the reason i give the answer

     

    Maybe I'm misunderstanding what you're saying (sorry if I am), but changing gallery.php?CatID=1  to gallery.php?CatID=1&time=23423 doesn't change anything.  I click on a gallery link on one page (photos.php), which inserts the Category ID in the URL (CatID=1 in this example), then when I get to that gallery page I have the script on that page pulling out the images from the photos table in the db with a category ID (CatID) that matches that category's ID.  I'm guessing it just ignores everything in the url string except the CatID?

  3. I'm putting together a simple image gallery, but I can't figure out how to get it to display ALL the images with a specific CatID.  This is what I've pieced together, but it just keeps repeating the same image.

     

    
    <?php 
    $CatID = $_REQUEST['CatID'];
    $Photos = mysql_query("SELECT ID, Title, ImageURL, CatID, Details FROM Photo WHERE CatID='$CatID'", $connection) or die("error querying database");
    $rows_nb = mysql_num_rows($Photos);
    
    $pic_num = 0;
    $pic_code = mysql_fetch_array($Photos);
    
    
    					echo '<table width="75%" border="0" align="center">'; 
    
    					while($row = mysql_fetch_assoc($Photos))
    
    
    					{ 
    						echo '<tr>'; 
    
    						for ($tb_rows=0;$tb_rows<3;$tb_rows++) 
    						{
    
    							if ($pic_num < $rows_nb)
    							{ 
    							echo '<td><div align="center"><img src="'.$pic_code['ImageURL'] .'" border="1" /></div></td>';
    							$pic_num++;
    							}else{
    							echo '<td></td>';
    							}
    
    						} 
    
    					echo '</tr>'; 
    					} 
    
    					echo '</table>';
    ?>
    

  4. <?php
    /*** begin mock db select ***/
    for ($x = 1; $x <=20; $x++) {
       $array[] = rand(100,110);
    }
    sort($array);
    /*** end mock db select *****/
    
    $rank = 0;
    
    foreach($array as $score) {
       $r = ($score == $oldScore)? $rank : ++$rank;
       echo $r . " " . $score . "<br/>";
       $oldScore = $score;
    }
    ?>
    

     

    Thanks for the reply.  What would I put in place of $array to get this to work with my connection? This is my SELECT statement:

     

    $Points = mysql_query("SELECT ID, Name, Points FROM tq_Points ORDER BY Points DESC", $connection) or die("error querying database");

  5. Hello,

        I put together some code that displays ranks, but if two people have the same amount of points (tied) I want them to have the same rank...then the next would skip a number.  For example, like this

     

    Rank    Name    Points

    1        Joe      105

    2        John      101

    2        Shawn  101

    4        Sam      100

     

    Right now, my code would just list the rankings for these members as 1,2,3,4

     

    Here's my current code:

     

    			<?php 
    
    echo '<table cellpadding="3" cellspacing="0" style="width:100%;">
    				<tr>
    					<td>Rank</td><td>Driver</td><td>Points</td>
    				</tr>';
    $rank = 1;
    
    while($r = mysql_fetch_array($Points)){ 					
    
    	 echo '
    
    	 <tr>
    	 <td class="topline">' . $rank . '</td>
    	 <td class="topline">' . $r['Name'] . '</td>
    	 <td class="topline">' . $r['Points'] . '</td>
    	 </tr>';
    
    $rank++;
    
    }
    
    echo '</table>';
    
    ?>
    

  6. First, here's my currently functioning code:

     

    $QueryString="SELECT Top 4 * FROM ads WHERE Terminate > GETDATE() ORDER BY RAND()";

     

    Now, this limits my results to 4...but it's only showing the same Top 4 every time...and it doesn't appear to be randomizing. If I refresh the xml.php page, I keep seeing the same nodes in the same order.  The big issue is, I don't want the Top 4...I want 4 random.  What I want this to do is give me 4 Random ads from ALL the ads that haven't expired (have a terminate date > now).

     

    I'm guessing something like this would work perfect, if my SQL server recognized LIMIT

     

    "SELECT * FROM ads WHERE Terminate > GETDATE() ORDER BY RAND() LIMIT 4";

     

  7. Getting closer... 

     

    This test code works:

     

    <?php 
    $sendTo = "myName@myDomain.com"; 
    $subject = "Website Inquiry"; 
    $headers = "From: somebody@domain.com\nReturn-Path: somebody@domain.com\nX-Mailer: PHP/" .phpversion(); 
    $messages .= "From: John Smith\r\n";
    $messages .= "Email: somebody@domain.com\r\n";
    $messages .= "------------------------------------------" . "\r\n";
    $messages .= "Testing Form\r\n";
    
    mail($sendTo, $subject, $messages, $headers); 
    ?> 
    

     

    But this one is not (that uses the variables from the flash form).  Something is wrong with the $headers line:

     

    <?php 
    $sendTo = "myName@myDomain.com"; 
    $subject = "Website Inquiry"; 
    $headers = "From: " . $_POST["name"] . "\nReturn-Path: " . $_POST["email"] . "\nX-Mailer: PHP/" .phpversion();
    $messages .= "From: " . $_POST["name"] . "\r\n";
    $messages .= "Email: " . $_POST["email"] . "\r\n";
    $messages .= "Phone: " . $_POST["phone"] . "\r\n";
    $messages .= "------------------------------------------" . "\r\n";
    $messages .= "Message: " . $_POST["message"] . "\r\n";
    
    mail($sendTo, $subject, $messages, $headers); 
    ?> 
    

  8. I've used this script on linux/unix hosting plans before and it works fine, but it's not working for me now on a windows hosting plan.  I have a flash contact form that sends the variables to it.  Any ideas why it's not working on the windows server?

     

    <?php 
    $sendTo = "name@domainname.com"; 
    $subject = "Website Inquiry"; 
    $headers = "From: " . $_POST["name"]; 
    $headers .= "<" . $_POST["email"] . ">\r\n"; 
    $headers .= "Reply-To: " . $_POST["email"] . "\r\n"; 
    $headers .= "Return-Path: " . $_POST["email"];
    $messages .= "From: " . $_POST["name"] . "\r\n";
    $messages .= "Email: " . $_POST["email"] . "\r\n";
    $messages .= "------------------------------------------" . "\r\n";
    $messages .= "Message: " . $_POST["message"] . "\r\n";
    
    mail($sendTo, $subject, $messages, $headers); 
    ?> 
    

  9. oops, I didn't mean to say "Won't it just display all dates".  I meant the 1st 5 in the db, regardless of the current date.

     

    I had a little trouble getting this to display at first, then read around and it looks like I had to change it to read:

     

    SELECT TOP 5 ID, Date, ...etc.

     

    Since I'm on an SQL server.  I kept getting an error whenever I tried putting the LIMIT in there.  Using SELECT TOP 5 is only showing me the first 5 dates in the database though.  So, since the first date is 11/20/08, it's showing first....but I don't want it to show at all, since that date would be past.  So if the site was visited today, I'd want it to only display the next 5 dates that are of 11/15/08 or greater.

  10. Hello,

        I need some help adjusting my code to only display dates greater than or equal to the current date. And for it to limit the results to 5.  Please help!

     

    <?php
    ini_set('error_reporting', E_ALL | E_STRICT);
    ini_set('display_errors', 'On');
    include('admin/functions.php');
    
    $ConnString="DRIVER={SQL Server};SERVER=;DATABASE=";
    $DB_User="";
    $DB_Passwd="";
    $QueryString="SELECT ID, Date, Title, Details, Results, Car FROM Schedule ORDER BY Date";
    $Connect = odbc_connect( $ConnString, $DB_User, $DB_Passwd );  
    $Result = odbc_exec( $Connect, $QueryString ); 
    
    $nl = "\r\n"; 
    
        echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" . $nl; 
      echo "<ROOT>" . $nl; 
    
    while($r = odbc_fetch_array( $Result ) )
    {
            
        echo '<news ID="' . $r['ID'] . '" Title="' . char_replace($r['Title']) . '" Date="' . $r['Date'] . '" Car="' . $r['Car'] . '">' . $nl; 
        echo '<body><![CDATA[' . stripslashes2($r['Results']) . ']]></body>' . $nl; 
        echo '</news>' . $nl; 
    }
    
    echo "</ROOT>" . $nl;
    
    odbc_free_result( $Result );
    odbc_close( $Connect );
    ?>
    

  11. That it could be setup in a way that if you enter something like "photos.php?galleryId=2", it would only display the nodes that has the galleryId=2?

     

    Where do you $_GET this value, "?galleryId=2"?  You would need to change your query to:

     

     $QueryString="SELECT * FROM $table WHERE gallery_id = $_GET['galleryId']";

     

    Is this what you're looking for?

     

     

     

    Awesome! Thanks!

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