-
Posts
1,842 -
Joined
-
Last visited
Posts posted by marcus
-
-
The variable would represent authorization. If you're sexy, access denied, if I'm sexy, in this case I am, you're logged in with authorization.
-
Um, he was just showing us the layout of what he has.
-
session_start(); if($_SESSION['sexy'] == 'you'){ // redirect to login }else if($_SESSION['sexy'] == 'me'){ // logged in }
-
$x=1; echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n"; echo "<tr><td>\n"; foreach($this AS $that){ echo $that . "<br>\n"; if($x == '5'){ echo "</td><td>\n"; $x=0; } $x++; } echo "</td></tr></table>\n";
something like that.
-
Like I said before, they go inside the single quotes.
<?php /* */ // Define the webserver and path parameters // * DIR_FS_* = Filesystem directories (local/physical) // * DIR_WS_* = Webserver directories (virtual/URL) // add your database and website details to the variables below define('DB_SERVER_USERNAME', 'blahblah'); // your username that you use to log into your web server define('DB_SERVER_PASSWORD', 'blahblah'); // your password that you use to log into your web server define('DB_DATABASE', 'blahblah'); // your database define('DIR_FS_ADMIN', '/home/myusername/public_html/admin/'); // replace username with your web server username define('DIR_FS_CATALOG', '/home/myusername/public_html/'); define('DIR_FS_DOCUMENT_ROOT', '/home/sitename/public_html/'); define('SITE', 'www.sitename.net'); define('WWW', 'http://www.sitename.net'); define('HTTP_SERVER', 'http://www.sitename.net'); define('HTTP_CATALOG_SERVER', 'http://www.sitename.net'); define('DB_SERVER', 'localhost'); ?>
-
PHP and SQL, most likely.
-
Gotta show us code.
-
Method 2 is commented out.
-
$countfriends = mysql_query("SELECT count(*) AS total_friends FROM `friendslist` WHERE `FriendID` IN('{$_SESSION['Current_User']}','$UserID')") or die(mysql_error()); $rowfriends = mysql_fetch_assoc($countfriends);
-
<?php /* */ // Define the webserver and path parameters // * DIR_FS_* = Filesystem directories (local/physical) // * DIR_WS_* = Webserver directories (virtual/URL) // add your database and website details to the variables below define('DB_SERVER_USERNAME', ''); #blahblah // your username that you use to log into your web server define('DB_SERVER_PASSWORD', ''); #blahblah // your password that you use to log into your web server define('DB_DATABASE', ''); #blahblah // your database define('DIR_FS_ADMIN', '/home/username/public_html/admin/'); #blahblah // replace username with your web server username define('DIR_FS_CATALOG', '/home/username/public_html/'); #blahblah define('DIR_FS_DOCUMENT_ROOT', '/home/yoursite.com/public_html/'); #mysite.com define('SITE', 'www.yoursite.com'); #www.mysite.com define('WWW', 'http://www.yoursite.com'); #http://www.mysite.com define('HTTP_SERVER', 'http://www.yoursite.com'); #http://www.mysite.com define('HTTP_CATALOG_SERVER', 'http://www.yoursite.com'); #http://www.mysite.com define('DB_SERVER', 'localhost'); ?>
you replace the values INSIDE the quotes, not out side.
-
just do something
$query = "SELECT * FROM `subjects` WHERE `id`='{$subject_id}'";
-
You can easily modify this to fit what you need.
<?php $string ="id<br> name<br> title<br> album<br> year<br> id<br> name<br> title<br> album<br> year<br> id<br> name<br> title<br> album<br> year<br>"; $string = explode("<br>", $string); $x=1; foreach($string AS $alone){ echo $alone . " "; if($x == '5'){ echo "<br>\n"; $x=0; } $x++; } ?>
Of course, if it's a file. Just change the $string variable to
$string = file_get_contents('file.txt');
My results were:
id name title album year id name title album year id name title album year
-
<?php # connect to your database $sql = "SELECT * FROM `list_cats` ORDER BY id"; $res = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_assoc($res)){ echo "<div id=\"main_link\">{$row['name']}"; $sql2 = "SELECT * FROM `links` WHERE `cat`='{$row['id']}'"; $res2 = mysql_query($sql2) or die(mysql_error()); while($row2 = mysql_fetch_assoc($res2)){ echo "<div id=\"link\"><a href=\"/you/{$row2['link']}\"></div>\n"; } echo "</div>\n"; } ?>
easily modifiable.
-
This worked for me.
<?php if(!$_POST['submit']){ echo "<form method=\"post\" action=\"\">"; echo "First: <input type=\"text\" name=\"fname\"><br>\n"; echo "Last: <input type=\"text\" name=\"lname\"><br>\n"; echo "<input type=\"submit\" name=\"submit\" value=\"Go\">\n"; echo "</form>\n"; }else { $fname = trim($_POST['fname']); $lname = trim($_POST['lname']); if($fname && $lname){ echo "You have been added as " . $fname . " " . $lname; }else { echo "Missing one or two fields!"; } } ?>
-
You can use an IN statement.
$count = mysql_query("SELECT count(*) AS total_friends FROM `friendslist` WHERE `FriendID` IN('$your_id','$other_id')") or die(mysql_error()); $row = mysql_fetch_assoc($count); echo $row['total_friends'];
-
You can try this.
<?php $ary = array( "Today date is 1, our breakfast is 2 eggs and salad", "Today date is 13, our breakfast is 3 breads and beff", "Today date is 18, our breakfast is 2 toasts with egg", "Today date is 21, our breakfast is 5 wafels with honey", "Today date is 30, our breakfast is a bowl of sereal" ); $date = date("j"); foreach($ary AS $ara){ $ex = explode(" ", $ara); $ex = str_replace(",", NULL, $ex); if($ex[3] == $date){ $what = $ara; } } echo $what; ?>
tested to some extent.
-
Just do
$count = count(glob("/uploads/*")); echo $count;
-
Why do we need that information?
-
<?php $count = count(glob("/path/to/your/directory/*")); # keep the asterick. echo $count; ?>
-
The query is fine. Just add some protection to it.
<?php $fname = mysql_real_escape_string(trim($_POST['prov_f_name'])); $lname = mysql_real_escape_string(trim($_POST['prov_l_name'])); if($fname && $lname){ $sql = "INSERT INTO providers (`f_name`,`l_name`) VALUES('$fname','$lname');"; $res = mysql_query($sql) or die(mysql_error()); echo "You have been added as a provider successfully, " . $fname . " " . $lname; }else { echo "You did not supply a first name and/or last name!"; } ?>
-
Do a cron for every 45 days, lol.
-
$array = array('this','is','an','array','of','things','you','would','like','to','replace','with','null'); $string = "I like array's and things that you replace stuff with!"; foreach($array AS $boo){ $string = preg_replace("/$boo/is",NULL,$string); } echo $string; # should return # I 's d that stuff !
-
Don't limit his options, he wants what he wants
-
Ha.
$sql = "SELECT * FROM `users` WHERE `admin`='1' ORDER BY `name` DESC";
Select all users with admin equal to one, order by username.
how to make an admin panel?
in PHP Coding Help
Posted
You could have seriously made this a lot easier. If each page was, navigated by like:
index.php?page=this
And 'this' was an included file such as: includes/this.inc
Whilst being an admin, have an admin-only link on the bottom of the page that would say "Edit this Page," then you would be prompted with like.
admin.php?act=edit&page=this
Using fread and fwrite, you can easily have the person just edit the file as a whole.