sort data in alphabetical order using php [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I get the data from database and I want to sort hotel_name in alphabetical order. How can I do it using php's sort function or any other method ?
foreach($selData as $row)
{
$name=$row['hotel_name'];
$distance_colombo=$row['distance_colombo'];
$distance_airport=$row['distance_airport'];
$description=$row['description'];
$activities=$row['activities'];
$str=(explode(',',$activities));
print_r($str);
}

There's no need to use sort() here. Just use ORDER BY in your SQL query.
Example:
SELECT * FROM table_name ORDER BY hotel_name

Related

Regex to select everything in between two characters [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need to create a regex that will select the data between two characters (& - #).
& foo #
I would like to select foo.
Any ideas? Good explanations are also appreciated.
how about this:
preg_match('~&([^#]*)#~',$content,$match);

how can i print the mySQL sum() in php [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have this query and i am asking if i can print the result in PHP without saving the result in other table.
SELECT SUM(weekly_fees) FROM scout_cabs
You start by giving it an alias to output:
SELECT SUM(`weekly_fees`) AS `total` FROM `scout_cabs`
Then you parse it as any normal request via mysql.
<?php
$sql = "SELECT SUM(`weekly_fees`) AS `total` FROM `scout_cabs`";
$run = mysql_query($sql);
$result = mysql_fetch_assoc($run);
echo 'The sum of the query is: ' . number_format($result['total']);
It may also be worth looking into mysqli_ if you are not already using it, as mysql_ is now deprecated.

How to know the stored procedure parameters in PHP? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to populate my MSSQL database, so, I will run some procedures with random data. I have to get the parameters of every SP. How I can do that?
Thanks.
You can find it with simple query -
SELECT p.name
FROM sys.objects o
INNER JOIN sys.parameters p ON p.[object_id] = o.[object_id]
WHERE o.[name] = 'stored_proc_name' AND o.[type] = 'P'

select query for date between [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am doing a project where i have to fetch data of between dates plus the name of user.
The query for only date betweenis working fine but with and operater its going in wrong way so please suggest me how to implement it to achieve desired output.
this is my code:
$qry11=mysqli_query($con,"select * from entry where (create_date between '$first' and '$second') && cnor='$nme'");
so please suggest ne how to do this....any idea will be appreciate with highly gratitude.
&&
should be replaced with
AND
You seem to be already using AND in your query right
(create_date between '$first' and '$second')
use the query like below
$qry11=mysqli_query($con,"select * from entry where (create_date between '$first' and '$second') and cnor='$nme'");

Use this php code wih WHERE [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Can I use this php code wih WHERE? SELECT SUM(buzz) as buzz FROM $table I want to calculate sumation of some spesific rows.
If you want specifically in PHP then this might help you
SELECT SUM(buzz) as buzz FROM $table WHERE $where
No, you can't use PHP code in an SQL where condition. Databases typically don't include a PHP interpreter.
What you can do is use PHP to generate the where clause that you need.

Categories