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!

Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok dito

Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

uu tama ka nga isa lang.. bakit isa lang ehh 3 yung email address na nilalagay ko.. yung echo ng line tama 3 pero yung uid isa lang..

e2 yung code ko..

Code:
<form action="" method="post">
<textarea name="test" rows="20" cols="50" type ='text'>

</textarea> 
<input type="submit" value="Submit" />
</form> 

<?php
$text = trim($_POST['test']);

//explode all separate lines into an array
$textAr = explode("\n", $text);

//trim all lines contained in the array.
$textAr = array_filter($textAr, "trim");

//loop through the lines
foreach ($textAr as $line)
{
    echo "Line " . $line . "<hr>";

		$uid = mysql_query("SELECT uid FROM dr_users where mail LIKE '{$line}' ") or die(mysql_error());
   $num_rows = mysql_num_rows($uid);
			while ($row = mysql_fetch_assoc($uid))
			{
				echo 	$num_rows;	
				echo  "UID: " . $row['uid'] . "<br>";
			}
}			
?>

e2 yung ng output please see attached
80039280.png


http://imageshack.us/photo/my-images/210/80039280.png/

Ngayon ko lang naintindihan ung gusto mo gawin..

Oo tama na isa lang talaga dapat ung lalabas sa query kasi isa lang UID naman talaga ung KAtumbas ng isang email Address eh.


Ang problema is sa display nga noh... hmmm

Sure ka na ung mga email na nilagay mo is may katumbas na entry sa DB mo?

If sure naman try mo eto.. Baka dahil sa while.. pero bala na try mo parin..

Alisin mo ung while. tapos ewan ko kung may difference pero gamitin mo mysql_fetch_array

$uid = mysql_query("SELECT uid FROM dr_users where mail LIKE '{$line}' ") or die(mysql_error());

$row = mysql_fetch_array($uid)
echo "UID: " . $row['uid'] . "<br>";



 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

guys patulong naman sa cashier prog na gawa sa javascript na may sql parang ganito sya.

Item# :
Description:
Price:
Quantity:

Add button/Reset button

List of purchase item:
Description Price Quantity:

Total:
Payment:
Change:

Parang ganito ung structure nya
Pls help wala kasi akong idea.

Di namin gagawin yan bibigyan ka lang namin ng idea kung paano gawin. Kasi pag ginawa namin yan, wala po tayong matutunan. Super Spoon Feeding na po kasi.


Bale ganito, Ang mangyayari

This one:

Item# :
Description:
Price:
Quantity:

Add button/Reset button

Pasok mo lahat sa isang form. Kung JS gagamitin mo sa pag form validate ok lang. Pero HINDI KAYA NG JS makipagusap kay mysql.

Kaya gagamit ka parin ng PHP. Kasi gusto mo sya ipasok sa database. Kaya halos php nalang gamitin.

Pero kung walang database/mysql pwede pure JS nalang, Ipasok mo lang sa mga var or sa array ung mga nasa form. Tapos i document.write mo nalang ung sa baba.

Total:
Payment:
Change:

Eto bago mag output. I cocompute mo ung values through PHP.
Tapos echo nalang na may condition na isset para hindi kagad lumbas ang mga yan. Pati ung pag pasok mo sa DB sql sa form action/php mo na gagawin. Na may condition rin na isset para sa button na submit. Tapos ang method na gagamitin mo is POST



 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

Ngayon ko lang naintindihan ung gusto mo gawin..

Oo tama na isa lang talaga dapat ung lalabas sa query kasi isa lang UID naman talaga ung KAtumbas ng isang email Address eh.


Ang problema is sa display nga noh... hmmm

Sure ka na ung mga email na nilagay mo is may katumbas na entry sa DB mo?

If sure naman try mo eto.. Baka dahil sa while.. pero bala na try mo parin..

Alisin mo ung while. tapos ewan ko kung may difference pero gamitin mo mysql_fetch_array





Idol sure ako my katumbas na entry sa db ko yung mga emails na yun..

ginawa ko yung sinabi mo na alisin ko yung while ganun parin ang result... :weep: idol patulong pls.. :thanks:
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

