Smudly 0 Light Poster

Hi, I am currently creating the template for a website I am working on. When I resize the window, the Links and the top right image move out of place. I need these to stay in place no matter what size the window is or what resolution is using. What am I doing wrong?

Here's my code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="description" content="Bed Bug & Dust Mite Services - Mattress Doctor">
<meta name="keywords" content="bed,bug,dust,mite,mattress,cleaning,service,doctor,saint,george,utah">
<meta name="author" content="Mattress Doctor - We clean mattresses to destroy and remove dust mites and bed bugs!">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title>Mattress Doctors</title>
<link rel="stylesheet" type="text/css" href="styles/style.css">
<style type="text/css">
#header{
	height: 130px;
	background:url(../img/header.gif);
	width: 100%;
}
#headleft{
	width: 40px;
	height: 130px;
	background:url(../img/header.gif);
	float: left;
}
#logo{
	width: 222px;
	height: 130px;
	text-align: center;
	position: relative;
	overflow: hidden;
}
#slogan{
	width: 602px;
	height: 130px;
	float: left;
}
#schedule{
	position: absolute;
	right: 0px;
	top: 20px;
	width: 200px;
	height: 130px;
	text-align: center;
	overflow: hidden;
}
#nav{
	position: absolute;
	top: 130px;
	width: 100%;
	height: 40px;
	background:url(../img/nav.gif);
	text-align: center;
}
#link{ 
	float: left;
}
#container{
	height: 600px;
	background:url(../img/bg.gif);
}
body{
	font-weight: bold;
	margin: 0px auto;
}
img{
	border: none;
}
</style>
</head>
<body bgcolor="#ffffff">

<!-- Header -->
<div id="header">
	<div id="headleft"></div>
	<div id="logo"><img src="img/logo.png" alt="Mattress Doctors"></div>
	<div id="slogan"></div>
	
	<div id="schedule">1-800-Bug-Free<br><a href="schedule.php"><img src="img/schedule.png" alt="Schedule Service"></a></div>
</div>

<!-- Nav -->
<div id="nav">
	<a href="home.php"><img src="img/home.gif"></a>
	<a href="problem.php"><img src="img/problem.gif"></a>
	<a href="solution.php"><img src="img/solution.gif"></a>
	<a href="process.php"><img src="img/process.gif"></a>
	<a href="faq.php"><img src="img/faq.gif"></a>
	<a href="contact.php"><img src="img/contact.gif"></a>
</div>

<!-- Content --> …
Smudly 0 Light Poster

When I upload new files, their file name is stored into my database. I have been told that a couple of the file downloads weren't working. Upon further investigation I figured out that the file the person wanted to download was nowhere to be seen in my downloads directory. How can I determine if a file exists in my directory? I assume I can somehow use the location that is stored inside my database (ex: myfile.pdf) and compare that with what's in the folder.

Smudly 0 Light Poster

Hi,

I'm trying to figure out the best way to determine if a user is currently downloading a file from my website.
The way my site works, is the user waits 30 seconds and views an ad. After the timer is up the download becomes available.
I heard that I could probably use a timestamp or something of the sort. I've read up on it but not sure how I could go about this.

Smudly 0 Light Poster

I'm not having any luck with this :( Could anyone provide an example?

Smudly 0 Light Poster

I have a search engine that searches through my sql table called `sheets`. Inside this table are the following columns:
id int(11) No
artist varchar(100) No
title varchar(100) No
url varchar(2083) No
timesdownloaded int(11) No
lastdownloaded date No
todaydownloads int(11) No
date date No
active varchar(3) No
duplicate int(1)

My search script searches for matches inside the Artist or Title columns.
However there is one problem.
Let's say I have 5 records (I will show the first three columns):
ID .. Artist .. Title
1 .. ABBA .. Super Trouper
2 .. Super Castlevania .. First Stage
3 .. Super Mario Brothers .. Underwater
4 .. Mario .. Theme
5 .. Super Junior .. Sorry, Sorry

