Hi, this is my query
$result = mysql_query("SELECT SUM(`qty`) FROM sims_ac WHERE region ='North'");
How I can show this
$result[0]
without using While loop or any other loop.
Hi, this is my query
$result = mysql_query("SELECT SUM(`qty`) FROM sims_ac WHERE region ='North'");
How I can show this
$result[0]
without using While loop or any other loop.
You need to use a function to extract the result array from the $result
resource. If you are only interested in the first result you get from your query, you can just use this:
$row = mysql_fetch_array($result);
EDIT: $row
will contain the first row of results returned by the database. If you want just the data for the first field from that first result, then you only need to access $row[0]
$row = mysql_fetch_row($result
echo $row[0];
You can actually do this with a single line of code:
// mysql_result() function is used to pull a single value from the database
$value = mysql_result(mysql_query("SELECT value FROM table WHERE condition = 'met'"), 0);
SELECT count(*),Code FROM `lims_cmt` group by code having count(*)>1 LIMIT 0, 30 ;
Coutt more then 1
i write query
<?php
$query=select username from table_name where username=$username;
$query_result=mysql_query($query) or die("Sorry there is no value" .mysql_error());
while($row=mysql_fetch_object($query_result)){
echo $row->username;
}
?>
Waseem12, are you asking a question? You may want to start a new thread if you are, and I'm sure people will be happy to help.
The code you have above will not run.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.