[eluser]rakish[/eluser]
what is wrong with my codes? big help..thank you in advance..
here is my controller:
<?php
class About_img extends MY_Controller
{
function About_img()
{
parent::MY_Controller();
$this->load->helper(array('form', 'url'));
$this->load->model('mabout_content');
}
function uploadStaffImg()
{
$dirPath = dir('./media/img/images/about');
$options = array();
while (($file = $dirPath->read()) !== false)
{
if ((substr($file, -3)=="gif") || (substr($file, -3)=="jpg") || (substr($file, -3)=="png"))
{
$options[ ] = trim($file);
}
}
$dirPath->close();
sort($options);
//$c = count($imgArray);
foreach($options as $key=>$val)
{
//echo "<option value=\"" . $val. "\">" . $val . "\n";
echo form_dropdown($val);
}
$this->load->view('backend/admin/about/staff_img');
if(isset($_POST['about2']))
{
$image=$_POST['staff_img'];
$this->db->get($res);
//$result = mysql_query("UPDATE about_img SET mission_img='$image' WHERE id='1'") or die (mysql_error());
}
}
}
view:
[removed]
$(document).ready(function() {
$(".hl").mouseover(function() {$(this).addClass("trover");}).mouseout(function() {$(this).removeClass("trover");});
Date.firstDayOfWeek = 0;
Date.format = 'yyyy-mm-dd';
$('.date-pick').datePicker({startDate: '2009-05-01', endDate: (new Date()).asString()});
})
function confirmDelete(delUrl){
if (confirm("Are you sure you want to delete?"))
document.location = delUrl;
else
return false;
}
[removed]
<br />
<div class="tsmall">
<fieldset size="30">
<legend align="right">Upload Images</legend>-->
<td width="15%" ><img class="pictr" src="../../media/img/about/<?php echo $mission_img;?>" width="100" height="100"></td>
<td width="14%"><strong>Mission Pic</strong></td>
<td width="19%"><strong>Filename: <?php echo $mission_img;?></strong></td>
<td width="29%">
<form action="backend/about_img/uploadStaffImg" name="about2" method="post">
<select class="styled" name="staff_img">
<option value="">- Select Image -
<?php
$staffImg=uploadStaffImg();
echo $staffImg;
?>
</option>
</select>
<input type="submit" name="about2" value="Save" />
</form>
</td>
</tr>
</table>
<hr />
<center><a href="http://localhost/cote/backend/about">Back</a></center>
</fieldset>
</div>
model:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Mabout_img extends Model
{
var $table;
//var $datenow;
function Mabout_img()
{
$this->table = "about_img";
//$this->datenow = date("Y-m-d H:i
");
}
function uploadStaffImg($params)
{
$id = (isset($params['id'])) ? $params['id'] : 0;
//unset($params['id']);
if( $id > 0 )
{
$this->db->update($this->table, $params, array('id'=>$id));
return;
}
}
}
my aim is to have a dropdown list from the folder.