So if I search for "Super Mario", right now it is displaying the following results (So right now it is searching phrases, rather than single words):
3 .. Super Mario Brothers .. Underwater

However, I need to modify my code so it will display the following results:
1 .. ABBA .. Super Trouper
2 .. Super Castlevania .. First Stage
3 .. Super Mario Brothers .. Underwater
4 .. Mario .. Theme
5 .. Super Junior .. Sorry, Sorry

Here is my full code, and any suggestions appreciated. I'll be working on it.

<?php
session_start();

include_once('inc/connect.php');

if (isset($_SESSION['username'])){
$loginstatus = "logout";
}
else{
$loginstatus = "login"; …
Smudly 0 Light Poster

My uploader allows the following file formats:

jpg
pdf
gif
png

I tested that if someone was to name a file configure.php.jpg, my uploader allows it to upload

I want to do a check to see if the user has 2 extensions, and if so it will not allow them to upload.

I was thinking of just checking if the file name has two "." (dots) in the name. What function could I use to do this?

Or .. is there a better way?

Smudly 0 Light Poster

Fixed. Thanks!

Smudly 0 Light Poster

Hi, I have created a missing.php file which the user is redirected to if the page they are trying to access does not exist. I use GoDaddy as a host and I set up the 404 error section so it redirects correctly. It works if the user tries to go to www.mysite.com/fakefile.html
This would redirect the user to missing.php

However, if they go down a directory, things start to get funky. Example:

www.mysite.com/directory/fakefile.html

This redirects to the missing.php, but any styling it had before is nowhere to be seen.

My missing.php is in my Root Directory. I tried making a duplicate and placing it in the sub folders and places ../ on any images, css files, etc.

Smudly 0 Light Poster

Hey thanks for the examples. I am looking through trying to understand. I currently have the code on a couple test files. When clicking the button, nothing happens. I created the sf.php file and types what you have above. You can see it here:
http://www.sheetmusichaven.com/testinterval.php

I'll keep working at it until you are able to reply. Thanks

Edit:

I noticed the Function name: function do(){
was not capitalized like it was in the input tag. I changed that but still not displaying "OK".

Smudly 0 Light Poster

How can I call a PHP Function inside a Javascript Function? This is what I have so far, but I don't think I'm doing it the right way.
Any suggestions?

<?php
function phpQuery(){

     $query = mysql_query("INSERT INTO mytable VALUES('','name','email')");

}
?>
<script type="text/javascript">
function delayQueries()
{
  timeoutID = window.setTimeout(doQueries, 2000);
}

function doQueries()
{
  var runQuery = "<?php phpQuery(); ?>";    
}
</script>
Smudly 0 Light Poster

Hi,

I have some queries that update some statistics in a table I have. I need these queries to run only after 15 seconds have passed however. This way if the user leaves before the 15 seconds, the queries won't run. I've tried using Sleep, however it seems to just stop all the code all together for the allotted time. There must be a way to do this. :)

Smudly 0 Light Poster

Hey thanks for all your effort.

1. The top section (the green area) that displays the timer is supposed to be that height, however, the bottom section that displays newgrounds.com is supposed to fill up the rest of the page. I am uncertain as to what is causing this.

2 & 3. I found that the error only happens after the file successfully downloads, and if the 'save file' window shows up after hitting download a second time, i hit cancel, and after clicking download again, that's when the code displayed to the page (all this in firefox).

4. I'm not sure how to manipulate my code to work for IE as well lol. I guess the users that aren't smart enough to use IE won't be able to download.

Smudly 0 Light Poster

Hi, I am having some major issues.
My site provides sheet music available for downloading for free. When a user clicks on a sheet to download, a new window opens up. This user views our sponsor's website for 30 seconds. Once the time is up, they can download the free sheet.

Now for the issues:

I found a download script that I'm putting to the test. When clicking download, it asks where you want to save the file and downloads the file just fine. After some testing, i found that if the user tries to download the sheet again, my entire php/html code displays on the page, as well as a bunch of nonreadable characters (I'm guessing this is from the .pdf file that is supposed to be downloaded).

