Log in

View Full Version : search subdirectory



jd57
04-29-2009, 01:20 PM
Hi everyone

I'm in a desperate situation, I hope someone can help.
I have a search engine that use a mysql database and display 6 different images as a result.
The problem I’m having is, that all of the images are located in one folder, now I’m having a problem to see all files through my ftp program since I’ve exceeded the amount of files allowed by my host, so I am forced to split the folder by adding 26 subdirectories (A-Z) to SEArchive directory and move all images that start with the letter “A” to the a subdirectory http://www.mysite/SEArchive/a , the same with “B” “C” etc….
Is there a php or a function code I can add so that it will search through all 26 subdirectories until it finds the image.
I added the codes in red and now uploads from the subdirectory, however when I try the cvdata1.php it adds the subdirectory path. example: a/Adam it should just Adam
I would appriciate if you add the code to the script, since I'm only a novice and have a lot to learn.


<?PHP

function loadMember($name){
global $link;

// Fetch total number of records
//$SQL="SELECT * FROM ihsreg WHERE Bloom_Name ='".addslashes($name)."'";
if(stristr($name,"'") && !stristr($name,"\'")){
$name = addslashes($name);
}
$SQL="SELECT * FROM ihsreg WHERE Bloom_Name ='".$name."'";
$result = mysql_query($SQL);
$row = mysql_fetch_assoc($result);
$row['Bloom_Label']=$row['Bloom_Name'];
$row['Bloom_Name']=strtoupper($row['Bloom_Name'][0]) . '/' . $row['Bloom_Name']; if($row['id'] != 1 && sizeof($row) > 5){
return $row;
} else {
$row = array('id'=>1,'Bloom_Name'=>'Unknown');
return $row;


}
}

function displayImageLink($member, $size = array(80,80)){
if($member['Bloom_Name']!='Unknown'){
$return = '<a href="javascript:show_remote(\''.addslashes($member['Bloom_Name']).'.jpg\');">';
$return .= '<img width="'.$size[0].'"
src="http://www.mysite/SEArchive/'.$member['Bloom_Name'].'.jpg" height="'.$size[1].'" border="0" \></a>';
} else {
$return .= '<img width="'.$size[0].'" src="http://www.mysite/SEArchive/U/Unknown.jpg" height="'.$size[1].'" \>';
}
return $return;
}
function loadMother($child){
return loadMember($child['Pod_Name']);
}
function loadFather($child){
return loadMember($child['Pollen_Name']);
}


if(isset($_REQUEST['Search_box'])){

$search = $_REQUEST['Search_box'];

$link = mysql_connect('localhost', 'xxxx', 'xxxx');
if (!$link) { die('Could not connect: ' . mysql_error()); }
mysql_select_db('xxxxx');



$main = loadMember($search);
$mother = loadMember($main['Pod_Name']);
$father = loadMember($main['Pollen_Name']);

$grandmother1 = loadMother($father);
$grandfather1 = loadFather($father);

$grandmother2 = loadMother($mother);
$grandfather2 = loadFather($mother);

$greatgrandmother1 = loadMother($grandfather1);
$greatgrandfather1 = loadFather($grandfather1);

$greatgrandmother2 = loadMother($grandmother1);
$greatgrandfather2 = loadFather($grandmother1);

$greatgrandmother3 = loadMother($grandfather2);
$greatgrandfather3 = loadFather($grandfather2);

$greatgrandmother4 = loadMother($grandmother2);
$greatgrandfather4 = loadFather($grandmother2);

//echo "<PRE>".print_r($grandmother2,true)."</PRE>";

}
?>


<script type="text/javascript">
<!--

function show_remote(imageSrc){
OpenWindow = window.open("cvdata1.php?search="+imageSrc.substring(0,imageSrc.length-4)+"", "remoteWin", "resizable=1, scrollbars=1, toolbar=1, left=0, top=0, width=800, height=390");
/*OpenWindow.document.write('<img width="250" height="250" src="'+imageSrc+'"><br>');
OpenWindow.document.write('<div align="center"><strong>'+imageSrc.split('.')[0]+'</strong><br>');
OpenWindow.document.write('<a href="javascript:window.close();">Close Window</a></div>');
*/

}
//-->
</script>

amutha
04-30-2009, 07:21 AM
you may show the url of the site...... :confused:

jd57
04-30-2009, 12:42 PM
why do you need to know the site? can you help me with this problem?

forum_amnesiac
04-30-2009, 01:03 PM
The reason that we ask for a link to the site is so that we can actually observe what is happening and sometimes to see what other code, eg html, js, that you are using.

This can help to find a solution.

For example, your code refers to a javascript function and also to a variable, $member. What are these? How are they derived?

jd57
04-30-2009, 03:17 PM
Hi

This is the search engine url http://www.internationalhibiscussociety.org/SEArchive/SEindex1.php to see how this work, search for “Adam” all images uploads from the SEArchive/a subdirectory this part works fine, however if you select the “Comparative Analysis” button the image uploads from the SEArchive directory and this needs to be fixed to upload from SEArchive/a subdirectory.

forum_amnesiac
04-30-2009, 03:41 PM
I'm not 100% sure about this but I think that you should be able to strip the first letter from the required image and add it to the directory string. eg


$directory=http://xxxxxxx.com;
$subdir=substr(trim($imagename),0,1);
$fullpath=$directory."/". $subdir."/".$imagename;

jd57
04-30-2009, 04:06 PM
Hi
that did not work,will you accept the script to your private mail?

forum_amnesiac
04-30-2009, 05:34 PM
Ok, I'll PM you my email.

I'll have a look but I can't make any promises