Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2
boss nka connect na po xa sa db problema ko nlng po ay f "select * from table_name" ilalabas nya lahat ng data sa db na table_name pro pag e specify ko naman gaya ng "where card ='$card' " wala siyang display..tulung naman pohh..
ito code ko sa function
Code:
public function getPosts($card) {
$result = mysql_query("SELECT * FROM uu");
$posts = array();
while($row = mysql_fetch_array($result)) {
$posts[] = $row;
}
return $posts;
}
sa php namn
Code:
nclude 'functions.php';
$User = new User();
$posts = $User->getPosts($card);?>
<?php foreach ($posts as $row){ ?>
<?php echo $row['card']; ?>
<?php echo $row['name']; ?>
<?php echo $row['depo']; ?>
<?php } ?>
Baka nagkakamali ka sa query statement mo..
help select
Name: 'SELECT'
Description:
Syntax:
SELECT
[ALL | DISTINCT | DISTINCTROW ]
[HIGH_PRIORITY]
[STRAIGHT_JOIN]
[SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]
[SQL_CACHE | SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS]
select_expr [, select_expr ...]
[FROM table_references
[WHERE where_condition]
[GROUP BY {col_name | expr | position}
[ASC | DESC], ... [WITH ROLLUP]]
[HAVING where_condition]
[ORDER BY {col_name | expr | position}
[ASC | DESC], ...]
[LIMIT {[offset,] row_count | row_count OFFSET offset}]
[PROCEDURE procedure_name(argument_list)]
[INTO OUTFILE 'file_name'
[CHARACTER SET charset_name]
export_options
| INTO DUMPFILE 'file_name'
| INTO var_name [, var_name]]
[FOR UPDATE | LOCK IN SHARE MODE]]
SELECT is used to retrieve rows selected from one or more tables, and
can include UNION statements and subqueries. See [HELP UNION], and
http://dev.mysql.com/doc/refman/5.1/en/subqueries.html.
The most commonly used clauses of SELECT statements are these:
o Each select_expr indicates a column that you want to retrieve. There
must be at least one select_expr.
o table_references indicates the table or tables from which to retrieve
rows. Its syntax is described in [HELP JOIN].
o The WHERE clause, if given, indicates the condition or conditions
that rows must satisfy to be selected. where_condition is an
expression that evaluates to true for each row to be selected. The
statement selects all rows if there is no WHERE clause.
In the WHERE expression, you can use any of the functions and
operators that MySQL supports, except for aggregate (summary)
functions. See
http://dev.mysql.com/doc/refman/5.1/en/expressions.html, and
http://dev.mysql.com/doc/refman/5.1/en/functions.html.
SELECT can also be used to retrieve rows computed without reference to
any table.
URL:
http://dev.mysql.com/doc/refman/5.1/en/select.html
here some of my example.
Code:
$query="SELECT stores.address, purchaseorderid,suppliername,suppliers.address,suppliers.phone,suppliers.term, DATE_FORMAT(NOW(),'%m-%d-%Y'),shippername,gross,net from (($db.purchaseorders inner join $db2.suppliers on purchaseorders.supplierid=suppliers.supplierid) left join $db2.shippers on purchaseorders.shipperid=shippers.shipperid),$db2.stores where stores.storename='$db' and purchaseorderid=$id";
$result=mysql_query($query);
if (!$result)
{
throw new Exception(mysql_error());
}
$row=mysql_fetch_row($result);
$storeadd=$row[0];
$purchaseid=$row[1];
$suppliername=$row[2];
$supplieradd=$row[3];
. and so on........
//more codes here.....
You have to test your query statement first in your mysql console(window) or terminal (linux) before applying it to your code..