ang ginawa mo pala is array inside an array.


Ganito bale.

Gawa ka pa ng isang variable na mag hohold ng numbers ng entries doon sa loob ng array na pinasok mo sa array :rofl: gets?

Bale

$num_entry = count($_POST[$x]); //Di ko sure kung yan or eto
$num_entry = count($d); // <------ Pero mas tingin ko eto mas tama eto muna try mo

//tapos sa mysql querry mo. Eto gawin mo

//importante ung mga space dito sa querry

$sql = "INSERT INTO {$data} VALUES(";
for($i=0; $i<$num_entry;$i++){
if($i!=$num_entry){
$sql .="$d[$i] , ";
}
else
{
$sql .="$d[$i])";
}
}

$results= mysql_query($sql);

Ayan na.. ang pinaka tag tataka ko is ung sa foreach na loop mo dun sa array BAKIT $_POST lang??? PAANO MO NAPASOK ANG array sa loob ng isang $_POST???

Kung napasok mo man. Kaylangan mo parin sya ipasok sa loob ng isang Variable para magamit mo ung mga index nya at ma count() mo.

Hi sir, ah, binago ko pala ung codes na unang nagawa ko, and i came up with this po. mas okay, siya nakakapag insert naman na ako, pero ang problema po ang value niya sa DB ko is ARRAY..

pero titignan ko parin, kung saan ako nag kamali. :)

eto po ung bago ko code.:excited:

if(isset($_POST[save]))
{
//student,grade,section,subject
$ids=$_POST['id'];
$grades=$_POST['fg'];
$secs=$_POST['secs'];
$subs=$_POST['subs'];
$yirs=$g_year['acad_id'];
$a="aa";
for($i=0;$i<count($ids) && $i<count($grades);$i++){
$id = $ids[$i];
$graded=$grades[$i];

$sql = "insert into tbl_firstgrading values(NULL,'$graded','$id','$a','$secs','$subs','$yirs')";
$result = mysql_query($sql)or die(mysql_error());
$x=1;
}
if($x==1){
$mess="YES!";
}


}
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

How to debug php line by line?

Hehe,

Use

var_dump($variable);exit;

or

echo $SQL;exit;

where $SQL = "SELECT * FROM table WHERE id = '" . $id . "';

you can see the full SQL command with the value.

Just insert those snippets to where you want a value to be checked or to know if dumaan ba talaga sa line na yon yong algo mo.
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

Idol sure ako my katumbas na entry sa db ko yung mga emails na yun..

ginawa ko yung sinabi mo na alisin ko yung while ganun parin ang result... :weep: idol patulong pls.. :thanks:


What's the problem?


I wanna rephrase the problem ha?

Problem: You had entries sa database mo na may email addresses. Each email addresses were tagged into single UID.

Entries ng database mo:
UID1 = 123; Email1 = [email protected];
UID2 = 124; Email2 = [email protected];
UID3 = 125; Email3 = [email protected];

Ganito, you provide a search query tapos yong search text is "mail" lang diba? Since "mail" lang ang query gusto mo yong 3 UIDs ang ma display kasi puro sila may "mail"?


The code:

Code:
    $search = $_POST["search"];

    /* Observe the % in this line. */
    /* Use placeholders para sa query string mo. Your query means search uid whose email has $search on it. */
    $query = mysql_query("SELECT uid FROM student WHERE email = '%" . $search . "%'");

    /* Check if query has a result, otherwise echo no result found. */
    if (mysql_num_rows($query) > 0)
    {
        /* Use mysql_fetch_assoc, mysql_fetch_array, mysql_fetch_row in here and it doesn't matter. */
        /* What matter is mysql_fetch_assoc is more user friendly and faster than the two. */
        /* Lesser resource used compared to mysql_fetch_array. */
        /* Lesser risk when using mysql_fetch_row, especially when query string changes it's column orders. */
        while ($row = mysql_fetch_assoc($query))
        {
            /* This line here will loop 3 times based sa data na binigay ko sa taas. */
            /* There you go meron ka dapat 3 items na magdisplay. */
            echo $row["uid"];
        }
    }
    else
    {
        echo "No result found.";
    }

