Can you not do a recursive function instead? I imagine it would be more flexible. So in my example I'm just returning a list of IDs but you get the point..
function getChildren(parentID)
{
$sql = "SELECT id FROM categories WHERE parentID='$parentID'";
// loop through results and for each one call:
$allChildren .= "$id,";
$allChildren .= getChildren($id);
return $allChildren;
}
$allChildren = getChildren("");
I'm not sure how fussy it is but you're using the wrong type of quotes - try using ` instead of '. It worked for me when I ran your query with those quotes replaced.
I think day of the month is date('d') - date('l') is day of the week. However this will be local to the server time not the users. I believe you have to use javascript to get the local time for the user.
var d = new Date()
var day = d.getDate();
?
Yes what corbin has suggested will do that. I'd do something like this to go around your delete statement:
// find out the number that this one was placed at
$sql = "SELECT sort_order FROM table WHERE id = {$_POST['id']}";
$result = mysql_query($sql);
$row = mysql_fetch_row($result);
// your original delete
$sql = "DELETE FROM table WHERE id = {$_POST['id']}";
$deleted = mysql_query($sql) or die(mysql_error());
// update remaining records
$sql = "UPDATE table SET sort_order=sort_order-1 WHERE sort_order > $row[0]";
$updated = mysql_query($sql);
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.