Jump to content

socratesone

Members
  • Posts

    33
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

socratesone's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. My guess is you're using it for some kind of pagination? You could try something like this: <?php $start = $_GET['start']; $rank = ( isset($start) && ( $start > 0 ) ) ? $start : 1; $limit_by = 'LIMIT ' . ($start - 1) . ', ' ($start + 20); $pageNum = 1; // loop through all possible pages for( $iStart = 1; $iStart > $max ; $iStart = $iStart + 20){ $class = ($iStart == $_GET['start'] ) ? 'class="active"' : ''; echo '<a href="results.php?start=' . iStart . '" ' . $class .'>' . $pageNum++ . '</a>'; } ?>
  2. I haven't tried this, but I suggest you do: mysql_query ("UPDATE liga1 SET puncte=($pctsteua + 3), m='1', v='1' WHERE echipa='Steaua' "); note - don't need quotes if puncte is an int, and mathematical expressions should be enclosed in parenthesis.
  3. "arial.ttf" is the file name of a font. In order to put a font in an image, you need to have the font file. A font file is like any other file. It doesn't have to be "arial.ttf". You can download lots of fonts on the internet. When this particular script is run, it is looking for a file named "arial.ttf", but you don't have that file, so it's throwing up all over itself. The script is scared, and doesn't know what to do, but you can help it. You can be the hero and give the script the font it needs. All you have to do is download a font and put it in the same directory as the script, so they can live together in harmony. BE CAREFUL, though! You might download a font that is not named "arial.ttf". In that case, you will need to EDIT the script. That means you have to open it up in your text editor and change "arial.ttf" to something else. However, I don't know what that is. You have to figure that one out on your own, but it shouldn't be too hard, because it will be whatever the name of the font is that you downloaded. For instance, if you download a font called "myAwesomeFont.ttf", you will have to edit the script and change "arial.ttf" to "myAwesomeFont.ttf". Please let me know if you have any questions. I know it can be tricky.
  4. // for simplicity (you can do some cleanup and checking here, too) $start = $_GET['start']; // the rank can be set using basic logic just once $rank = ( isset($start) && ( $start > 0 ) ) ? $start : 1; // This switch statement is really just here to show you what you can do besides a buch of if statements, // but my guess is there is a better way of doing this. // How, exactly, are you using these $active_x1_x2 variables, and why do you need them? switch($start){ case 1: $active_1_20 = 'active'; break; case 21: $active_21_40 = 'active'; break; case 41: $active_41_60 = 'active'; break; case 61: $active_61_80 = 'active'; break; } // the limit can be set using simple math $limit_by = 'LIMIT ' . ($start - 1) . ', ' ($start + 20);
  5. You can use whatever font you want. You just need to make sure the font file exists and the path and file name are correct.
  6. You have some options here. 1) Keep everything you have, but wrap it in a form and create a button, like this: ?> <form action="" method="post"> <?php echo $string; ?> <input type="submit" value="go" /> </form> ...and at the top of the page, add some logic to check the value, and, if present, forward off to the page <?php if(isset($_POST['selection']) && and !empty($_POST['selection'])}{ header("Location: http://www.example.com/" . $_POST['selection']); } ?> ....or.... 2) You can create links instead of a select box // get rid of this // $string='<select name=selection><option value=>modelo</option>'; // change this: // $string .='<option value="'.$row_array[1].'">'.$row_array[0]."</option>"; // to this: $string .= '<a href="'.$row_array[1].'">'.$row_array[0]."</a><br />"; // (you can also change this to any kind of format or wrapper for the <a> tag, such as wrapping them in <li> elements // get rid of this $string .='</SELECT>'; Hope that helps.
  7. Is this code supposed to use the $role variable as the key? '$role' => kry_encrypt_password($password)); If so, you're not going to get what you want. Instead, you're going to get the string litteral '$role' as the key, rather than the variable. If you want to use variables in the key, you must use double quotes rather than single quotes, ie: "members_$role" => kry_encrypt_password($password)); However, I think that you need to re-evaluate what you are doing here. You should probably NOT have multiple users with the same user name. You should probably have a group table that associates user ids with that group. Then, each user will log in with their own user name and their group identity will be in the database.
  8. You're attempting to re-order them in PHP or JavaScript? I'm guessing you're doing the reordering on the client side and storing it via ajax or form submission?
  9. Change this: $result=mysql_query($sql); to this: echo $sql; $result=mysql_query($sql) or die(mysql_error()); And post what you see.
  10. A quick way to do this is just to use a default value. I don't know if this is the behavior you want, though. <INPUT checked="checked" TYPE=RADIO NAME="otherdata" VALUE="Yes">YES<br/> <INPUT TYPE=RADIO NAME="otherdata" VALUE="No">NO<br/>
  11. This isn't the literal connection strings, I hope? mysql_connect("host", "userName", "password"); You are passing in the actual values, right? Not the strings "host", "userName", and "password"?
  12. A couple things: First, you want to alter the form to include the enctype: <form id="whatever" action="whatever" enctype="multipart/form-data" > Then, you want your file field in the form itself: <input type="file" name="image_file" /> Next, you may want to do some javascript validation to make sure it's the right file type. If you have a one-to-one relationship between post and image (one image per post), you will add the field to the database. Finally, you edit your form processing script to include the file upload: // set the path $path = 'path/to/save/filename.jpg'; // handle the upload move_uploaded_file($_FILES['image_file']['tmp_name'], $path) ; // enter into database mysql_query("UPDATE table set `image_path`= '$path'); Note that this is VERY simple, and is NOT meant to be a cut and paste solution. You will probably want to do more to validate server-side, check for existing files to avoid over-writing them, and more. A more in-depth discussion can be found here: http://www.webdeveloper.com/forum/showthread.php?t=101466 Hope that helps.
  13. You could check if the file exists before you call unlink. if(file_exists($picname)){ unlink($picname); }else{echo 'file not found';} if(file_exists("thumbs/".$picname)){ unlink("thumbs/".$picname); }else{echo 'thumb not found';} If you're getting the echo'd error message, make sure that the path is correct, as well.
  14. The easiest way to solve this was to ensure that relationship existed, so I add an addition to the rel table befor I even get here.
  15. I have three tables (not the actual table names): Voters: VoterId | numCandidatesVotedFor Candidates: CandidateId | numVotes VoterCandidateRel FKVoterId | FKCandidateId | numVotes The Voters table has the total number of Candidates that this voter has voted for The Candidates table has the total number of times this Candidate has been voted for The VoterCandidateRel table has the total number of times that a particular voter has voted for a particular Candidate What I would LIKE to be able to do (In MySQL v. 4.0.23) is to update all three tables in one fell swoop with on querie I can do this if the VoterCandidateRel table already has a record of an existing purchase with this query: UPDATE Voters, Candidates, VoterCandidateRel SET Voters.numCandidatesVotedFor=Voters.numCandidatesVotedFor+1, Candidates.numVotes=Candidates.numVotes+1, VoterCandidateRel.numVotes=VoterCandidateRel.numVotes+1 WHERE VoterCandidateRel.FKVoterId = Voters.VoterId AND VoterCandidateRel.FKCandidateId = Candidates.CandidateId AND Voters.VoterId=12345 AND Candidates.CandidateId=12345; However, If the relationship in the VoterCandidateRel doesn't exist, I get 0 rows effected. What I would like to be able to do is to UPDATE the VoterCandidateRel table if the relationship exists, and INSERT a new relationship if it doesn't yet exits, but I would like to be able to do it with a single query, if at all possible. I realize I can use PHP to check if the relationship exists, then do an UPDATE or INSERT after the fact, but that would mean that I would have to make three different queries: 1) To find out if the relationship exists 2) To update the Voters and Candidates Table, and 3) To conditionally insert or update the VoterCandidateRel table. I was wondering if there was any MySQL magic that I can do to do this all in one query, to avoid all the hits to the database.
×
×
  • Create New...

Important Information

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.