If that's the problem above.

Please correct the problem if I misinterpreted it so that we could find other solution to fix your problem.
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

Hi sir, ah, binago ko pala ung codes na unang nagawa ko, and i came up with this po. mas okay, siya nakakapag insert naman na ako, pero ang problema po ang value niya sa DB ko is ARRAY..

pero titignan ko parin, kung saan ako nag kamali. :)

eto po ung bago ko code.:excited:


MALI talaga. (Sorry for my rudeness)

Kasi sa design mo, mahirapan ka mag.link ng grades for the students. How will the student look for their grades?


It should be one record per student in each grade.

Student1 = 90
Student2 = 99
Student3 = 70

Dapat ganyan maka.store yong data mo sa database.

Code:
    /* Dump values are this */
    /*
     id = array("011", "012", "013");
     grade = array(90, 99, 95);
     subject = array("english", "filipino", "math");
    */
    /* We should expect to have the same count ng array for id and grade otherwise magkakamali tayo ng pagkakaassign ng grades if one is missing. */
    $id = $_POST["id"];
    $grade = $_POST["grade"];
    $subject = $_POST["subject"];

    /* We'll build a new array in such a way yong grades ma tagged dun sa id. */
    $new = array();

    /* We'll use the indexes of the array until the length of id. */
    for ($i = 0; $i < count($id); $i++)
    {
        $new[$id[$i]] = array(
            "grade" => $grade[$i],
            "subject" => $subject[$i]
        );
    }

    /* Let see the new structure of our array. */
    var_dump($new);

    /* Create SQL statement OPTION 1. */
    $new_values = array();

    foreach ($new as $key => $value)
    {
        /* We will create a string like this : ('ID', 'GRADE', 'SUBJECT'). */
        $new_values[] = "('" . $key . "', '" . implode("', '", $value) . "')";
    }

    /* Insert values by batch */
    if (count($new_values) > 0)
    {
        /* We will create a SQL like this "INSERT INTO table (id, grade, subject) VALUES ('011', '90', 'english'), ('012', '99', 'filipino'), ('013', '95', 'math')". */
        $query = mysql_query("INSERT INTO table (id, grade, subject) VALUES " . implode(", ", $new_values) . "");
    }

    /* Done */

    /* Option 2 */
    foreach ($new as $key => $value)
    {
        /* This will loop 3 times and insert your 3 values. */
        $query = mysql_query("INSERT INTO table (id, grade, subject) VALUES ('" . $key . "', '" . implode("', '", $value) . "')");
    }

Just add the fields na gusto mo e.add. Just to give you the idea how yan lang ginamit kong values.
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2


@hakuna_matata

Boss ung dito naman sa problem ni rhence .. Di po pwede ung sinugest nyo.. kasi

What's the problem?


I wanna rephrase the problem ha?

Problem: You had entries sa database mo na may email addresses. Each email addresses were tagged into single UID.

Entries ng database mo:
UID1 = 123; Email1 = [email protected];
UID2 = 124; Email2 = [email protected];
UID3 = 125; Email3 = [email protected];

Ganito, you provide a search query tapos yong search text is "mail" lang diba? Since "mail" lang ang query gusto mo yong 3 UIDs ang ma display kasi puro sila may "mail"?


The code:

Code:
    $search = $_POST["search"];

    /* Observe the % in this line. */
    /* Use placeholders para sa query string mo. Your query means search uid whose email has $search on it. */
    $query = mysql_query("SELECT uid FROM student WHERE email = '%" . $search . "%'");

    /* Check if query has a result, otherwise echo no result found. */
    if (mysql_num_rows($query) > 0)
    {
        /* Use mysql_fetch_assoc, mysql_fetch_array, mysql_fetch_row in here and it doesn't matter. */
        /* What matter is mysql_fetch_assoc is more user friendly and faster than the two. */
        /* Lesser resource used compared to mysql_fetch_array. */
        /* Lesser risk when using mysql_fetch_row, especially when query string changes it's column orders. */
        while ($row = mysql_fetch_assoc($query))
        {
            /* This line here will loop 3 times based sa data na binigay ko sa taas. */
            /* There you go meron ka dapat 3 items na magdisplay. */
            echo $row["uid"];
        }
    }
    else
    {
        echo "No result found.";
    }

