Welcome Guest, Not a member yet? Register   Sign In
DropDownMenu-- please help
#1

[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>--&gt;

<td width="15%" ><img class="pictr" src="../../media/img/about/&lt;?php echo $mission_img;?&gt;" width="100" height="100"></td>
<td width="14%"><strong>Mission Pic</strong></td>
<td width="19%"><strong>Filename: &lt;?php echo $mission_img;?&gt;</strong></td>
<td width="29%">
&lt;form action="backend/about_img/uploadStaffImg" name="about2" method="post"&gt;
<select class="styled" name="staff_img">
<option value="">- Select Image -
&lt;?php
$staffImg=uploadStaffImg();
echo $staffImg;
?&gt;

</option>
</select>


&lt;input type="submit" name="about2" value="Save" /&gt;
&lt;/form&gt;
</td>
</tr>
</table>
<hr />

<center><a href="http://localhost/cote/backend/about">Back</a></center>
</fieldset>
</div>

model:
&lt;?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:iConfused");
}



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.
#2

[eluser]jedd[/eluser]
You might have more luck if you [url="http://codeigniter.com/wiki/How_to_ask_a_good_question/"]ask a better question[/url].

Obvious things include separating and tagging (with [ code ]) your code partials, identifying intended & desired behaviour, and clearly describing how the actual results deviate from the expected results .. etc.
#3

[eluser]rakish[/eluser]
ok sir..uhm is this how you browse in codeigniter, I mean browsing your file from folders?

Quote:$dirPath = dir('./media/img/images');
#4

[eluser]jedd[/eluser]
There's no 'browse' capability per se - that is, if you're looking for a function that will generate a navigable front-end to your file system.

Rather than using the dir() function, you might use the [url="/user_guide/helpers/file_helper.html"]CI File Helper[/url] - say the get_filenames() function. Though you're not obliged to - you can still use vanilla PHP functionality wherever you want, of course.




Theme © iAndrew 2016 - Forum software by © MyBB