I need to modify my code to stop this from happening. I've tried to exit() the code or die() after the sheet downloads, but I must be doing it wrong because nothing seems to work. I also tried a redirect to send them to a different page once they download the file. That doesn't work either.

The next issue is the bottom page is supposed to display our sponsor's website, which it does. However, the frame that contains the website is not 100% in height as it is specified to be. Something in my code is causing it to stop extending all the way.

If you would like to see exactly what is happening for …

Smudly 0 Light Poster

You have a phrase in the table, yet you want to list per word, is that correct ?

Yes, that is correct. I want to display the top 10 most searched words in order

Smudly 0 Light Poster

Hey, I have a search feature that searches for words in my database.
I am currently storing all searches that users make in a table called `search`. I need to list the top 10 words that are searched for the most, excluding common words like "the, and, or, etc".
Because the searches users make are stored into a table, it should be fairly easy.
Could anyone give an example of how to do this?

Here's how my sql table looks:

table name: search

columns:
id (autoincrement)
phrase
date
resultsfound
ip

Smudly 0 Light Poster

I ended up using this.

Thanks

$date = $row;
$dArray = explode("-", $date);
$newDate = $dArray[1]. "-" .$dArray[2] ."-". $dArray[0];

Smudly 0 Light Poster

Hey, I am grabbing a date from a row in my table which is currently formatted as:
date("Y-m-d")
2010-09-29

So in my code I have something like this:

$row;

How do I use this to rearrange the date to look like:

09-29-2010

I looked at the formatting tutorials, but they explain how to format it for the date you are currently setting into a variable.

Smudly 0 Light Poster

I have a form, that when the user click Submit, I need a php variable to be echoed to the page.
This is for an upload page. So when they are waiting for the file to upload, it will say "Uploading..." until the upload is complete.

All I know so far is I need to create a javascript function and include it in the submit button. This is all I have so far in the submit button tag:
onClick="Transferring();"

Now I need to figure out the code to include in this function.

Any ideas?

Smudly 0 Light Poster

Hey, i tried your code and edited the areas you specified. I'm not getting any errors, however, the results from the search are still the same.
I have a row that has the value Moulin Rouge, and another row that has the value Rogue.
If I type "Moulin Rouge" in the search field though, all that displays is Moulin Rouge. It's only when I type "Rouge", that both of these rows display.

Smudly 0 Light Poster

Hi, I'm having two issues with my Search engine for my website. It is created to search through my database (it doesn't crawl through pages). The first problem I'm having is when I type in for example:
Super Mario Bros
and there is a row in my table with a field called Super Mario Brothers
this row is not included as a successful result to the search. I need to somehow modify my code to search every word in every table cell in the database.