If that's the problem above.

Please correct the problem if I misinterpreted it so that we could find other solution to fix your problem.


kasi tignan nyo po ung image na binigay nya

80039280.png



Is mag ttype sya ng emails sa isang TEXT AREA.
Tapos ini explode nya at trim para mapasok sa array ung bawat
email na nakalagay doon.

Tapos isesearch nya ung bawat isang email na un sa DB para mag return ng info.


Sa query nyo po kasi is. ung "search" po kasi is a text na may maraming emails...

kahit gumamit ng % di sya pwede ma apply kasi text area na
may /n ung sa kanya.



EDIT: Tinesting ko ung % search % di po sya pwede. Mas effective ung ginagawa nya ngaun kasi pinapasok nya sa array tapos naka trim pa..
 
Last edited:
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

use kang


IN


Code:
$email = $_POST["email"];

$email = explode("\n", $email);

/* Dump $email should be array(). */

/* SELECT * FROM table WHERE email IN ('[email protected]', '[email protected]', '[email protected]') */
$query = mysql_query("SELECT * FROM table WHERE email IN ('" . implode("', '", $email) . "')");
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2


PARENG RHENCE!!! NAGAWA KO NA!! AHAHAHAHA

Sinbukan ko kasi dito, dahil wala akong magawa. MATATAWA KA SA SOLUTION :rofl:

Tignan mo ung akin

attachment.php


Eto ung version ko wag mo gamitin yan kasi iba iba ung variable name na ginamit ko pero ang solution is parehas lang

<?php
if(isset($_POST['submit'])){
$text = trim($_POST['searchy']);
//explode all separate lines into an array
$textAr = explode("\n", $text);
//trim all lines contained in the array.
$textAr = array_filter($textAr, "trim");
//loop through the lines
foreach ($textAr as $line)
{
echo "Line " . $line . "<hr>";
$name=trim($line);

$uid = mysql_query("SELECT id FROM wherelike WHERE Name ='{$name}'",$connection);
$num_rows = mysql_num_rows($uid);
echo "Num Rowss: " . $num_rows;
$row = mysql_fetch_assoc($uid);
echo " UID: " . $row['id'] . "<br>";
}
}
?>


ANG SOLUTION IS!



IPASOK MO ULIT SA LOOB NG ISA PANG VARIABLE si $line tapos sa search querry mo imbis na $line .. ang gamitin mo is ung bagong variable!!! aahahahahahaahha

parang ganito

$emails=trim($line);

:thumbsup: Natuwa ako sa pag-sosolve ng problem mo! THANKS!

 

Attachments

  • Capture.PNG
    Capture.PNG
    9.2 KB · Views: 40
Last edited:
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

Pa Mark dami ko natutunan dito thanks mga kaSB
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

Di namin gagawin yan bibigyan ka lang namin ng idea kung paano gawin. Kasi pag ginawa namin yan, wala po tayong matutunan. Super Spoon Feeding na po kasi.


Bale ganito, Ang mangyayari

This one:



Pasok mo lahat sa isang form. Kung JS gagamitin mo sa pag form validate ok lang. Pero HINDI KAYA NG JS makipagusap kay mysql.

Kaya gagamit ka parin ng PHP. Kasi gusto mo sya ipasok sa database. Kaya halos php nalang gamitin.

Pero kung walang database/mysql pwede pure JS nalang, Ipasok mo lang sa mga var or sa array ung mga nasa form. Tapos i document.write mo nalang ung sa baba.



Eto bago mag output. I cocompute mo ung values through PHP.
Tapos echo nalang na may condition na isset para hindi kagad lumbas ang mga yan. Pati ung pag pasok mo sa DB sql sa form action/php mo na gagawin. Na may condition rin na isset para sa button na submit. Tapos ang method na gagamitin mo is POST




