Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

Help naman po sa backend (PHP x Mysqli)

ScreamAimsFire

Proficient
Advanced Member
Messages
228
Reaction score
13
Points
38
Una sa po lahat bago ako mag post dito nag search na po ako sa google etc etc,

Ang tanong ko po kung, Possible ko po ba mag filter ang specific data value ng isang table?

Example : si employee po ang aking table ay meron po akong 3 fields at yung si name_id(1,2,3), name_list(juan,pedro,tasyo) at section(s1,s2,s3), ang tanong ko po ay possible po ba? na ang ma fetch ko lang sa isang page ay si section 3(s3) at hindi lahat ng section, at hindi sila section 1 and 2? i mean si section 3 lang mag ooutput sa page na si 3,tasyo,s3 ? sana po may makatulong at maka intindi sa may kaguluhang explanation ko hehe Salamt po :)
 
So ang gusto mong mapick ay (3, tasyo, s3) ? bakit di mo nalang i-pick si 3 para makita mo ung (3, tasyo, s3) ?
 
use joinwith if gusto mo ma kuha yung relation ng eh ffilter mo sa main
 
So ang gusto mong mapick ay (3, tasyo, s3) ? bakit di mo nalang i-pick si 3 para makita mo ung (3, tasyo, s3) ?

Ang gusto ko po mang yare ay meron po akong isa page na ang output lang ay specific section lang po. Na ang gusto ko lang lumabas sa page ay lahat lang po ng s3 employees. At pano ko po sya i ququery. Salamat po sa respond

- - - Updated - - -

use joinwith if gusto mo ma kuha yung relation ng eh ffilter mo sa main

Than you po, pero ang gusto ko lang po na maging output ay lahat ng nag input ng s3 kay section. Pano ko po sya i ququery ty
 
Code:
select *
from table
where category<>"S3"

ano na ang nagagawa mo sa sql?
 
Code:
select *
from table
where category<>"S3"

ano na ang nagagawa mo sa sql?

nakakapag crud na po ako sa php and sql, bali ang problema ko na lang po ay pag fefetch ng specific data column gaya po ng example ko.

- - - Updated - - -

so bali ang magiging query ko po ay


select *
from employee
where section<>"S3"


tama po ba?

- - - Updated - - -

so bali ang magiging query ko po ay


select *
from employee
where section<>"S3"


tama po ba?
 
try mo mag google minsan nandyan na yung clue kung pano mo masosolve yang problem mo . Punta ka ka google or youtube type mo ito "Mysql how to use JOIN".
 
try mo mag google minsan nandyan na yung clue kung pano mo masosolve yang problem mo . Punta ka ka google or youtube type mo ito "Mysql how to use JOIN".

joinwith nga

Bakit kailangan ng join? eh iisang table lang naman ung concern nya.

Ito yung given data
Code:
name_id		1		2		3
name_list	juan		pedro		tasyo
section		s1		s2		s3

na kapag kinonvert natin sa horizontal view ay magiging:

Code:
name_id		name_list	section
1		juan		s1
2		pedro		s2
3		tasyo		s3
 
madaming na nagsasabi po na join table.

SELECT * FROM tbl_1 as t1 INNER JOIN tbl_2 as t2 ON t1.id = t2.id

kung meron ka iseselect.

example.

SELECT * FROM tbl_1 as t1 INNER JOIN tbl_2 as t2 ON t1.id = t2.id WHERE t1.id=1
 
ganito ba sir kailangan mo?

Halimbawa ito yung html page mo.
Code:
<table>
   <tr>
        <td>Section</td><td>Action</td>
   </tr>
   <tr>
        <td>S1</td><td><a href="[COLOR="#FF0000"][B]view_section.php?section=S1[/B][/COLOR]">View section S1</a></td>
   </tr>
   <tr>
        <td>S2</td><td><a href="[COLOR="#FF0000"][B]view_section.php?section=S2[/B][/COLOR]">View section S2</a></td>
   </tr>
   <tr>
        <td>S3</td><td><a href="[COLOR="#FF0000"][B]view_section.php?section=S3[/B][/COLOR]">View section S3</a></td>
   </tr>
</table>

ito naman yung view_section.php
Code:
<?php
[COLOR="#FF0000"]$section = isset($_GET['section'])?$_GET['section']:"";[/COLOR]
    
    // retrieve mo yung record sa database gamit ang sql statement na ito to variable $records, i hope alam mo na kung paano.
    // "SELECT * FROM employee WHERE section =".$section
   
   [COLOR="#FF0000"]if($records){[/COLOR]
       
    // display employee list by section in table form.
       
      

  [COLOR="#FF0000"]}[/COLOR]
?>
 
Last edited:
Bakit kailangan ng join? eh iisang table lang naman ung concern nya.

Ito yung given data
Code:
name_id		1		2		3
name_list	juan		pedro		tasyo
section		s1		s2		s3

na kapag kinonvert natin sa horizontal view ay magiging:

Code:
name_id		name_list	section
1		juan		s1
2		pedro		s2
3		tasyo		s3

Tama po sir ang kailangan ko lang po kasi i output ay specific na data input na lahat po ng ng nag input ng s3 under section.
 
Una sa po lahat bago ako mag post dito nag search na po ako sa google etc etc,

Ang tanong ko po kung, Possible ko po ba mag filter ang specific data value ng isang table?

