After searching data when i click on next page then it doesn't work with searching results. After click it goes on first page. How can i solve this problem ?
Thank you
Controller:
public function gkclientsadd(){
$arg["src"] = 0;
$arg["pageOffset"] = 0;
$np = $this->uri->segment(3);
$data["offset"] = 0;
$this->search_by = 0;
if($_SERVER['REQUEST_METHOD'] == 'GET')
{
if(isset($_GET["client_search"]))
{
$arg["login"] = $this->input->get('login');
$arg["pwd"] = $this->input->get('pwd');
$arg["basetariff"] = $this->input->get("basetariff");
$arg["crc"] = $this->input->get("crc");
$arg["resone"] = $this->input->get("resone");
$arg["rpp"] = $this->default_rpp;
$arg["offset"] = $this->default_offset;
$arg["src"] = 1;
$this->search_basetariff = $arg["basetariff"];
$this->search_currency = $arg["crc"];
$this->search_parent = $arg["resone"];
$this->search_by = 1;
//print_r($arg);die;
} else $arg["src"] = 0;
}
if(!empty($np)){
$arg["pageOffset"] = ($np/$this->default_rpp);
$arg["rpp"] = $this->default_rpp;
$arg["offset"] = ($this->default_rpp)*$arg["pageOffset"];
$data["offset"] = $arg["offset"];
$arg["src"] = 1;
}
$data["gkclientsData"] = $this->admin_model->getGkclients($this->userId, $this->rtc_table,$arg, $this->default_rpp, $this->default_offset);
$data["getTotalGk"] = $this->admin_model->getTotalGk($this->rtc_table,$arg);
$data["totalRecords"] = count($data["getTotalGk"]);
$data["totalPage"] = $data["totalRecords"]/$this->default_rpp;
$data["Page"] = $arg["pageOffset"]+1;
$config = array();
$config["base_url"] = base_url() . "index.php/admin/gkclientsadd";
$config["total_rows"] = $data["totalRecords"] ;
$config["per_page"] = $this->default_rpp;
$config["uri_segment"] = 3;
$config['first_url'] = $config['base_url'].'?'.http_build_query($_GET);
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data["links"] = $this->pagination->create_links();
$this->load->view('admin/clients/gkclientsadd',$data);
}
Model:
public function getGkclients($userId, $rtc_table,$arg, $default_rpp,$default_offset)
{
$this->load->database();
if($arg['src']== 1){
$whr = "";
$rpp = "";
$offset = "";
if(!empty($arg["rpp"])) $rpp .= " LIMIT ".$arg["rpp"]."";
if(!empty($arg["offset"])) $offset .= " OFFSET ".$arg["offset"]."";
if(!empty($arg["login"])) $whr .= " AND $rtc_table.login = '".$arg["login"]."'";
if(!empty($arg["pwd"])) $whr .= " AND $rtc_table.password = '".$arg["pwd"]."'";
if(!empty($arg["basetariff"])) $whr .= " AND $rtc_table.id_tariff = '".$arg["basetariff"]."'";
if(!empty($arg["crc"])) $whr .= " AND $rtc_table.id_currency = '".$arg["crc"]."'";
if(!empty($arg["resone"])) $whr .= " AND $rtc_table.id_res = '".$arg["resone"]."'";
} else {
$whr="";
$rpp= "Limit $default_rpp";
$offset= "OFFSET $default_offset";
}
$query = "SELECT DISTINCT $rtc_table.id_client,$rtc_table.id_res,$rtc_table.login,$rtc_table.password,$rtc_table.id_tariff,
$rtc_table.account_state,$rtc_table.type,$rtc_table.type2,currency_names.name
FROM $rtc_table, currency_names
WHERE currency_names.id = $rtc_table.id_currency $whr
order by $rtc_table.login ASC $rpp $offset";
$query_result = $this->db->query($query);
$gkData=$query_result->result();
return $gkData;
}
http://i.stack.imgur.com/yMa6d.jpg
Related
I've read some texts and searched topics, but nothing help me. I'm beginner in PHP. I have array where are variables $qA01_1 up to $qA30_5 and their values can be different 0 or 1 or 5. From array I would like to find all variables with value 1 and make sum. Same for number 5.
$qA01_1 = $_SESSION['qA01_1'];
$qA01_2 = $_SESSION['qA01_2'];
$qA01_3 = $_SESSION['qA01_3'];
$qA01_4 = $_SESSION['qA01_4'];
$qA01_5 = $_SESSION['qA01_5'];
$qA02_1 = $_SESSION['qA02_1'];
$qA02_2 = $_SESSION['qA02_2'];
$qA02_3 = $_SESSION['qA02_3'];
$qA02_4 = $_SESSION['qA02_4'];
$qA02_5 = $_SESSION['qA02_5'];
$qA03_1 = $_SESSION['qA03_1'];
$qA03_2 = $_SESSION['qA03_2'];
$qA03_3 = $_SESSION['qA03_3'];
$qA03_4 = $_SESSION['qA03_4'];
$qA03_5 = $_SESSION['qA03_5'];
$qA04_1 = $_SESSION['qA04_1'];
$qA04_2 = $_SESSION['qA04_2'];
$qA04_3 = $_SESSION['qA04_3'];
$qA04_4 = $_SESSION['qA04_4'];
$qA04_5 = $_SESSION['qA04_5'];
$qA05_1 = $_SESSION['qA05_1'];
$qA05_2 = $_SESSION['qA05_2'];
$qA05_3 = $_SESSION['qA05_3'];
$qA05_4 = $_SESSION['qA05_4'];
$qA05_5 = $_SESSION['qA05_5'];
$qA06_1 = $_SESSION['qA06_1'];
$qA06_2 = $_SESSION['qA06_2'];
$qA06_3 = $_SESSION['qA06_3'];
$qA06_4 = $_SESSION['qA06_4'];
$qA06_5 = $_SESSION['qA06_5'];
$qA07_1 = $_SESSION['qA07_1'];
$qA07_2 = $_SESSION['qA07_2'];
$qA07_3 = $_SESSION['qA07_3'];
$qA07_4 = $_SESSION['qA07_4'];
$qA07_5 = $_SESSION['qA07_5'];
$qA08_1 = $_SESSION['qA08_1'];
$qA08_2 = $_SESSION['qA08_2'];
$qA08_3 = $_SESSION['qA08_3'];
$qA08_4 = $_SESSION['qA08_4'];
$qA08_5 = $_SESSION['qA08_5'];
$qA09_1 = $_SESSION['qA09_1'];
$qA09_2 = $_SESSION['qA09_2'];
$qA09_3 = $_SESSION['qA09_3'];
$qA09_4 = $_SESSION['qA09_4'];
$qA09_5 = $_SESSION['qA09_5'];
$qA10_1 = $_SESSION['qA10_1'];
$qA10_2 = $_SESSION['qA10_2'];
$qA10_3 = $_SESSION['qA10_3'];
$qA10_4 = $_SESSION['qA10_4'];
$qA10_5 = $_SESSION['qA10_5'];
$qA11_1 = $_SESSION['qA11_1'];
$qA11_2 = $_SESSION['qA11_2'];
$qA11_3 = $_SESSION['qA11_3'];
$qA11_4 = $_SESSION['qA11_4'];
$qA11_5 = $_SESSION['qA11_5'];
$qA12_1 = $_SESSION['qA12_1'];
$qA12_2 = $_SESSION['qA12_2'];
$qA12_3 = $_SESSION['qA12_3'];
$qA12_4 = $_SESSION['qA12_4'];
$qA12_5 = $_SESSION['qA12_5'];
$qA13_1 = $_SESSION['qA13_1'];
$qA13_2 = $_SESSION['qA13_2'];
$qA13_3 = $_SESSION['qA13_3'];
$qA13_4 = $_SESSION['qA13_4'];
$qA13_5 = $_SESSION['qA13_5'];
$qA14_1 = $_SESSION['qA14_1'];
$qA14_2 = $_SESSION['qA14_2'];
$qA14_3 = $_SESSION['qA14_3'];
$qA14_4 = $_SESSION['qA14_4'];
$qA14_5 = $_SESSION['qA14_5'];
$qA15_1 = $_SESSION['qA15_1'];
$qA15_2 = $_SESSION['qA15_2'];
$qA15_3 = $_SESSION['qA15_3'];
$qA15_4 = $_SESSION['qA15_4'];
$qA15_5 = $_SESSION['qA15_5'];
$qA16_1 = $_SESSION['qA16_1'];
$qA16_2 = $_SESSION['qA16_2'];
$qA16_3 = $_SESSION['qA16_3'];
$qA16_4 = $_SESSION['qA16_4'];
$qA16_5 = $_SESSION['qA16_5'];
$qA17_1 = $_SESSION['qA17_1'];
$qA17_2 = $_SESSION['qA17_2'];
$qA17_3 = $_SESSION['qA17_3'];
$qA17_4 = $_SESSION['qA17_4'];
$qA17_5 = $_SESSION['qA17_5'];
$qA18_1 = $_SESSION['qA18_1'];
$qA18_2 = $_SESSION['qA18_2'];
$qA18_3 = $_SESSION['qA18_3'];
$qA18_4 = $_SESSION['qA18_4'];
$qA18_5 = $_SESSION['qA18_5'];
$qA19_1 = $_SESSION['qA19_1'];
$qA19_2 = $_SESSION['qA19_2'];
$qA19_3 = $_SESSION['qA19_3'];
$qA19_4 = $_SESSION['qA19_4'];
$qA19_5 = $_SESSION['qA19_5'];
$qA20_1 = $_SESSION['qA20_1'];
$qA20_2 = $_SESSION['qA20_2'];
$qA20_3 = $_SESSION['qA20_3'];
$qA20_4 = $_SESSION['qA20_4'];
$qA20_5 = $_SESSION['qA20_5'];
$qA21_1 = $_SESSION['qA21_1'];
$qA21_2 = $_SESSION['qA21_2'];
$qA21_3 = $_SESSION['qA21_3'];
$qA21_4 = $_SESSION['qA21_4'];
$qA21_5 = $_SESSION['qA21_5'];
$qA22_1 = $_SESSION['qA22_1'];
$qA22_2 = $_SESSION['qA22_2'];
$qA22_3 = $_SESSION['qA22_3'];
$qA22_4 = $_SESSION['qA22_4'];
$qA22_5 = $_SESSION['qA22_5'];
$qA23_1 = $_SESSION['qA23_1'];
$qA23_2 = $_SESSION['qA23_2'];
$qA23_3 = $_SESSION['qA23_3'];
$qA23_4 = $_SESSION['qA23_4'];
$qA23_5 = $_SESSION['qA23_5'];
$qA24_1 = $_SESSION['qA24_1'];
$qA24_2 = $_SESSION['qA24_2'];
$qA24_3 = $_SESSION['qA24_3'];
$qA24_4 = $_SESSION['qA24_4'];
$qA24_5 = $_SESSION['qA24_5'];
$qA25_1 = $_SESSION['qA25_1'];
$qA25_2 = $_SESSION['qA25_2'];
$qA25_3 = $_SESSION['qA25_3'];
$qA25_4 = $_SESSION['qA25_4'];
$qA25_5 = $_SESSION['qA25_5'];
$qA26_1 = $_SESSION['qA26_1'];
$qA26_2 = $_SESSION['qA26_2'];
$qA26_3 = $_SESSION['qA26_3'];
$qA26_4 = $_SESSION['qA26_4'];
$qA26_5 = $_SESSION['qA26_5'];
$qA27_1 = $_SESSION['qA27_1'];
$qA27_2 = $_SESSION['qA27_2'];
$qA27_3 = $_SESSION['qA27_3'];
$qA27_4 = $_SESSION['qA27_4'];
$qA27_5 = $_SESSION['qA27_5'];
$qA28_1 = $_SESSION['qA28_1'];
$qA28_2 = $_SESSION['qA28_2'];
$qA28_3 = $_SESSION['qA28_3'];
$qA28_4 = $_SESSION['qA28_4'];
$qA28_5 = $_SESSION['qA28_5'];
$qA29_1 = $_SESSION['qA29_1'];
$qA29_2 = $_SESSION['qA29_2'];
$qA29_3 = $_SESSION['qA29_3'];
$qA29_4 = $_SESSION['qA29_4'];
$qA29_5 = $_SESSION['qA29_5'];
$qA30_1 = $_POST['qA30_1'];
$qA30_2 = $_POST['qA30_2'];
$qA30_1 = (isset($_POST['qA30_1'])) ? $_POST['qA30_1'] : 0;
$qA30_2 = (isset($_POST['qA30_2'])) ? $_POST['qA30_2'] : 0;
$qA30_3 = (isset($_POST['qA30_3'])) ? $_POST['qA30_3'] : 0;
$qA30_4 = (isset($_POST['qA30_4'])) ? $_POST['qA30_4'] : 0;
$qA30_5 = (isset($_POST['qA30_5'])) ? $_POST['qA30_5'] : 0;
Here is my proposal which do not work. I thing that I should to do something with "array" .
// Sum of all numbers 1
$sumOne = 0;
for ($i = 0; $i <= 3; $i++) {
for($j = 0; $j <= 9; $j++) {
for($k = 1; $k <= 5; $k++){
$u = 'qA_' . $i . $j. '_' . $k;
if ($u==1){
$sumOnet+=1;
}
}
}
}
echo "<br/>SumOne:" . " " . round($sumOne[0], 0);
You really should stick with an array. If you define an array within the $_SESSION array and use that it will be much simpler:
$_SESSION['data']['qA01_1'] = 0;
$_SESSION['data']['qA01_2'] = 1;
$_SESSION['data']['qA01_3'] = 5;
$counts = array_count_values($_SESSION['data']);
if(isset($counts[0])) { echo $counts[0]; } // sum of any 0s is 0 so here is the count
if(isset($counts[1])) { echo $counts[1]; } // sum of any 1s will be the count
if(isset($counts[5])) { echo $counts[5] * 5; }
If I understand the question correctly, you want to sum up all individual values in your array.
You can use array_count_values() for that, it returns you the number of occurances of each value where the value itself is the key:
foreach (array_count_values($_SESSION) as $value => $count) {
echo 'sum of ' . $value . ' values: ' . ($value * $count) . "<br>";
}
No idea where the POST variables fit in though...
i'm writing a php web script with mvc, but i'm concerned about code is safe.
i fear most "eval($str)", but i try a lot of php function string but nothing happened.
$a = func_get_args();
if((func_num_args()-1)%2 == 0){
$str = "";
array_shift($a);
for($i = 0;$i<sizeof($a);$i++){
if($i%2==0){
if(!is_numeric($a[$i])){
if($a[$i] == 'filter'){
$filter=1;
}
$str.= "$".stripslashes($a[$i])." = ";
}else{
$str.= 'page';
}
}else{
if($filter != 1){
if(is_numeric($a[$i])){
$str.= stripslashes($a[$i]).";";
}else{
$str.=1;
}
}else{
$arr = explode("-",$a[$i]);
$dizz = 'array(';
for($j=0;$j<sizeof($arr);$j++){
if(($j%2)==0){
$dizz .= '\''.stripslashes($arr[$j]).'\'=>';
}else{
$dizz .= '\''.stripslashes($arr[$j]).'\',';
}
}
$dizz = rtrim($dizz,',');
$dizz .= ');';
$str.= $dizz;
}
}
}
eval($str);
}
$filter = isset($filter) ? $filter : false;
$page= isset($page) ? $page: '';
$count= isset($count) ? $count: '';
if($count == ''){
switch ($process) {
case 'table':
$count = 40;
break;
case 'detailed':
$count = 3;
break;
case 'mobile':
$count = 12;
break;
default:
$count = '';
break;
}
}
if($count != ''){
if(is_numeric($count )){
if($count <=200 && $count >0){
$count = $count ;
}else{
$count = 40;
}
}else{
$count = 1;
}
}
if(!is_numeric($page)){
$page= 1;
}
to sql query->
$new_filter = "Where ";
if($filter){
foreach ($filteras $key => $value) {
$new_filter .= 'k.'.$key.'='.$value.' and ';
}
$new_filter = rtrim($new_filter,' and ');
$filter= $new_filter;
}else{
$filter= '';
}
$limit = ($limit) ? 'LIMIT 30' : '';
if($id == ''){
$where = $filter;
}else{
$where = $id;
}
$query = 'select * from kullanici as k join kisiler as ki on k.id = ki.kullanici_id join iletisim as i on k.id = i.kullanici_id '.$where.' '.$siralama.' '.$limit;
$query = $this->_db->prepare($query);
$query->execute();
example url:
profile/show/mobile/page/4/count/5/filter/echo-"'xzcxza'"-sadas-asdxc
this results:
$page = 4;$count= 5;$filter= array('echo'=>'%22%27xzcxza%27%22','sadas'=>'asdxc');
I have some data in url
sub_cat.php?s=1&os=3,1&brand=10,9&camera=19&storage=15,13&data=17
I have:
operating systems with id 3 and 1
brands with id 10 and 9
camera with id 19
storage with id 15 and 13
data with id 17
i want to show mobiles having these specifications from sql database
if (isset($_GET['brand'])) {
$sf_brand = $_GET['brand'];
$brand_split = explode(',', $sf_brand);
$sf_brand_len = count($brand_split);
for ($ab=0; $ab < $sf_brand_len; $ab++) {
$append_sf_brand .= 'OR product.product_brand LIKE \''.$brand_split[$ab].'\' ';
}
$append_sf_brand_f = '('.substr($append_sf_brand, 3).')';
}else{
$append_sf_brand_f = '';
}
if (isset($_GET['os'])) {
$sf_os = $_GET['os'];
$os_split = explode(',', $sf_os);
$sf_os_len = count($os_split);
for ($ao=0; $ao < $sf_os_len; $ao++) {
$append_sf_os .= 'OR productspec.prospec_expspec_id LIKE \''.$os_split[$ao].'\' ';
}
$append_sf_os_f = '('.substr($append_sf_os, 3).')';
}else{
$append_sf_os_f = '';
}
if (isset($_GET['camera'])) {
$sf_camera = $_GET['camera'];
$camera_split = explode(',', $sf_camera);
$sf_camera_len = count($camera_split);
for ($ac=0; $ac < $sf_camera_len; $ac++) {
$append_sf_camera .= 'OR productspec.prospec_expspec_id LIKE \''.$camera_split[$ac].'\' ';
}
$append_sf_camera_f = '('.substr($append_sf_camera, 3).')';
}else{
$append_sf_camera_f = '';
}
if (isset($_GET['data'])) {
$sf_data = $_GET['data'];
$data_split = explode(',', $sf_data);
$sf_data_len = count($data_split);
for ($ad=0; $ad < $sf_data_len; $ad++) {
$append_sf_data .= 'OR productspec.prospec_expspec_id LIKE \''.$data_split[$ad].'\' ';
}
$append_sf_data_f = '('.substr($append_sf_data, 3).')';
}else{
$append_sf_data_f = '';
}
if (isset($_GET['storage'])) {
$sf_storage = $_GET['storage'];
$storage_split = explode(',', $sf_storage);
$sf_storage_len = count($storage_split);
for ($as=0; $as < $sf_storage_len; $as++) {
$append_sf_storage .= 'OR productspec.prospec_expspec_id LIKE \''.$storage_split[$as].'\' ';
}
$append_sf_storage_f = '('.substr($append_sf_storage, 3).')';
}else{
$append_sf_storage_f = '';
}
$sf_condition = '(product.product_id LIKE productspec.prospec_product_id) AND '.$append_sf_brand_f.' AND '.$append_sf_os_f.' AND '.$append_sf_camera_f.' AND '.$append_sf_data_f.' AND '.$append_sf_storage_f;
I have query:
$get_brand_query = mysqli_query($connect, "SELECT * FROM product, productspec WHERE $sf_condition");
But it is not working well, so how I can show mobiles can anyone help me thanks.
i am getting error in my program. in this program i want to make if periode active show data when the periode active but when periode not active not show data anything. but i try this condition i am getting error Trying to get property of non-object in model.
this is modal
function get_id_periode_open()
{
$this->db->where('tgl_dari <= curdate()');
$this->db->where('tgl_sampai >= curdate()');
// $this->db->where('status', 'open');
$row = $this->db->get('periode')->row();
$id_periode = $row->id_periode; //line error
return $id_periode;
}
this is my controller
function index($nama = '',$period = 0,$geup = 0)
{
$this->load->model('mukt');
$id_periode = $this->mukt->get_id_periode_open();
$this->data['id_periode_sekarang'] = $id_periode;
if ($id_periode)
{
$this->data['ukt2'] = $this->mukt->get_ukt($perpage,$offset);
}
else
{
echo "string";
$this->data['contents'] = '<div class="twelve wide column">Tidak ada periode aktif</div>';
}
if (!$nama AND $this->input->post('nama'))
{
$nama = $this->input->post('nama');
}
else if(!$nama)
{
$nama = 0;
}
if ($this->input->post('id_periode')){
$period = $this->input->post('id_periode');
}
else if(!$period)
{
$period = 0;
}
if ($this->input->post('geup')){
$geup = $this->input->post('geup');
}
else if(!$geup)
{
$geup = 0;
}else{
$geup = urldecode($geup);
}
// echo $period. urldecode($geup). $nama;
$count = $this->mukt->get_count_peserta_ukt($period, urldecode($geup), $nama);
// print_r($count);
// exit;
// Set up pagination
$offset = 0;
$perpage = 1;
$uri_segment = 6;
if ($count > $perpage) {
$this->load->library('pagination');
$this->load->config('pagination');
$config = $this->config->item('pag');
$config['base_url'] = site_url('pelatih/ukt/'.$nama.'/'.$period.'/'.$geup);
$config['total_rows'] = $count;
$config['per_page'] = $perpage;
$config['uri_segment'] = $uri_segment;
$config['first_page'] = 'Awal';
$config['last_page'] = 'Akhir';
$config['next_page'] = '«';
$config['prev_page'] = '»';
$this->pagination->initialize($config);
$this->data['pagination'] = $this->pagination->create_links();
if($this->uri->segment($uri_segment)){
$offset = $this->uri->segment($uri_segment);
}
}
else {
$this->data['pagination'] = '';
$offset = 0;
}
$this->data['periode'] = $this->mperiode->get_periode();
if ($period AND $geup)
{
$this->data['ukt2'] = $this->mukt->get_cari_peserta_ukt($period, $geup ,$nama,$perpage,$offset);
}
else if($nama && (!$period || !$this->input->post('geup')))
{
$this->data['ukt2'] = $this->mukt->get_cari_peserta_ukt("", "",$nama,$perpage,$offset);
}
else
{
$this->data['ukt2'] = $this->mukt->get_ukt($perpage,$offset);
}
$this->data['title'] ='UKM Taekwondo | ukt';
$this->data['orang'] = $this->mlogin->dataPengguna($this->session->userdata('username'));
$this->data['contents'] = $this->load->view('pelatih/ukt/view_ukt', $this->data, true);
$this->load->view('template/wrapper/pelatih/wrapper_anggota',$this->data);
please tell me how to solved this error.
thank you.
may be your query returns no result, so try doing:
$query = $this->db->get('periode');
if( $query->num_rows() > 0 ) {
$row = $query->row();
$id_periode = $row->id_periode;
return $id_periode;
}
return 0;
I'm using this function:
function getmyimages($qid){
$imgdir = 'modules/Projects/uploaded_project_images/'. $qid .''; // the directory, where your images are stored
$allowed_types = array('png','jpg','jpeg','gif'); // list of filetypes you want to show
$dimg = opendir($imgdir);
while($imgfile = readdir($dimg))
{
if(in_array(strtolower(substr($imgfile,-3)),$allowed_types))
{
$a_img[] = $imgfile;
sort($a_img);
reset ($a_img);
}
}
$totimg = count($a_img); // total image number
for($x=0; $x < $totimg; $x++)
{
$size = getimagesize($imgdir.'/'.$a_img[$x]);
// do whatever
$halfwidth = ceil($size[0]/2);
$halfheight = ceil($size[1]/2);
$mytest = 'name: '.$a_img[$x].' width: '.$size[0].' height: '.$size[1].'<br />'. $a_img[$x]. '';
}
return $mytest;
}
And I call this function between a while row as:
$sql_select = $db->sql_query('SELECT * from '.$prefix.'_projects WHERE topic=\''.$cid.'\'');
OpenTable();
while ($row2 = $db->sql_fetchrow($sql_select)){
$qid = $row2['qid'];
$project_query = $db->sql_query('SELECT p.uid, p.uname, p.subject, p.story, p.storyext, p.date, p.topic, p.pdate, p.materials, p.bidoptions, p.projectduration, pd.id_duration, pm.material_id, pbo.bidid, pc.cid FROM ' . $prefix . '_projects p, ' . $prefix . '_projects_duration pd, ' . $prefix . '_project_materials pm, ' . $prefix . '_project_bid_options pbo, ' . $prefix . '_project_categories pc WHERE p.topic=\''.$cid.'\' and p.qid=\''.$qid.'\' and p.bidoptions=pbo.bidid and p.materials=pm.material_id and p.projectduration=pd.id_duration');
while ($project_row = $db->sql_fetchrow($project_query)) {
//$qid = $project_row['qid'];
$uid = $project_row['uid'];
$uname = $project_row['uname'];
$subject = $project_row['subject'];
$story = $project_row['story'];
$storyext = $project_row['storyext'];
$date = $project_row['date'];
$topic = $project_row['topic'];
$pdate = $project_row['pdate'];
$materials = $project_row['materials'];
$bidoptions = $project_row['bidoptions'];
$projectduration = $project_row['projectduration'];
//Get the topic name
$topic_query = $db->sql_query('SELECT cid,title from '.$prefix.'_project_categories WHERE cid =\''.$cid.'\'');
while ($topic_row = $db->sql_fetchrow($topic_query)) {
$topic_id = $topic_row['cid'];
$topic_title = $topic_row['title'];
}
//Get the material text
$material_query = $db->sql_query('SELECT material_id,material_name from '.$prefix.'_project_materials WHERE material_id =\''.$materials.'\'');
while ($material_row = $db->sql_fetchrow($material_query)) {
$material_id = $material_row['material_id'];
$material_name = $material_row['material_name'];
}
//Get the bid methode
$bid_query = $db->sql_query('SELECT bidid,bidname from '.$prefix.'_project_bid_options WHERE bidid =\''.$bidoptions.'\'');
while ($bid_row = $db->sql_fetchrow($bid_query)) {
$bidid = $bid_row['bidid'];
$bidname = $bid_row['bidname'];
}
//Get the project duration
$duration_query = $db->sql_query('SELECT id_duration,duration_value,duration_alias from '.$prefix.'_projects_duration WHERE id_duration =\''.$projectduration.'\'');
while ($duration_row = $db->sql_fetchrow($duration_query)) {
$id_duration = $duration_row['id_duration'];
$duration_value = $duration_row['duration_value'];
$duration_alias = $duration_row['duration_alias'];
}
}
echo '<br/><b>id</b>--->' .$qid. '<br/><b>uid</b>--->' .$uid. '<br/><b>username</b>--->' .$uname. '<br/><b>subject</b>--->'.$subject. '<br/><b>story1</b>--->'.$story. '<br/><b>story2</b>--->'.$storyext. '<br/><b>postdate</b>--->'.$date. '<br/><b>categorie</b>--->'.$topic_title . '<br/><b>project start</b>--->'.$pdate. '<br/><b>materials</b>--->'.$material_name. '<br/><b>bid methode</b>--->'.$bidname. '<br/><b>project duration</b>--->'.$duration_alias.'<br /><br /><br/><b>image url</b>--->'.getmyimages($qid).'<br /><br />';
}
CloseTable();
The result outputs only the "last" file from the directories.
If I do an echo instead of a return $mytest;, it reads the whole directory but ruins the output.
You are always overwriting $mytest in your loop:
for($x=0; $x < $totimg; $x++)
{
$size = getimagesize($imgdir.'/'.$a_img[$x]);
// do whatever
$halfwidth = ceil($size[0]/2);
$halfheight = ceil($size[1]/2);
$mytest = 'name: '.$a_img[$x].' width: '.$size[0].' height: '.$size[1].'<br />'. $a_img[$x]. '';
}
return $mytest;
So after the loop, $mytest contains the last value that was generated in the loop. You might want to return an array instead:
$mytest = array();
for($x=0; $x < $totimg; $x++)
{
$size = getimagesize($imgdir.'/'.$a_img[$x]);
// do whatever
$halfwidth = ceil($size[0]/2);
$halfheight = ceil($size[1]/2);
$mytest[] = 'name: '.$a_img[$x].' width: '.$size[0].' height: '.$size[1].'<br />'. $a_img[$x]. '';
}
return $mytest;
But of course you also have to change your other function in order to deal with the returned array.