-
Posts
760 -
Joined
-
Last visited
Posts posted by joel24
-
-
you can do it all in mysql, without PHP. also you don't need between... now is the max time, so use greater than
$query_users = mysql_query("SELECT userid FROM *table* WHERE datetime > NOW() - INTERVAL 5 MINUTE");
-
in the array
[1] => Admin
[2] => User
is 1 the admin user_type_id?
if so..
you'd have somthing like this
$sql = @mysql_query("SELECT * FROM user_types"); while ($r = mysql_fetch_array($sql)) { $userTypes[$r['user_type_id']] = $r['user_types']; }
then you'd have an array with
$userTypes[1] = "Admin"
$userTypes[2] = "User" etc
-
DELETE FROM *table* WHERE id BETWEEN 0 AND 101
-
it would be similar to your "delete reply" setup.
except you'd delete the topic id
then delete all the replies in alabama_forum_replies that are assigned to that topic id.
or is your delete reply code not working and you want help with that?
-
can you show me the code of both pages?
-
are you passing the $psrn with a session or through the URL?
i.e.
header ('Location: http://localhost/bitssap/success.php?psrn=' .$psrn);
then on the success page
$psrn = $_GET['psrn'];
-
the "get directions" link works fine for me in firefox 3.5
-
you'd have to have a function in that class like
function returnUserName() { return $this->username; }
then call that objects function.. i.e. if the object was $user1
class MyApp { function __construct() { global $dbHost; global $dbUser; global $dbPass; global $dbName; $this->DB = new Database; $this->DB->connect($dbHost, $dbUser, $dbPass, $dbName); $user = new User; $username = $user->returnUserName(); echo $User->login; echo $this->User->login; } }
-
this *should* work...
$start_num = ($page->page_num * $advert->per_page) - ($advert->per_page - 1); $end_num = $start_num + $advert->per_page; if($end_num > $all) $end_num = $all; $showing = "$start_num - $end_num of $all";
-
with prepend it would just add the last entry when it was being sent to the database, you can also do it another way... which might be easier...
you can create a PHP page which calls that create_output function and displays it on an otherwise blank page.
like
updateGuestBook.php
then on the page the guestbook entries would be listed in a div with id guestBookEntries
$("#guestbook_submit").click(function(){ //get the id //the_id = $(this).attr('id'); $(".postmsg").fadeOut(50); // show the spinner $('.postmsg').append('<img src="images/loader.gif" alt="Loading" />'); //the main ajax request var dataString = $("#guestbook_form").serialize(); $.ajax({ type: "POST", data: dataString, url: "add_post.php", timeout: 2000, cache: false, success: function(msg) { $("#loading").remove(); $(".postmsg").fadeIn(400); $(".postmsg").html(msg); setTimeout("$('.postmsg').fadeOut();",2000); $.post("updateGuestBook.php", function(data) { if (data.length > 0) { $('#guestBookEntries').html(data); } else { $('#guestBookEntries').html("<div align='center'>Error retrieving item details</div>"); } }); } }); return false; });
that code will call the updateGuestBook.php file and get the HTML of the page and put it into the #guestBookEntries div
also the line
setTimeout("$('.postmsg').fadeOut();",2000);
should make the .postmsg div fade out after 2seconds... before it was set to 60000 (60secs)
-
there's a bit of scripting involved, have you played around with jquery?
it'd depend on how you have your guestbook layed out.
but
pretty much you write the html and insert it at the top of the div containing the guest book entries...
but pull the values using jquery... then put them in there..
i.e. the jquery would be like
$("#guestbook_submit").click(function(){ //get the id //the_id = $(this).attr('id'); $(".postmsg").fadeOut(50); // show the spinner $('.postmsg').append('<img src="images/loader.gif" alt="Loading" />'); //the main ajax request var dataString = $("#guestbook_form").serialize(); $.ajax({ type: "POST", data: dataString, url: "add_post.php", timeout: 2000, cache: false, success: function(msg) { $("#loading").remove(); $(".postmsg").fadeIn(400); $(".postmsg").html(msg); setTimeout("$('.postmsg').fadeOut();",2000); $("#guestbookEntries").prepend("<b>Entry Number: whatever, etc etc</b><div>rarara</div>"); } }); return false; });
<div id="guestbookEntries">
<!-- other entries -->
</div>
check out
-
-
you have to put it inside the class which has the $string1 - 10 variables.
then to call it you need to create an object
i.e.
$object1 = new test1(constructor details);
then you can use
$array = $object1->shareStrings();
which will put the strings into $array.
read up on it.
-
do you want it to just show the new post?
or all the posts?
you'll either have to make it refresh the page, or append the new post to the top of the others...
-
you'd have to write a function which shares those variables.
public function shareStrings() { $strings = array($this->string1, $this->string2, $this->string3.... $this->string10); return $strings; }
-
i think its because of the scope of a function.
i.e.
function get_name(){ $name = "Jimmy Goe" echo $this->name; }
$name within the function and $name in the class are two separate variables, because the scope of a variable within a function is local..
try
function get_name(){ $this->name = "Jimmy Goe" echo $this->name; }
-
you've got a problem with your jquery/ajax.
the data isn't being sent properly...
use the serialize() function to put the form element into a readable state for the php...
you have the give the guestbook form an id.
i.e.
<form class="guestbook_form" action="add_post.php" method="post"> <label>Nickname:</label> <?php db_connect(); if(!$_SESSION['user']['username']) { $username = "Anonymous"; echo '<input type="text" readonly="readonly" name="guestbook_name" class="guestbook_name" value="'.$username.'" />'; } else { $username = $_SESSION['user']['username']; echo '<select name="guestbook_name" class="guestbook_name" id="guestbook_name"> <option value="'. $username .'">'. $username .'</option> <option value="Anonymous">Anonymous</option> </select>'; } $query = "SELECT * FROM `categories`"; $results = mysql_query($query); echo '<select name="category" class="category" id="guestbook_category">'; while ($row = mysql_fetch_array($results)) { $catid = $row['cat_id']; $catname = $row['category']; echo '<option value="'.$catid.'">'.$catname.'</option>'; } echo "</select>"; ?> <p class="label"> <label>Message:</label><textarea cols="50" rows="10" name="guestbook_message" id="guestbook_message"></textarea> </p> <p class="label"> <label></label> <span class="postmsg"> </span> </p> <p class="submit"> <button type="submit" class="submit" value="Submit" id="guestbook_submit" name="guestbook_submit">Submit</button> <button type="submit" class="close">Cancel</button> </p> </form>
then change the jquery to the following
$("#guestbook_submit").click(function(){ //get the id //the_id = $(this).attr('id'); $(".postmsg").fadeOut(50); // show the spinner $('.postmsg').append('<img src="images/loader.gif" alt="Loading" />'); //the main ajax request var dataString = $("#guestbook_form").serialize(); $.ajax({ type: "POST", data: dataString, url: "add_post.php", timeout: 2000, cache: false, success: function(msg) { $("#loading").remove(); $(".postmsg").fadeIn(400); $(".postmsg").html(msg); setTimeout("$('.postmsg').fadeOut();",60000); } }); return false; });
-
for the price use BETWEEN
i.e.
you'd have priceMin and priceMax on the form.
$priceMin = isset($_GET['priceMin']) ? $_GET['priceMin'] : 0; if (isset($_GET['priceMax'])) { $types[] = isset($_GET['price'])?"`price` BETWEEN $priceMin AND $priceMax":''; } else { $types[] = isset($_GET['price'])?"`price` >= $priceMin":''; }
is the script working at present?!
I don't get exactly what you want us to do...?
-
then you can use the mysql event feature if your using mysql 5.1.6 or greater
http://dev.mysql.com/tech-resources/articles/event-feature.html
or you can set up a cronjob which will run a script automatically at 12.01am every morning...
-
... do you want it removed when something in the database is updated? or when a page is viewed? or automatically at 12:01am?
-
you'd have a database with columns song_id, day_start, day_hits, week_start, week_hits, total_hits
then run a script like the following for each time the song page is viewed...
$song_id = 'the song id'; $sql = @mysql_query("SELECT * FROM song_hits WHERE song_id = $song_id"); $song_hits = mysql_fetch_row($sql); if ($song_hits['day_start'] == date('z')) { $sql_day = ' day_hits = ' . $song_hits['day_hits']++ . ', '; } else { $sql_day = ' day_start = ' . date('z') . ', day_hits = ' . $song_hits['day_hits']++ . ', '; } if ($song_hits['week_start'] == date('W')) { $sql_week = ' week_hits = ' . $song_hits['week_hits']++ . ', '; } else { $sql_week = ' week_start = ' . date('W') . ', week_hits = ' . $song_hits['week_hits']++ . ', '; } $sql_total = ' total_hits = ' $song_hits['total_hits']++; $sql = @mysql_query("UPDATE song_hits SET $sql_day $sql_week $sql_total WHERE song_id = $song_id");
-
noo i meant so the automatically added gold was never stored in the database...
instead only acquired gold was stored in there... and then each time the user interacted with someone or someone viewed their gold it would add the amount in teh database + (current unix timestamp - account creation timestamp) / 60
i.e. if they might have -400 gold in the database however since they've been a member so long they actually have 10000 gold.
i guess then there's issues if you want to select the person with the most gold from the database etc etc...
other way is to write a script which runs each time the user is interacted with... and after it puts in gold it adds the current unix timestamp to the database, so next time someone interacts with the user it adds the amount of gold accumulated since the previous interaction...?
-
andy is on the right path,
you could have someones gold stores what is in the database plus the amount automatically given to them since their account creation
i.e. have a unix timestamp of their creation, then each time someone interacts with that user they work out the amount of gold that user has
which would be
(current unix timestamp - account creation timestamp) / 60 (for minutes).
then add that to the amount in the database, which is not inclusive of any automatically given gold... and could be a negative or positive number...
so when someone stole gold or wanted to see how much gold a person had
$sql = @mysql_query("SELECT accountCreation, gold FROM users WHERE userid = xx"); $results = mysql_fetch_row($sql); //amount of gold in users account $gold = (time() - $results['accountCreation']) / 60 + $results['gold'];
either that or you can have it so each time a user logs on or a user interacts with another user, a script runs which updates the amount of gold in their account...
-
if the strings coming from a textbox etc play around with the nl2br function.
php if else statement and less than brilliant formatting
in PHP Coding Help
Posted
whats the error / conflict?