...

View Full Version : variable subdirectory path (a-z)



jdimino
05-01-2009, 01:54 AM
Hello
I would like to change the image path, from http://www.Mysite/SEArchive/ to a variable subdirectory path (a-z).
I have tried the following code
$row['Bloom_Label']=$row['Bloom_Name'];
$row['Bloom_Name']=strtoupper($row['Bloom_Name'][0]) . '/' . $row['Bloom_Name'];
but this code does not work, any suggestions?






<?PHP

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


function find($name, $view){
global $link;

// Fetch total number of records
//$SQL="SELECT * FROM ihsreg WHERE Bloom_Name ='".addslashes($name)."'";
if(stristr($name,"'") && !stristr($name,"\'")){
$name = addslashes($name);
}

switch($view){
case "1": $column = 'Bloom_Name'; break;
case "2": $column = 'Pod_Name'; break;
case "3": $column = 'Pollen_Name'; break;
case "4": $column = 'Hybridiser'; break;
case "5": $column = 'Origin'; break;
default: $column = 'Bloom_Name'; break;

}


$SQL = "SELECT Bloom_Name, Pod_Name, Pollen_Name, Hybridiser, Origin " .
"FROM ihsreg " .
"WHERE " . $column . " LIKE '" . $name . "' AND $column != '' " .
"ORDER BY Bloom_Name ASC";

$result = mysql_query($SQL);
$results = array();
while($row = mysql_fetch_row($result)){
$row['Bloom_Label']=$row['Bloom_Name'];
$row['Bloom_Name']=strtoupper($row['Bloom_Name'][0]) . '/' . $row['Bloom_Name'];

$results[] = $row;
}
return $results;
}