Example : si employee po ang aking table ay meron po akong 3 fields at yung si name_id(1,2,3), name_list(juan,pedro,tasyo) at section(s1,s2,s3), ang tanong ko po ay possible po ba? na ang ma fetch ko lang sa isang page ay si section 3(s3) at hindi lahat ng section, at hindi sila section 1 and 2? i mean si section 3 lang mag ooutput sa page na si 3,tasyo,s3 ? sana po may makatulong at maka intindi sa may kaguluhang explanation ko hehe Salamt po :)

Given :
Table: employee
Data:
Code:
[B]name_id     name_list     section[/B]
1                juan            s1  
2                pedro          s2
3                tasyo           s3

Output: 3, tasyo, s3

Solution:

Code:
<?php

 # Init the MySQL Connection
  if( !( $db = mysql_connect( 'localhost' , 'root' , '' ) ) )
    die( 'Failed to connect to MySQL Database Server - #'.mysql_errno().': '.mysql_error();
  if( !mysql_select_db( 'employee' ) )
    die( 'Connected to Server, but Failed to Connect to Database - #'.mysql_errno().': '.mysql_error();

  $selectSQL = "Select * from employee where section = 's3'"; // can be a variable
 # Execute the SELECT Query
  if( !( $selectRes = mysql_query( $selectSQL ) ) ){
    echo 'Retrieval of data from Database Failed - #'.mysql_errno().': '.mysql_error();
  }else{
    ?>
<table>
  <thead>
    <tr>
      <th>ID</th>
      <th>Name</th>
      <th>Section</th>
    </tr>
  </thead>
  <tbody>
    <?php
      if( mysql_num_rows( $selectRes )==0 ){
        echo '<tr><td colspan="4">No Rows Returned</td></tr>';
      }else{
        while( $row = mysql_fetch_assoc( $selectRes ) ){
          echo "<tr><td>{$row['name_id']}</td><td>{$row['name_list']}</td><td>{$row['section']}</td></tr>\n";
        }
      }
    ?>
  </tbody>
</table>

    <?php
   } //close else

?>
 
Last edited:
Possible po ba? na lahat nang mag input ng s3 kay section ay ma filter? at yun lang po ang mai-output. sa isang page, like gagawa ako ng page kay s1, s2, and s3. at lahat lang po nang mag iinput ng s1 or s2 ay sya lang po ang lilitaw sa isang page?

Halimbawa po:
Code:
                  name_id		name_list	         section
                     1	  	          juan		     s1
                     2		          pedro		     s2
                     3		          tasyo		     s3
                     4                   pablo                    s3
                     5                   efren                    s3
Yan po yung table at ang gusto ko po sana mang yare ay ang ma post ko lang po sa isang page ay lahat ng may section s3 na sila tasyo, pablo, at efren. at naka seperate din sa ibang page bawat section na parang na fifilter nya yung mga section na gusto ko po i output sa isang page. Pasensya na po dahil nag aaral pa lang po ako ng back end, maraming salamat po sa mga nag rerespond :)
 
Last edited:
Possible po ba? na lahat nang mag input ng s3 kay section ay ma filter? at yun lang po ang mai-output. sa isang page, like gagawa ako ng page kay s1, s2, and s3. at lahat lang po nang mag iinput ng s1 or s2 ay sya lang po ang lilitaw sa isang page?

Halimbawa po:
Code:
                  name_id		name_list	         section
                     1	  	          juan		     s1
                     2		          pedro		     s2
                     3		          tasyo		     s3
                     4                   pablo                    s3
                     5                   efren                    s3
Yan po yung table at ang gusto ko po sana mang yare ay ang ma post ko lang po sa isang page ay lahat ng may section s3 na sila tasyo, pablo, at efren. at naka seperate din sa ibang page bawat section na parang na fifilter nya yung mga section na gusto ko po i output sa isang page. Pasensya na po dahil nag aaral pa lang po ako ng back end, maraming salamat po sa mga nag rerespond :)

yup ayan na code. nakaloop yan kahit ilang s3 pa yan
Code:
while( $row = mysql_fetch_assoc( $selectRes ) ){
          echo "<tr><td>{$row['name_id']}</td><td>{$row['name_list']}</td><td>{$row['section']}</td></tr>\n";
        }


Code:
<?php

 # Init the MySQL Connection
  if( !( $db = mysql_connect( 'localhost' , 'root' , '' ) ) )
    die( 'Failed to connect to MySQL Database Server - #'.mysql_errno().': '.mysql_error();
  if( !mysql_select_db( 'employee' ) )
    die( 'Connected to Server, but Failed to Connect to Database - #'.mysql_errno().': '.mysql_error();

  $selectSQL = "Select * from employee where section = 's3'"; // can be a variable
 # Execute the SELECT Query
  if( !( $selectRes = mysql_query( $selectSQL ) ) ){
    echo 'Retrieval of data from Database Failed - #'.mysql_errno().': '.mysql_error();
  }else{
    ?>
<table>
  <thead>
    <tr>
      <th>ID</th>
      <th>Name</th>
      <th>Section</th>
    </tr>
  </thead>
  <tbody>
    <?php
      if( mysql_num_rows( $selectRes )==0 ){
        echo '<tr><td colspan="4">No Rows Returned</td></tr>';
      }else{
        while( $row = mysql_fetch_assoc( $selectRes ) ){
          echo "<tr><td>{$row['name_id']}</td><td>{$row['name_list']}</td><td>{$row['section']}</td></tr>\n";
        }
      }
    ?>
  </tbody>
</table>

    <?php
   } //close else

?>
 
Last edited:
Back
Top Bottom