Jump to content

momasri

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Posts posted by momasri

  1. we need to create a tree type table:

    Year --> Institute --> Simister

     

    an admin Page to enter Values

    we enter a Year, then we enter multiple Institute affiliated with that Year, then multiple Simisters affiliated with that Institute

    the script then will mkdir() where dir name = year-Institute-simister

    so if we have 1 year input, 2 Institute inputs and 2 simisters per Institute

    we should have 4 folders created.

     

    then I want a display page for users where they Select there Year, then a select menue with avalible Institute's  for that year would appear, and when one is selected a Simister list would appear.

     

     

    can you give me a quote, and time-line for doing it.

     

    almasri_m@hotmail.com

     

  2. The Ajax Code:

    <script language="javascript" type="text/javascript">
    <!-- 
    //Browser Support Code
    function ajaxFunction(){
    var ajaxRequest;  // The variable that makes Ajax possible!
    
    try{
    	// Opera 8.0+, Firefox, Safari
    	ajaxRequest = new XMLHttpRequest();
    } catch (e){
    	// Internet Explorer Browsers
    	try{
    		ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    	} catch (e) {
    		try{
    			ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
    		} catch (e){
    			// Something went wrong
    			alert("Your browser broke!");
    			return false;
    		}
    	}
    }
    // Create a function that will receive data sent from the server
    ajaxRequest.onreadystatechange = function(){
    	if(ajaxRequest.readyState == 4){
    		var ajaxDisplay = document.getElementById('ajaxDiv');
    		ajaxDisplay.innerHTML = ajaxRequest.responseText;
    	}
    }
    var pic = document.getElementById('pic').value;
    
    var queryString = "?pic=" + pic;
    ajaxRequest.open("GET", "ajax-example.php" + queryString, true);
    ajaxRequest.send(null); 
    }
    
    //-->
    </script>
    

     

    The PHP code:

    <?php
    require_once("configure.php");
    mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database" . mysql_error());
    @mysql_select_db("$DBName") or die("Unable to select database $DBName" . mysql_error() );
    $user_sqla = "select * from $emaila " ;
    
    while($user_array = mysql_fetch_array($user_resulta)) 
    {
    $pictures = $user_array[picture];
    ?>
    <form name='myForm'>
    <?php
    
    
    echo "<div align='left' style='padding-left:25px'><table border='1'><tr><td><img src=".$pictures." width='65' height='65'><input type='hidden' name='pic' id='pic' value=".$pictures.">". $pictures;?></td>
    <td><div style="padding-left:5px; padding-top:15px"><?php echo "<a  href='#' onclick='ajaxFunction()' >Remove</a></td></tr></table></div>"; ?></div>
         </form><?php } ?>
    

     

    the ajax-example.php code:

    <?php
    
    // Retrieve data from Query String
    $age = $_GET['pic'];
    
    
    echo $age;
    ?>
    

     

     

    Now the Php code gives the following result:

     

    "image1" "Remove"

    "image2" "Remove"

    "image3" "Remove"

     

    when I click the "Remove" the result I keep getting is "image1" even if I click the remove beside image3 I still get the Image1 Name transffered from my ajax code to the ajax-example.php page

  3. sweet thanks, this solves the main problem. now I have a sub question from the above code:

     

    in the Body of the page I write:

    // this line displays the Pictures I have the "$dire" folder as specified in the code above

    <?php getPictures(); ?>
    

     

     

    // this line makes a Previous Page if exists

    // and  makes a Next button for Next Page views if they exist

    <?php
    if ( $has_previous ) 
    	echo '<div align="left" style="padding-left:100"><a href="?page='.($page - 1).'">← Previous Page</a></div>';
    
    if ( $has_next )  
    	echo '<div align="right" style="padding-right:100"><a href="?page='.($page + 1).'"> Next Page →</a></p>';
    ?>
    

     

    // the code below gives me numbers for each page, so if the totall number of pictures per page is 5, and i have 20 pictures it gives me links  0 1 2 3 4

     

    My question is How can I set my first page to be number "1"  insted of number "0" 

    now I am sure the Fix for it is not in the code below, but I thought I would paste all so you can make use of this Picture Pigntaion

    $directory = $dire .'/';
    if (glob("$directory*.jpg") != false)
    {
    $filecount = count(glob("$directory*.jpg"));
    echo "You have " . $filecount . " Number of Files";
    echo "<br/><br/>";	
    $total = $filecount / $per_page;
    echo "That means you have " .$total . " Number of Pages to view";
    
    for ($i = 0; $i <= $total; $i++)
    if ($i >= 0)
    {
    echo '<p class="prev"> <a href="?page='.$i.'"> '.$i.' </a></p>';
    }
    }		
    ?>

  4. Actuly this is my first line few lines of code:

     

    require_once("configure.php");

    mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database" . mysql_error());

    @mysql_select_db("$DBName") or die("Unable to select database $DBName" . mysql_error() );

    $user_sql = "select institute from $DBtable order by email" ;

     

    $user_result = mysql_query($user_sql) or die(mysql_error());

     

    while($user_array = mysql_fetch_array($user_result))

    {

     

    $institutea = $user_array[institute] ;

    }

     

    $dire = str_replace(" ","-",$institutea);

    echo "<br />" . dire;  // this shows a value

    // and if I do an echo it works but if I do an echo inside the function is does not work, if I do an echo after the function it works

  5. Hello, this is my first post I hope you guys can help me out here, basically whats going on is I declare a variable "$diree" then I insert it in a function  but its not getting recognized, here is the code:

     

    $institutea "some directory";

    $dire = str_replace(" ","-",$institutea);

     

     

    # SETTINGS

    $max_width = 110;

    $max_height = 130;

     

    $per_page = 5;

    $page = $_GET['page'];

     

    $has_previous = false;

    $has_next = false;

     

    function getPictures() {

    global $page, $per_page, $has_previous, $has_next;

    if ( $handle = opendir($diree.'/') ) { // done changes here

    $lightbox = rand();

    ?><table border="1"><tr><td>

    <form action="pro.php" method="post">

     

     

     

    <?php

    echo "<ul id='pictures'>";

     

    $count = 1;

    $skip = $page * $per_page;

     

    if ( $skip != 0 )

    $has_previous = true;

     

    while ( $count < $skip && ($file = readdir($handle)) !== false ) {

    if ( !is_dir($file) && ($type = getPictureType($file)) != '' )

    $count++;

    }

    $count = 1;

    while ( $count < $per_page && ($file = readdir($handle)) !== false ) {

    if ( !is_dir($file) && ($type = getPictureType($file)) != '' ) {

     

    if ( ! is_dir($dire .'/') ) {  // done changes here

    mkdir($dire .'/'); // done changes here

    }

    if ( ! file_exists($dire .'/'.$file) ) {

    makeThumb( $file, $type );

    }

     

     

    echo '<li>';

    echo '<img src="'.$dire .'/'.$file.'" alt="" / width="110" height="110"><br/><input type="checkbox" name="food[]" value='.$file.'>'; // done changes here

    echo '</li>';

     

    $count++;

     

    }

    }

    echo '</ul>';

    ?>

    </td></tr><tr><td><div align="center"><input type="submit" value="Add"></div></td></tr>

    </tr></table></form>

    <?php

    while ( ($file = readdir($handle)) !== false ) {

    if ( !is_dir($file) && ($type = getPictureType($file)) != '' ) {

    $has_next = true;

    break;

    }

    }

    }

    }

     

    function getPictureType($file) {

    $split = explode($dire .'/', $file);

    $ext = $split[count($split) - 1];

    if ( preg_match('/jpg|jpeg/i', $ext) ) {

    return 'jpg';

    } else if ( preg_match('/png/i', $ext) ) {

    return 'png';

    } else if ( preg_match('/gif/i', $ext) ) {

    return 'gif';

    } else {

    return '';

    }

    }

     

    function makeThumb( $file, $type ) {

    global $max_width, $max_height;

    if ( $type == 'jpg' ) {

    $src = imagecreatefromjpeg($file);

    } else if ( $type == 'png' ) {

    $src = imagecreatefrompng($file);

    } else if ( $type == 'gif' ) {

    $src = imagecreatefromgif($file);

    }

    if ( ($oldW = imagesx($src)) < ($oldH = imagesy($src)) ) {

    $newW = $oldW * ($max_width / $oldH);

    $newH = $max_height;

    } else {

    $newW = $max_width;

    $newH = $oldH * ($max_height / $oldW);

    }

    $new = imagecreatetruecolor($newW, $newH);

    imagecopyresampled($new, $src, 0, 0, 0, 0, $newW, $newH, $oldW, $oldH);

    if ( $type == 'jpg' ) {

    imagejpeg($new, $dire .'/'.$file);

    } else if ( $type == 'png' ) {

    imagepng($new, $dire .'/'.$file);

    } else if ( $type == 'gif' ) {

    imagegif($new, $dire .'/'.$file);

    }

    imagedestroy($new);

    imagedestroy($src);

    }

    ?>

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