$noimagemessage = "No Photo Available";
if(isset($_GET['search'])){
//$fp = file('reg.txt');
//$search = "/".stripslashes($_GET['search'])."/i";
$search = $_GET['search'];
$y = 0;
$results[0]=Array();
$results[1]=Array();
$results[2]=Array();
$results[3]=Array();
$results[4]=Array();
//for($x=0; $x<count($fp); $x++){
/*
$search_text = "";
if($_GET['view']==5){
$search_text = split("\|",$fp[$x]);
$search_text = $search_text[4];
}else if($_GET['view']==4){
$search_text = split("\|",$fp[$x]);
$search_text = $search_text[3];
}else if($_GET['view']==3){
$search_text = split("\|",$fp[$x]);
$search_text = $search_text[2];
}else if($_GET['view']==2){
$search_text = split("\|",$fp[$x]);
$search_text = $search_text[1];
}else{
$search_text = split("\|",$fp[$x]);
$search_text = $search_text[0];
}
*/
$results = find($search,$_GET['view']);

/*
if(preg_match($search,$search_text)){
list($results[0][$y],$results[1][$y],$results[2][$y],$results[3][$y],$results[4][$y])=split("\|",$fp[$x]);
$y++;
}
*/
$y = sizeof($results);
//}
/*
if($_GET['view']==5){
array_multisort($results[4],$results[0],$results[1],$results[2],$results[3]);
}else if($_GET['view']==4){
array_multisort($results[3],$results[0],$results[1],$results[2],$results[4]);
}else if($_GET['view']==3){
array_multisort($results[2],$results[0],$results[1],$results[3],$results[4]);
}else if($_GET['view']==2){
array_multisort($results[1],$results[0],$results[2],$results[3],$results[4]);
}else{
array_multisort($results[0],$results[1],$results[2],$results[3],$results[4]);
}
*/
//echo '<PRE style="font-size: 9px;">';print_r($results);echo "</pre>";

}
?>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
img{
border:0;
}
</style>
<script type="text/javascript">
function open_win(img){
window.open("cvdata1.php?search="+img);
}
</script>
</head>
<body bgcolor="#FFFFFF" BACKGROUND="file:///E%7C/IHS%20Backup/old_new_scripts/newsearch/cvimages/b2a.jpg"><body>
<div align="center"><img src="http://www.Mysite/SEArchive/SEimages/CVtittle.gif" width="320" height="65">
<br>
<b><font face="Trebuchet MS">Click On Image For Details</font></b><br>
<table border=2 width="100%" bordercolor="#006666" cellpadding="1" cellspacing="1" bordercolorlight="#999900" bordercolordark="#CCCC00">
<?PHP
for($x=0; $x<count(@$results); $x++){
echo '<tr>';
echo '<th width="150" height="7" bgcolor="#CCFFCC"><font color="#000000" face="Trebuchet MS">CULTIVAR';
echo 'NAME</font></th>';
echo '<th width="150" height="7" bgcolor="#339999"><font color="#000000" face="Trebuchet MS">MOTHER</font></th>';
echo '<th width="150" height="7" bgcolor="#99CCCC"><font color="#000000" face="Trebuchet MS">FATHER</font></th>';
echo '<th width="150" height="7" bgcolor="#CCCC99"><font color="#000000" face="Trebuchet MS">HYBRIDISER</font></th>';
echo '<th width="150" height="7" bgcolor="#CCCC33"><font color="#000000" face="Trebuchet MS">ORIGIN</font></th>';
echo '</tr>';
echo '<tr>';
echo '<th width="150" height="7" bgcolor="#CCFFCC">' . (file_exists((trim($results[$x][0]).".jpg"))?'<a href="cvdata1.php?search='. $results[$x][0] .'" onclick="open_win(\'' . addslashes($results[$x][0]) . '\'); return false;"><img width="140" height="140" src="http://www.Mysite/SEArchive/'.$results[$x][0].'.jpg"></a>':'<div style="padding-top:65px; width:140px; height:140px;">'.$noimagemessage.'</div>') . '<br><font color="#000000" face="Trebuchet MS"><b>'.$results[$x][0].'</b></font></th>';
echo '<th width="150" height="7" bgcolor="#339999">' . (file_exists((trim($results[$x][1]).".jpg"))?'<a href="cvdata1.php?search='. $results[$x][1] .'" onclick="open_win(\'' . addslashes($results[$x][1]) . '\'); return false;"><img width="140" height="140" src="http://www.Mysite/SEArchive/'.$results[$x][1].'.jpg"></a>':'<div style="padding-top:65px; width:140px; height:140px;">'.$noimagemessage.'</div>') . '<br><font color="#000000" face="Trebuchet MS"><b>'.$results[$x][1].'</b></font></th>';
echo '<th width="150" height="7" bgcolor="#99CCCC">' . (file_exists((trim($results[$x][2]).".jpg"))?'<a href="cvdata1.php?search='. $results[$x][2] .'" onclick="open_win(\'' . addslashes($results[$x][2]) . '\'); return false;"><img width="140" height="140" src="http://www.Mysite/SEArchive/'.$results[$x][2].'.jpg"></a>':'<div style="padding-top:65px; width:140px; height:140px;">'.$noimagemessage.'</div>') . '<br><font color="#000000" face="Trebuchet MS"><b>'.$results[$x][2].'</b></font></th>';
echo '<th width="150" height="7" bgcolor="#CCCC99">' . (file_exists((trim($results[$x][3]).".jpe"))?'<img width="140" height="140" src="http://www.Mysite/SEArchive/'.$results[$x][3].'.jpe">':'<div style="padding-top:65px; width:140px; height:140px;">'.$noimagemessage.'</div>') . '<br><font color="#000000" face="Trebuchet MS"><b>'.$results[$x][3].'</b></font></th>';
echo '<th width="150" height="7" bgcolor="#CCCC33">' . (file_exists((trim($results[$x][4]).".jpe"))?'<img width="140" height="140" src="http://www.Mysite/SEArchive/'.$results[$x][4].'.jpe">':'<div style="padding-top:65px; width:140px; height:140px;">'.$noimagemessage.'</div>') . '<br><font color="#000000" face="Trebuchet MS"><b>'.$results[$x][4].'</b></font></th>';
echo '</tr>';
echo '<tr><td colspan=5>&nbsp;</td></tr>';
/*
echo '<tr><td width="100%" align="center">Cultivar:'.$results[0][$x].'</td></tr>';
echo '<tr><td width="100%" align="center"><table width="100%"><tr>';
echo '<td width="50%" align="center"><img width="140" height="140" src="'.$results[0][$x].'.jpg">';
echo '<br><b>'.$results[0][$x].'</b></td>';
echo '<td width="50%" align="center"><img width="140" height="140" src="'.$results[1][$x].'.jpg">';
echo '<br><b>'.$results[1][$x].'</b></td>';
echo '<td width="50%" align="center"><img width="140" height="140" src="'.$results[2][$x].'.jpg">';
echo '<br><b>'.$results[2][$x].'</b></td>';
echo '<td width="50%" align="center"><img width="140" height="140" src="'.$results[3][$x].'.jpe">';
echo '<br><b>'.$results[3][$x].'</b></td>';
echo '<td width="50%" align="center"><img width="140" height="140" src="'.$results[4][$x].'.jpe">';
echo '<br><b>'.$results[4][$x].'</b></td>';

echo '</tr></table></td></tr>';
*/
}
if(count(@$results[0])==0){
echo '<tr><td width="100%" colspan=5 align="center">No results found.</td></tr>';
}
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum