Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
Im having a little trouble with a php script ive made.
you can see all the relevant info at http://click-media.co.uk/Client/Lisa/Admin/admin.php (password: "hey")
I basically need the classes to be ordered by day/time when a new class is created, either by changing the column names in the database to a timestamp or something or by making a new column to and ordering it by this.. then using the php to switch the order values when the admin clicks "moveup"/"move down" next to the row.
any help would be much appreciated.
Thanks
You can implement this by doing the following:
Add a column in the database and call it class_order
Your SQL query should have ORDER BY class_order
Moving up UPDATE table set class_order = THE_ORDER_OF_THE_CLASS_ABOVE WHERE id = TARGET_CLASS and UPDATE table set class_order = TARGET_CLASS_ORDER WHERE id = THE_CLASS_ABOVE
Moving down is the opposite of moving up
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
i have a column of user names and every name is repeating one or more than one. i want to display that user name maximum one time through php or sql query. Any suggestions please?
I think i understand your problem you want to get rid of the repeating elements from your result returned by sql so if you are working in php you can do it by:
1) get your result in ascending order
2) do this in your php code
$temp=NULL;
$names=array();
$i=0;
foreach($result as $row){
if($row->id!=$temp){
$temp=$row->id;
$name[$i]=$temp;
$i++;
}
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I want to store and display recently viewed posts. I don't want to use cookies because not only want to show what the visitor him/her self viewed posts but viewed by others as well.
I know I can simply store post id in the table and display the data. But is this is best way to do this. As I understand this will store huge amount of junk data in the database as I only want to display 10 latest viewed posts on my website.
Can anyone tell me a better way to do this or is this the only way to do this?
Add a "dt_lastViewed" field to your "Posts" table. Update it when it's been viewed, and pull the top 10 for your module.
Optionally, create another field called "timesViewed" so that you can increment and track the most popular posts! May be considered YAGNI
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I had tried to find last inserted id in php, but I am unable to get.
It displays value 0.
This is my code:
require_once "../config.php";
$query = "call experience_insert('$uid','$title','$cname','$sdate','$edt')";
$result = $connection->ServerDb->query($query);
$id = $connection->ServerDb->insert_id;
You should post the relevant sections of the stored procedure you're calling. It should have a return statement that gives back the ID. Keep in mind there are weird gotchas with MySQL stored procedures and last_insert_id() as well.
http://dev.mysql.com/doc/refman/5.7/en/stored-routines-last-insert-id.html
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I am trying to separate my code into functions to make it more readable.
I made a function to update a field in a database. What I am trying to do is that when they change the username it goes to update Account function then updates the session variable , the smarty var,and the database regarding the name.
Everything gets updated after the form is submitted but the smarty variable and I can't figure out why(i know its something to do with the scope) because if i declare it out of the function it works fine.
All the magic that i need fixed is in the Home portion of the routing section of my code. Thank you for any help :)
code :http://pastebin.com/VdRPz3hc
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I have a PHP script that displays data read from a MySQL database. I want to filter the output to only show rows where two columns contain specific values. How do I do this?
Add a WHERE clause, e.g., WHERE column1 = 'specific-value1' AND column2 = 'specific-value2'
Here's a link to MySQL's SELECT syntax:
http://dev.mysql.com/doc/refman/5.1/en/select.html
(and in German):
http://dev.mysql.com/doc/refman/5.1/de/select.html
no idea why you are posting in german on an english site and then translating it to english. But what you need to do is something like "select * from table where column1='val' and column2='val'". Though it sounds like you have a large set of data pulled off already and you want to filter that. I don't see why you shouldn't just query what you need from the database instead of pulling everything off and then filtering.