Jump to content

spiderwell

Members
  • Posts

    1,008
  • Joined

  • Last visited

Posts posted by spiderwell

  1. the file view.php, at no point in that file do you attempt to put a value into the variable $file, so it is empty

     

    a value for this is being passed via a query string in the other script here:

    <?php echo "<img src=\"view.php?file={$row["id"]}\">";?></td>
    

     

    so in view.php you need to grab that value being passed to it

    so put this line at the top of view.php

    <?php  include 'db.inc';  
    $file = $_GET['file'];
    $file = clean($file, 4);
    
    

  2. <?php
    	$objConnect = mysql_connect("localhost","","root") or die(mysql_error());
    	$objDB = mysql_select_db("sdf");
    	$pic2 = "SELECT * FROM images";
    	if (!isset($_GET['Page']))	$_GET['Page']='0';
    	$pic1 = mysql_query($pic2);
    	$Num_Rows = mysql_num_rows($pic1);
    	$Per_Page = 16;   // Per Page
    	$Page = $_GET["Page"];
    	if(!$_GET["Page"])
    	{$Page=1;}
    	$Prev_Page = $Page-1;
    	$Next_Page = $Page+1;
    	$Page_Start = (($Per_Page*$Page)-$Per_Page);
    	if($Num_Rows<=$Per_Page)
    	{$Num_Pages =1;}
    	else if(($Num_Rows % $Per_Page)==0)
    	{$Num_Pages =($Num_Rows/$Per_Page) ;}
    	else
    	{$Num_Pages =($Num_Rows/$Per_Page)+1;
    		$Num_Pages = (int)$Num_Pages;}
    	$pic2 .=" order  by thumbnailID ASC LIMIT $Page_Start , $Per_Page";
    	$pic1  = mysql_query($pic2);
    $cell = 0;
    
    echo '
        <div id="tablediv">
          <table border="0" cellpadding="17" cellspacing="0" class="table">
            <tr>';
    
      while($pic = mysql_fetch_array($pic1)) {
    
        if($cell % 4 == 0) {
          echo '</tr><tr>';
        }
    
        if($cell == 2) {
          echo '
            <td>
              fillerspace
            </td>';
        } elseif ($cell == 3) {
          echo '
            <td>
    Fillerspace2
            </td>';
        } else {
          echo '
            <td>
              <a href="/' . $pic["link"] . '.php">
                <div class="image">
                  <img src="https://s3.amazonaws.com/image/' . $pic["pic"] . '.png" 
                       alt="' . $pic["alt"] . '" 
                       height="200" 
                       width="200" 
                  />
                </div>
              </a>
            </td>'; 
        }
        $cell++;
      }
      echo '</tr></table></div>';
    ?>
    

  3. the first thing i spotted is you are listed by ASC, so you want to change it to DESC, this will put the new image at the top.

     

    there seems to be an awful lot of extra code that you dont really need.

     

    why is $pic2 and $link1 and $alt1 all the same SQL command? (well you add ordering and paging to $pic2 but this is the only recordset you need)

     

    give me a moment and Ill post a stripped out version for you

     

  4. it can't be because you ask this

    This code works when theres no predefined value however I'm trying to modify it in case there IS a value from the DB which is from the  " . $row2['content'] . " data.

     

    but it doesn't appear in any of the code you have posted!?!

     

     

    EDIT:: glad you fixed it , as I had no clue :P

  5. i cant even see " . $row2['content'] . "  in your code,

     

    its very hard to second guess your code if we can't see it.

     

    I am guessing its within the $row3 loop that you want 'selected' echoed into the <option>, but you haven't given us anything to work with  :shrug:

  6. the first example will throw an error saying name is undefined if it wasnt found in the $_POST array, that is Null

     

    isset is a way of being sure something exists before retreiving its value

     

    i usually retreive all my form values like this

     

    if (isset($_POST['name'])) $name = $_POST['name'];
    

  7. ryan you are doing what miko said not to do with the SQL, just use one SQL statement and order by region.

     

     

    	
    
    <?php
    
    
    $currentregion = false;
    $result = "SELECT * FROM regions ORDER BY region ASC;";	
    while ($row=mysql_fetch_assoc($result))   {
    if (!$currentregion) //first call
    {
       echo "<h3>" . $row['region'] . "</h3>";
       $currentregion = $row['region'];
       echo "<div><p>" ;
    }
    elseif($currentregion != $row['region']) // region has changed
    {
      echo "</p></div>"; //close last region div
      echo "<h3>" . $row['region'] . "</h3>";
       $currentregion = $row['region'];
       echo "<div><p>" ; 
    }
    echo "<a href=\"delete.php?region=".$row['region']."&country=".$row['country']."\" onclick=\"return confirm('Are you sure you want to delete?')\"><img src=\"http://www.veryicon.com/icon/png/System/Float/Delete.png\" height=\"20\"/></a>";
    echo $row['country'] . "<br>";
    
    
    }// end DB loop
    echo "</p></div>"; //close last div
    

     

    p.s. i havent checked above code for typo errors.

  8. then you need to group by region or order by region.

     

    then you need to make a check to see if region has changed as you loop through and close off the div and start a new one for the new region, when the region does change.

     

    something roughly like

     

    $currentregion = false;
    while ($row=mysql_fetch_assoc($result))   {
    if (!$currentregion) //first call
    {
       echo "<h3>" . $row['region'] . "</h3>";
       $currentregion = $row['region'];
       echo "<div>" ;
    }
    elseif($currentregion != $row['region']) // region has changed
    {
      echo "</div>"; //close last region div
      echo "<h3>" . $row['region'] . "</h3>";
       $currentregion = $row['region'];
       echo "<div>" ; 
    }
    echo $row['country'];
    
    
    }// end DB loop
    echo "</div>"; //close last div
    

     

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