salamat kasi accounting ako eh sa it namin to wala akong masyadong alam sa javascript sa mysql pero may alam ako kaso limited lang
kasi sabi ni prof ung list of purchased items, sa may sql daw magdidisplay dapat ung table, pag nag input ka dun sa upper part dapat lalabas sya dun sa table sa my sql, 3 javascript saw gagamitin, pwede humingi kahit kunting code.

pwede palang gamitin php jasvascript din mysql sabi ni prof :(
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

Item# :
Description:
Price:
Quantity:

Add button/Reset button

//bali pag pag press ng add lalabas agad sa baba ung items

List of purchase item:
Description| Price | Quantity
_________ _____ _______
_________ _____ _______

Total:
Payment:
Change:

di ko lang talaga maintindihan ung pag pasok ng mga item sa DB limited lang kasi alam ko dun.
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

guys sorry hindi ko naka-pag OL ng ilang weeks, haha.. super loaded ako this month saka next month.. drop by lang ako muna, sumakit na ulo ko kaka-program hahaha..
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

Have a nice long vacation sir nitz, hahaha...


Ok lang yon... may time talaga na busy lalo na pag may projects.
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

XSS Vulnerable pala si simsimi.
Isa sa mga dapat niyung iwasan when making websites. They can inject iframe, redirects, even phish users accounts pag vulnerable site niyo sa mga ganyan..

Try typing: "mipf"
without qoutations sa simsimi and see what happens.

Also try typing: "pcac" and "ccit"

edit: Nafix na ni simsimi yung exploit..

anyways eto yung screenshot:
n1Teh.png


i was able to redirect simsimi too to another site, add photos sa post niya, etc.

all is done via html entities.
 
Last edited:
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

mga sir bakit ganun pag inaayos ko ung pagesize saka linesize sa sql, nawawala ung ibang records.. hindi nagshoshow.
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

hello, :) patulong nanaman ako ulet..

Code:
<?php
//[B]checks if meron o walang student na na search[/B]
//kaso po di po siya nag vavalidate, tama ba validation na ginawa ko to check kung may na hanap o wala... :)
        			if($val = mysql_num_rows > 0)
					{
					echo "No Student Record Found!";
					}
					else
					{
					//gagawin na niya to, ipapakita niya ung mga na search nya!
					while($result=mysql_fetch_array($query)){
					
							echo $result[id].'<br>';
							echo $result[sub_id];
							echo $result[grading];
							echo $result[fg];
							echo $result[sg];
							echo $result[tg];
							}
					}	
		?>
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

hello, :) patulong nanaman ako ulet..

Code:
<?php
//[B]checks if meron o walang student na na search[/B]
//kaso po di po siya nag vavalidate, tama ba validation na ginawa ko to check kung may na hanap o wala... :)
        			if([COLOR="Red"]$val = mysql_num_rows [COLOR="Blue"]>[/COLOR] 0[/COLOR])
					{
					echo "No Student Record Found!";
					}
					else
					{
					//gagawin na niya to, ipapakita niya ung mga na search nya!
					while($result=mysql_fetch_array($query)){
					
							echo $result[id].'<br>';
							echo $result[sub_id];
							echo $result[grading];
							echo $result[fg];
							echo $result[sg];
							echo $result[tg];
							}
					}	
		?>

change the code in red into this one
Code:
if(mysql_num_rows($result) = 0)

error (code in red)
mali ang syntax mo for the mysql_num_rows(), since may parameter na hinihingi yung function na yan, yun yung value ng sql result...

error (code in blue)
change > to =
REASON:
kung yung nasa condition ay ">" ang ginamit mo, at nag-true ang condition na yun, ang idi-display nya ay "No student record found!", wherein hindi naman yun ang totoo, since nag-return nga sya ng value na greater than 0, it means na meron sya nakita na records...
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

mga sirs, meron po ba dito nakakaalam ng code for login and sign up ng website? please po patulong dreamweaver po gamit ko mga bossing.
 
Back
Top Bottom