So another example. I have 5 rows, each with one cell, named as follows:
One
Two
Three
Four
Five
If I was to type in the search box:
One Two Three Four Five
it should display all rows (it obviously doesn't do that right now lol)

The second issue has to do with my sql query.
It looks like this:

$query = "select * from sheets where artist like \"%$trimmed%\" OR title like \"%$trimmed%\" 
  order by artist"; 
 $numresults=mysql_query($query);

I need this query to search in the columns artist and title (like it is doing above) AS WELL as search only those rows that have an active status set to 'yes'.
I tried to type something like:

$query = "select * from sheets where active='yes' && artist like \"%$trimmed%\" OR title like \"%$trimmed%\" 
  order by artist";

but this obviously causes problems. How do i require the query to include rows that …

Smudly 0 Light Poster

Hi, I'm trying to type in a name of a song into an input field, for example:
I'll Be Missing you

This field is captured through $_POST and set to a variable $title

I then update the table with this new title. Once it is updated, all that is shown in the data is:

I

The single quote, and anything after it is gone completely.
Here is my query. How can I change this so it includes the single quote and everything after it?

$sql = "UPDATE sheets SET artist = '$artist', title = '$title', active = '$activestatus' WHERE id = $value";
        $result = mysql_query($sql) or die(mysql_error().'<br>'.$sql);

If more code is required to understand what I'm talking about, let me know.

Smudly 0 Light Poster

I have a mysql table that looks like this:

id int(11) autoincrement
artist varchar(50)
title varchar(50)

I need to check for any rows that have the same titles.
So for example, if I had the following rows:

1 - Bob - Hello World
2 - Charlie Brown - Theme Song
3 - Joe - Hello World
4 - Joe - Is Cool
5 - Bob - Magic Dude

The query would display Row 1, and Row 3 as duplicates. Any idea how I can do something like this?

Smudly 0 Light Poster

thanks very much! All fixed

Smudly 0 Light Poster

Hi,

I'm working on a page that GETs a value that is passed in the URL. This variable echos correctly up until I try echoing it inside an if statment where it needs to be.

The variable is called $siteid. Inside my if statement I have a query that runs WHERE id='$siteid'

Inside this if statement it won't echo out. It is the weirdest thing. I tried to hardcode the siteid as 95, to test it, and the query updated my database as it should. However, leaving it as the variable it will not work. Any help solving this mystery that I've been banging my head over for hours would be greatly appreciated!

My variable echos correctly up until the line that says:
// $siteid will Echo up until here. After this point it stops working.

The query I am having issues with is after the line that says:
// Problem lies in this query.

My SQL Table:
id int(11) No
userid int(11) No
url varchar(2083) No
credits int(11) No 0
dailyviews int(11) No 0
todayviews int(11) No 0
totalviews int(11) No
active tinytext No
title varchar(50) No
confirmed tinytext No

And my code:

<?php
session_start();

if (isset($_SESSION['username'])){
$loginstatus = "logout";

$username = $_SESSION['username'];

include_once('inc/connect.php');

$siteid = $_GET['siteid'];
$message = "messagebox";
$success = "&nbsp;";
$error = "&nbsp;";

$useridquery = "SELECT id FROM users WHERE username='$username'";
$useridresult = mysql_query($useridquery);
$useridrow = mysql_fetch_assoc($useridresult); …
Smudly 0 Light Poster

Hi, I am having a pretty difficult time getting files to upload to my server that have a Single Quote in the file name.
Example:

myfile's.pdf

I need to strip the file name of the quote before it uploads to the server.
I currently am using SWFUpload and this is the bit of code that was included with it.

I need to modify it to remove the single quotes as well. Been hammering my head over this all day.

$file_name = preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
	if (strlen($file_name) == 0 || strlen($file_name) > $MAX_FILENAME_LENGTH) {
		HandleError("Invalid file name");
		exit(0);
	}

thanks

Smudly 0 Light Poster

Cool, thanks for the tip.

I added in a '#' before the string of 26 letters (ABCDEF ...)

Now I'm trying to get it to display and sort all artist's whose name begins with a number when clicking on '#'. What do I need to modify?

Smudly 0 Light Poster

Hi,

I have downloads that are available for users. They can click the links to download the file. Once they do this, I have a query that updates the number of downloads that file has received. I need to create a query that adds up all the rows Total Downloads.

So for example: i have 3 rows:
Name - Total Downloads
First - 2
Second - 23
Third - 7

Using the query for these rows would give me an amount of 32.

Any idea how to do this?

I don't want to have to create a new column to find the total number of downloads. Any other ways?

Smudly 0 Light Poster

Hi,

I have a page that lists the names of the Artists in one column, and the title of their song in the next column. I've included a sort section that allows users to view the artist (with the corresponding title) that starts with whatever letter they press. I've now come to a point where I need to add in a check for numbers.
(View attached image to understand what we're talking about)

So if the artist name starts with any number between 0-9, it will be shown in order on the page once a user clicks on "#". I've tried doing it various ways, but can't seem to get it just right.
Here is the code (I took out all my attempts to get the numeric sort working):

<?php
session_start();

include_once('inc/connect.php');


if (isset($_SESSION['username'])){
$loginstatus = "logout";
}
else{
$loginstatus = "login";
}
if(!isset($_SESSION['sort_counter']))
{$_SESSION['sort_counter'] = 1;}

if(($_SESSION['sort_counter']%2) == 0){ //test even value
  $sortcount = "DESC";
}else{ //odd value
  $sortcount = "";
}

$result = mysql_query("SELECT * FROM sheets ORDER BY artist");
$sheetscount = mysql_num_rows($result);
$sortletteris = $_GET['letter'];
$downloadclick = $_GET['downloadclick'];
$show = $_GET['show'];
$today = date("Y-m-d");

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="styles/style.css" />
</head>
<body bgcolor="#343331">

<!-- Header -->
<div id="header">
	<div id="headerleft"></div>
	<div id="headermiddle"><a href="index.php"><img src="img/logo.png"></a></div>
	<div id="headerright">
	
	</div>
	
</div>

<!-- Content Top -->
<div id="contenttop">
	<div id="links">
	
<!-- 92x30 -->
	</div>
</div>

<!-- Content Middle -->
<div …
Smudly 0 Light Poster

Hi,
I am creating an admin page that allows me to view requests for sheet music that is not currently on my website.
(View image to get an idea of what we're talking about).

On this page are 6 columns.
ID (autoincremented) This is the # the request is
Userid - the user's id
artist - the name of the artist the user requested
title - the name of the title the user requested
added - after I have manually added the sheet music to my site, i click added which will set the "added" column in my sql table to "yes". Also, once added is clicked, an email will be sent to the user that originally requested the sheet.
delete - This deletes the row in the sql database, and removes it from view on my page.
At the bottom of the page, there is also a button called "Added All", which goes through and sets the "added" status to "yes" for all rows on the page.

So, the problem I'm having right now, is emailing the user after I have selected Added. After I figure this out, I need to implement it into the "Added All" button, which will email all the corresponding users. Here is what I have come up with. Any input appreciated.
I'm not getting any errors at this point. I tested my variables and all are echoing out correctly.

The area …

Smudly 0 Light Poster

Hello,

I've created two form fields (username, password).
When a user comes to the page, the word "Username" is shown in the first form field. The word "Password" is shown in the second field. When a user clicks inside the field, the word inside the field erases automatically, allowing them to type in their username.

Everything above is working, except I'm running into some problems.

1st:
I need to figure out a way to include an if statement, that displays "Username" once again, if they did not type anything in the username field, and they clicked outside of the field. This will be the case for the Password field as well.

2nd:
If a user types in their username in the username field, then types in their password, but clicks on the Username field once again to fix a typo, it completely erases their username from the field, making them have to type it all again.

I've included my code below. Thanks!

Any help appreciated :) :banghead:

<script type="text/javascript">
function make_blank()
{
if(document.login.username.value ="Username"){
	document.login.username.value ="";
}
}
function make_blank1()
{
document.login.password.value ="";
}
</script>
<style>
.loginboxdiv
{
 margin:0;
 height:22px;
 width:102px;
 background:url(../img/loginbox.gif) no-repeat bottom;
}
.loginbox
{
 background:none;
 border:none;
 width:100px;
 height:20px;
 margin:0;
 padding: 2px 7px 0px 7px;
 font-family:Verdana, Arial, Helvetica, sans-serif;
 font-size:12px;
}
</style>
<form name="login" action="template.html" method="POST">
			<div class="loginboxdiv" id="username">
			<input type="text" class="loginbox" name="username" value="Username" onclick="make_blank();">
			</div>
			<div class="loginboxdiv" id="password">
			<input class="loginbox" name="password" type="text" value="Password" onclick="make_blank1();">
			</div>
			</form>
Smudly 0 Light Poster

Hi,
I'm currently creating my html/css template for my site.
I have the site split into 2 sections (Header, Content)
My Content area is also split into 3 sections. This is because I have sliced the image that will be the background of my content. The first section shows the top of the rounded box for the content. The Second shows the whitespace (Area that will show content). The third shows the bottom of the rounded box.

I need the middle content area to have a default height of about 500px. However, if the content requires over than 500px, it will automatically stretch to fit that page's needs.

Below is a picture of my content area. It currently is not stretching to fit all the text.

http://img530.imageshack.us/img530/1903/templatecontent.jpg

Here is my HTML. And below that is my stylesheet.

<html>
<head>
<title>Template</title>
<link rel="stylesheet" type="text/css" href="styles/style.css" />
</head>
<body bgcolor="#343331">

<!-- Header -->
<div id="header">
	<div id="headerleft">&nbsp;</div>
	<div id="headermiddle"><p><a href="index.php"><img src="img/logo.png"></a>&nbsp;</p></div>
	<div id="headerright">
	</div>
	
</div>

<!-- Content Top -->
<div id="contenttop">

</div>

<!-- Content Middle -->
<div id="contentmiddle">
	<div id="content">
Hello<br />
	</div>
</div>

<!-- Content Bottom -->
<div id="contentbottom">

</div>

</body>
</html>
#header{
	width: 912px;
	height: 78px;
	background:url(../img/bggreen_header.png) no-repeat;
	margin-left: auto;
	margin-right: auto;
}
#headerleft{
	width: 249px;
	height: 78px;
	text-align: center;
	float: left;
}
#headermiddle{
	width: 414px;
	height: 78px;
	text-align: center;
	float: left;
}
#headerright{
	width: 249px;
	height: 78px;
	text-align: center;
	float: left;
}

