PHP - Moved: Change Pointer On Mouse Over Table Element
This topic has been moved to CSS Help.
http://www.phpfreaks.com/forums/index.php?topic=350544.0 Similar TutorialsI'm entering my site via a sub folder, e.g. mysite.com/BeginHere (which triggers index.php in the BeginHere folder) and then including my main page which is in the root folder. I change the directory pointer with chdir( '../' ) so now I'm officially back in the root folder. This works fine - but the HTML still points to one directory down. Is there any way I can move this up one level as well? This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=347058.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=320488.0 So i've been wanting to expand my php horizons if you will and finally break of my fear of OOP. Here's a simple connection script i built, however i'm kind of stuck on a part of it. user passes username/password. i instantiate the mysqlcon class and call the connect function. the connect function attempts a connection to the database. if successful, pass on the username and password to the authenticator class. call the authenticate function. select user based on username/passwrod criteria. if found return "Confirmed" otherwise "Denied" here's my issue, i'm assuming that my Code: [Select] return $this->ok variable is returned back to the mysqlcon class. however how can i return that variable once more back outside of the object class so that i can continue with my script assuming authentication was confirmed. Here's my code... thanks for the help! <?php ## OOP PRACTICE ## class mysqlcon { function connect($user,$pass) { //Note: Connect to the database $db = mysql_connect("localhost", "usr","psw") or die(mysql_error()); if(mysql_select_db("database",$db) or die(mysql_error())) { $auth = new authenticator(); $auth->authenticate($user,$pass); } } } class authenticator { var $ok = "Confirmed"; var $ex = "Denied"; function authenticate($user,$pass) { //Note: User user and pass variables to check for user in table $qry = "SELECT * FROM users WHERE username = '$user' AND password = '$pass'"; $sql = mysql_query($qry) or die(mysql_error()); $cnt = mysql_num_rows($sql); if($cnt > 0) { return $this->ok; } else { return $this->ex; } } } $con = new mysqlcon(); $con->connect($_POST['username'],$_POST['password']); ?> PS: the classes are in class.php and the instantiation are in index.php. I just placed them together for easy of viewing. Is there a way to get the mysql's internal pointer position? I have searched Google, found this: Code: [Select] <?php function mysql_pointer_position($result_set) { $num_rows = mysql_num_rows($result_set); $i = 0; while($result = mysql_fetch_array($result_set)) { $i++; } $pointer_position = $num_rows - $i; //Return pointer to original position if($pointer_position <= $num_rows - 1) { mysql_data_seek($result_set, $pointer_position); } return $pointer_position; } ?> But I don't really like it. Is there a better way to find the current position of the internal pointer? I have a user table that holds email addresses and for testing purposes I am trying to replace every email address with an email address defined in an array. I would like to randomly choose an email address from the array and update the table with this address. When I run the following code it randomly chooses a email address from the array but then updates every row with this one email address. Can you someone please let me know what I am doing wrong. Thanks in advance. Code: [Select] $query = "SELECT * FROM user '"; $result = mysql_query($query); $input = array('email1', 'email2', 'email3', 'email4', 'email5', 'email6', 'email7'); $rand_keys = array_rand($input, 2); $replaceStr = $input[$rand_keys[0]]; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $rand_keys = ""; $rand_keys = array_rand($input, 2); $replaceStr = $input[$rand_keys[0]]; mysql_query("UPDATE user SET email = '$replaceStr'"); } This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=316053.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=351591.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=330989.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=317025.0 This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=346762.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=342929.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=342245.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=350095.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=319719.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=357414.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=305930.0 Is there a way to duplicate all rows in a table AND change one field's value for each new row?
For example...
TABLE: comments
FIELDS:
commentid
userid
comment
weeknumber
Say there are only 5 comments in there like this (I have MANY rows, but keeping sample size small for example's sake)...
1-17-hello-3
2-41-hey-3
3-18-yo-3
4-67-sup-3
5-12-hola-3
I would like to duplicate them AND make the "weeknumber" = 4, so the table ultimately has 10 rows like this...
1-17-hello-3
2-41-hey-3
3-18-yo-3
4-67-sup-3
5-12-hola-3
1-17-hello-4
2-41-hey-4
3-18-yo-4
4-67-sup-4
5-12-hola-4
Is this doable?
Thanks...
This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=349729.0 Hi, I've making a script that's almost a todo list, and i want to have 3 colors to the posts. Post under 7 days old should be green, and thoose older then 7 days yellow and over 14 days should be red. How could i do that? Every post i timestamp when stored in my MYSQL table. Here is my code: Code: [Select] <?php $servername='localhost'; $dbusername='root'; $dbpassword=''; $dbname='store'; connecttodb($servername,$dbname,$dbusername,$dbpassword); function connecttodb($servername,$dbname,$dbuser,$dbpassword) { global $link; $link=mysql_connect ("$servername","$dbuser","$dbpassword"); if(!$link){die("Could not connect to MySQL");} mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error()); } $result = mysql_query("SELECT * FROM henvendelser ORDER by id desc ") or die(mysql_error()); echo "<table cellspacing='12px' cellpaddomg='5px' align='center'>"; echo "<tr> <th>ID</th> <th> Opprettet </th> <th>Navn</th> <th>Telefon</th> <th>Emne</th> </tr>"; while($row = mysql_fetch_array( $result )) { echo "<tr> <td>"; echo $row['id']; echo "</td> <td>"; echo date("d.m.y", strtotime($row["date"])); echo "</td> <td>"; echo "<a href=\"detaljer.php?view=$row[id]\">$row[Navn]</a>"; echo "</td> <td>"; echo $row['Telefon']; echo "</td> <td>"; echo $row['Emne']; echo "</td> </tr>"; } echo "</table>"; ?> |