body{
	margin-top: 25px;
}
#contenttop{
	width: …
Smudly 0 Light Poster

Hi,
I'm creating an upload section that limits users to upload the following file types:

.pdf
.zip
.rar
.doc
.jpeg
.gif

When getting the type for .pdf files, it comes up as:
application/force-download

and for .rar files it comes up as:
application/x-download

If I do a check that says:

if ($type=="application/force-download" || $type=="application/x-download")

then will users only be able to upload .PDF and .RAR files? I'm assuming these two types will allow other formats as well.

If this is the case, how can I check the extension of the file before the user is able to upload it. I was thinking of somehow capturing the last 3 letters of the filename, and then doing the check that way, except I'm not sure how to go about this. Any insight appreciated!

Smudly 0 Light Poster

Hello, I've got a page that I've created that allows me to change multiple values in a row in my database. These values are all stored in a single row. I have input boxes for every one of the columns in my row. If a box is filled in, that value will be updated for that column in the row. This sounds like all I have to do is an Update query for the row, but it's becoming more complicated. Take a look:

<?php

include_once('../inc/admin.php');
include_once('../inc/connect.php');

$varsquery = mysql_query("SELECT * FROM vars WHERE id='2'");
$row = mysql_fetch_array($varsquery);

$varsquery1 = mysql_query("SELECT * FROM vars WHERE id='1'");
$row1 = mysql_fetch_array($varsquery1);

$edit = $_GET['edit'];
$newvalue = "";

echo "
<html>
<head>
<title>Variables</title>
<style>
a:link{
text-decoration: none;
color: #519904;
}
a:visited{
text-decoration: none;
color: #519904;
}
a:hover{
text-decoration: none;
color: #4296ce;
}
#border{
	border-right-style: solid;
	border-bottom-style: solid;
	border-width: 1px;
}
</style>
</head>
<body>
";

echo "<div style='font-size: 28px; text-align: center;'>Variables</div><br />
<table align='center'>
<tr>
<th bgcolor='#cccccc'><a href='changevars.php?sort=number'>#</a></th>
<th bgcolor='#cccccc'><a href='changevars.php?sort=variable'>Variable</a></th>
<th bgcolor='#cccccc'><a href='changevars.php?sort=value'>Value</a></th>
<th bgcolor='#cccccc'><a href='changevars.php?sort=rate'>Rate</a></th>
<th bgcolor='#cccccc'><a href='changevars.php'>Change</a></th>
<th bgcolor='#cccccc'><a href='changevars.php?sort=default'>Default</a></th>
</tr><form action='changevars.php' method='POST'>";

$i = 1;
$color = 0;
while ($i < mysql_num_fields($varsquery)) {
    $meta = mysql_fetch_field($varsquery, $i);
    if (!$meta) {
        echo "No information available<br />\n";
    }
	
	if ($color % 2){
	$bgcolor = "#cccccc";
	}
	else{
		$bgcolor = "#ffffff";
	}
	
		echo "<tr bgcolor='$bgcolor'><td align='center' width='20' bgcolor='#eeeeee' id='border'>$i</td>";
		echo "<td align='center' width='200' id='border'>$meta->name</td>";
		echo "<td align='center' width='200' id='border'>" .$row[$i]. "</td>";
		echo "<td align='center' width='100' id='border'>0</td>";
		echo "<td align='center' width='200' id='border'><input type='text' name='$meta->name'></td>";
		echo …
Smudly 0 Light Poster

I want to create a page that contains all sorts of Variables with values such as Prices, Name of Site, Rates, etc.

I want to create an admin page, that allows the admin to easily edit the values inside this php file. How does this work without the variables being reset to their default values everytime the page is reloaded.

I tried google but wasn't sure what exactly to search for. I'll take anything you can give me. A link to learn more about how to do something like this or even some tips & tricks.

Smudly 0 Light Poster

In my code, I loop through 3 random users, and I am trying to add 500 to their total number of credits. The variable $credits isn't being captured correctly, as it shows blank when I try to echo it. The odd part however, is $userid (primary key) is captured into the variable. What do I need to modify in my code to fix this issue?
Or, perhaps is there a way to just add 500 to the current total of credits by using the mysql update?

<?php

include_once('../inc/connect.php');

$date = date("Y-m-d");

$drawquery = mysql_query("SELECT id FROM userstats WHERE `todaysurfed`>=250 AND DATEDIFF(NOW(),`wondaily`) > 30 OR `wondaily`='0000-00-00' ORDER BY rand() LIMIT 3");

while($row = mysql_fetch_array($drawquery))
  {

$userid = $row['id'];
$credits = $row['credits'];
$addcredits = 500;
$newcredits = $credits + $addcredits;

echo $userid."<br />";

$updatewinners = mysql_query("UPDATE userstats SET wondaily='$date', credits='$newcredits' WHERE id='$userid'");

}

?>

Thanks

Smudly 0 Light Poster

I'm creating a page that calculates a number depending on what value is inputted into a text field. I need to create some javascript that updates this new calculated value and outputs it next to the input field. Anytime the user changes the number, it recalculates the value. My calculation is currently being produced by PHP, however if I need to, I can create javascript as well to recalculate these numbers.

My formulas for all 4 calculations are as follows:

First: Inputted Value * 10
Second: Inputted Value * 20
Third: Inputted Value / 2
Fourth: Inputted Value * 2

Here is my code I'm working with:

<?php
session_start();
$username = $_SESSION['username'];

include_once('inc/connect.php');

$credquery = mysql_query("SELECT * FROM userstats WHERE username='$username'");
$row = mysql_fetch_assoc($credquery);

$credits = $row['credits'];
$bannercredits = $row['bannercredits'];
$textcredits = $row['textcredits'];

$sitetobanner = $_POST['sitetobanner'];
$sitetotext = $_POST['sitetotext'];
$bannertotext = $_POST['bannertotext'];
$texttobanner = $_POST['texttobanner'];

if (isset($sitetobanner)){

$bannerimp = round($_POST['bannerimp']);
	if ($bannerimp > 1){
		$s = "s";
	}
	if ($bannerimp <= $credits){
		$newcredits = $credits - $bannerimp;
		$newbannercredits = $bannerimp * 10;
		$totalbannercredits = $bannercredits + $newbannercredits;
		
		$updatebanner = mysql_query("UPDATE userstats SET credits='$newcredits', bannercredits='$totalbannercredits' WHERE username='$username'");
		
		$credits = $row['credits'];
		$bannercredits = $row['bannercredits'];
		$textcredits = $row['textcredits'];

		$convertedbanner = "You converted ".$bannerimp." credit".$s." into ".$newbannercredits." banner impressions";
		
	}
	else{
	if ($credits>1){
	$mycredits = $credits - 1;}
	$errorbanner = number_format($mycredits, 0, '.', '');

	}

}


if (isset($sitetotext)){

$textimp = round($_POST['textimp']);
	if ($textimp > 1){
		$s = "s";
	}
	if ($textimp <= $credits){
		$newcredits = $credits - …
Smudly 0 Light Poster

I'm creating a daily drawing system. The users have a chance to win every day. Once a user wins, they will not be able to win again for 30 days. I need to select all rows inside my mysql database that have dates over 30 days ago, or are still set as default (0000-00-00). How can I do something like this?

I've tried a few different ways but none seem to work. Once these rows are selected, it randomly chooses 3 winners, and sets their new dates to the current date.

Current code:

<?php

include_once('../inc/connect.php');

$date = date("Y-m-d");

$drawquery = mysql_query("SELECT id FROM users ORDER BY rand() LIMIT 1");
$row = mysql_fetch_assoc($drawquery);

$wondaily = $row['wondaily'];

$userid = $row['id'];
echo $userid;

?>
Smudly 0 Light Poster

I'm planning to create a voting page, where users can vote on different ideas or suggestions. I think for my situation it will be best to use a Thumbs Up / Thumbs Down type voting system. Can anyone explain how these work? Do they use division, average, etc?

Thanks

Smudly 0 Light Poster

EDIT: The first problem is solved.

For the second problem (submitting user's new information), why are you using javascript? Can't I do the same thing with PHP. Also, could you please elaborate on how to create a script to do this that works with my current code? I've never done something like this before.

And the last problem I don't understand how to set it up, but it really isn't my priority compared to "submit".

Thanks!

Smudly 0 Light Poster

Having a few problems with my Admin Page that lists all registered users with some of their information.
I have a Delete button (which deletes the user permanently) and a Ban button (which bans user until I unban them). Both of these buttons have their own javascript that asks for a confirmation before going through with the request of banning or deleting a user. The confirm window show up correctly, with the option to click OK, or Cancel. When I click OK, it deletes or bans the user successfully, however if I hit cancel, it does not stop the script. It deletes or bans the user. That's the first problem.

The next:

At the end of the page I have a Submit button. So for example, I change any of the user's information on the current page, I can hit submit, and update all the user's information in the database. I am unsure how to set this up, because it needs to go through each row and update them one at a time as to not give all users the same updated value.

I also need to create a Dropdown Menu, or input field, which allows me to choose a number (50, 100, 300, 500, etc) of users to show per page. I have no idea how to go about doing this.

<?php
session_start();
include_once('../inc/connect.php');

if(!isset($_SESSION['sort_counter']))
{$_SESSION['sort_counter'] = 1;}

if(($_SESSION['sort_counter']%2) == 0){ //test even value
  $sortcount = "DESC";
}else{ //odd value
  $sortcount = "";
}

// …
Smudly 0 Light Poster

I am currently working on an admin only page that allows the admin to view all of the websites members. On this page, the admin can edit any of the information for the users (and change it in the database), delete the users, ban the users, and sort the users (depending on which link they press, it will sort it accordingly).

I've got the basic layout complete, however I have run into some dead ends.
First Issue:
I have the users information split into two different tables in my database. The first one "users" contains their basic information (name, username, email), while the second "userstats" contains their stats (credits, level, etc). Right now, when the page is loaded, it goes through the "users" table and displays each row exactly how it should. But I need it to do the same thing on these same rows for the other table. I'm not sure how I should change my While loop to get it to do this without causing problems.

Second Issue:
The sort feature allows the admin to sort through all the information by the username, id, email, etc. It works perfectly in an Ascending order, but I want it to go the opposite direction (Descending) once it is clicked again. I tried setting variables, and adding increment each time the link was clicked, and determining if the variable contained an even or odd number, but this didn't seem to work (The variable stayed at 1, …