Jump to content

triphis

Members
  • Posts

    62
  • Joined

  • Last visited

    Never

Everything posted by triphis

  1. Lol sorry. I always get impatient @_@ But that is exactly what I needed! Thank you SO much
  2. Hi! This is what I have: a vote tabulation system that has ballots entered twice to ensure correctness. Then, if the program finds any discrepancies between the 1st or 2nd entries, it will force a third verification. We assume that the ballotID is always entered correctly, and it is used to drive this verification process. My table: Columns(id, ballotID, politicianID, choice, entry) [all are ints] Let us pretend that I am only tabulating 50 votes. There will be 50 rows with entry=1. 50 rows with entry=2. And then some smaller number (say 5) of entry=3. So, for 5 of those votes, there will be 3 rows with the same ballotID. For any ballotIDs that DO NOT have a entry=3 row, then entry=1 and entry=2 are EQUIVALENT. The entry=3 rows are the most correct, and trump their ballotID equivalents with entry=1 and entry=2. I now need to select a "full set" of ballots. Where possible choosing the entry=3 equivalent, and where not possible, either the 1st or 2nd entry (since they are the same). I regret that this is part of a group project and we are too far into development to change the tables and other setups now... so I ask that you limit your suggestions to how I can deal with this situation, assuming I can't change anything else. Thank you for any help you can offer
  3. It's good that you were able to figure it all out... but I'm wondering why you wanted to echo all of that in the first place? I love PHP because you can just... exit it whenever you want, and go back to writing HTML... and then use <?=$VARIABLE?> when you need to. I find that makes things so much easier
  4. Okay, You still didn't provide all the details I need (mysql table structure for example...) But, I'll try one more time Hopefully you can adjust it how you want. <form action="search_result.php" method="post"> <table width="100%" border="0" cellspacing="5" cellpadding="0"> <tr> <td width="25%"class="gensmall">Search by:</td> <td class="gensmall"> <input type="radio" name="searchType" value="username">Username <input type="radio" name="searchType" value="email">Email <input type="radio" name="searchType" value="state">State </td> </tr> <tr> <td> </td> <td ><input type="text" name="searchTerm" size="35" ></td> <td width="25%" ><input type="submit" name="search" class="submit" value="Search"></td> </tr> </table> </form> <?php if (isset($_POST['search'])) // They have just tried the search { $searchType = $_POST['searchType']; $searchTerm = $_POST['searchTerm']; switch($searchType) { case 'username': $sql = "SELECT user_name FROM members_info WHERE user_name='$searchTerm' break; case 'email': $sql = "SELECT user_name FROM members_info WHERE email='$searchTerm' break; case 'state': $sql = "SELECT user_name FROM members_info WHERE state='$searchTerm' break; } $res = mysql_query($sql); $num_results = mysql_num_rows($res); for ($i = 0; $i < $num_results; $i++) { $row = mysql_fetch_array($res); $user_name = htmlspecialchars( stripslashes($row["user_name"])); echo " <div class=\"friendtable\"> <table width=\"100%\" border=\"0\" cellspacing=\"0\"> <tr> <td class=\"image\"> <img src=\"http:// \"> </td> <td class=\"info\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"> <tr> <td class=\"name\">Name:</td> <td class=\"name\">$user_name</td> <td class=\"actions\"><a style=\"text-decoration:none;\" href=\"http://\">View Profile</a></td> </tr> <tr> <td class=\"label\"> Network: </td> <td> <a href=\" \">Lander '09</a><br /> </td> <td class=\"actions\"> <a style=\"text-decoration:none;\" href=\"http://\">Send Message</a> <a style=\"text-decoration:none;\" href=\"\">Poke Dolores!</a> <a style=\"text-decoration:none;\" href=\"http://\">View Friends</a> <a style=\"text-decoration:none;\" href=\"http://\">Add to Friends</a> </td> </tr> </table> </td> </tr> </table> </div>"; } } ?> I suggest not using "radio1" "radio2" etc for the names of your radio buttons... I hope what I have done makes sense. Depending on the user choice, the code i offered runs 3 different mysql queries... If you don't understand it, I suggest you look up SWITCH, and maybe other php tutorials because you might not understand all you need to. Also, be careful with the email search box... special characters can cause issues
  5. Okay then Won't this work? <?php $searchType = $_POST['searchType']; $searchTerm = $_POST['searchTerm']; $sql = "SELECT * FROM members_info WHERE user_name='$searchType' AND something = '$searchTerm'"; ?> If not, how about something like this: <?php $searchType = $_POST['searchType']; $searchTerm = $_POST['searchTerm']; switch($searchType) { case radio1: $sql = some query... break; case radio2: $sql = some different query... break; case radio3: $sql = some other different query... break; default: $sql = not NEEDED, but nice to have a backup } // carry on with your code ?> o.O; If that doesn't work, please provide a few more details, because I don't really know how anything is structured
  6. Hrm, I don't think I fully understand what you mean. And your code partially confuses me, because searchType is in a mysql query as username? That would imply you only have 3 usernames, litterally names "radio1", "radio2", and "radio3" What I think you might be trying to do is have 3 different queries, each searching something different, depending on what the radio selection is. Is this correct?
  7. I'm sorry, I checked all the forums and didn't know where to ask this @_@ I really wanted to ask on phpfreaks.com though because everyone here answers 1) fast, and 2) correctly So I'm ACTUALLY working on a Java assignment... but the language shouldn't matter here... UML should be the same for all OO languages right? I am just wondering, what do I put as the return type for constructors (in the method/3rd box of a class diagram)? Constructors technically "return" an object of type CLASS (whatever it is constructing for) right? So do I put... + thisConstructor() : CLASS or should it be VOID? **OR** do I not even include constructors in UML diagrams? Thanks so much to anyone who can help me out
  8. boo_lolly gave you all the code you need. first off, your pages should PROBABLY be .php not .html, unless your server parses PHP on .html extension pages.... then, use the code boo gave you right in front of the text, but after the link... if that if statement is true, it will change the font color. and you can add <b> there too. if that statement is false (ie, that page isnt the current page) the text will be displayed exactly as your CSS or page settings want
  9. See PHPexperts? This would be a good thing to help with *nudge*
  10. Actually, I rethought my answer, and I decided I don't like it haha. I wouldn't even go that far. This can have such a simple solution... Why have 3 submit buttons? Why not have ONE submit button, and just make use of 3 radio buttons, one for each action you want? <input type="radio" name="uploadwhere" value="pictures"> Pictures<br> <input type="radio" name="uploadwhere" value="school"> School<br> <input type="radio" name="uploadwhere" value="random"> Random<br> Then, one the process page, just use: $_GET['uploadwhere']; to find out which of the 3 was chosen, and build your if/switch statements around that I'm sorry, I'm not very good at giving exact answers with codes... I just explain how I would solve it. Hopefully you understand what I outlined above. If you want to wait a bit, I am sure another person will help you out here
  11. You would need to incorporate javascript, and have the form actions depend on the button pushed. the school submit button could have a onClick="submitSchool()" attribute, and so on. The javascript functions could make the browser submit the info to formprocess.php?type=school type=random type=pictures etc And then you could pull that variable from the URL and have your process.php page know which branch to upload to, based on that variable
  12. Should I be offering more information? lol I don't know what else I can tell you
  13. Hey everyone I have managed in the past to do simple image uploading and resizing... but now I want to extend one of my scripts to make a THUMBNAIL of the newly resized image. I am having trouble "capturing" the just-resized image and running it through the same process again. Hopefully someone here can help The code seen below is on a page that accepts image uploads as an array... Thanks in advance! foreach($_FILES['images']['tmp_name'] as $temp) { if($temp != NULL) { $result = mysql_query("SELECT * FROM pictures WHERE productcode = '$productcode'") or die(mysql_error()); $number = mysql_num_rows($result) + 1; if($number == 1) { $main = 1; } else { $main = 0; } $directory = '../uploads/'; $filename = $productcode . "_" . $number . ".jpg"; $newfile = $directory . $filename; $uploadedfile = $temp; $src = imagecreatefromjpeg($uploadedfile); list($width,$height)=getimagesize($uploadedfile); $newwidth=250; $newheight=304; $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); $justresized = imagejpeg($tmp,$newfile,100); // is this right??? $thumbdirectory = '../uploads/thumbs/'; $Tfilename = $productcode . "_" . $number . ".jpg"; // same name as before $Tnewfile = $thumbdirectory . $Tfilename; $uploadedfilethumb = $justresized; // I think this is where the problem is $srcthumb = imagecreatefromjpeg($uploadedfilethumb); list($Twidth,$Theight)=getimagesize($uploadedfilethumb); $Tnewwidth=100; $Tnewheight=100; $tmpthumb=imagecreatetruecolor($Tnewwidth,$Tnewheight); imagecopyresampled($tmpthumb,$srcthumb,0,0,0,0,$Tnewwidth,$Tnewheight,$Twidth,$Theight); if (imagejpeg($tmpthumb,$Tnewfile,100)) { echo "The image was uploaded, and the thumbnail was created!"; $entry = "INSERT INTO pictures(id,productcode,image,main) VALUES(NULL,'$productcode','$filename','$main')"; mysql_query($entry) or die(mysql_error()); imagedestroy($src); imagedestroy($tmp); } } } Also, if anyone can write a better confirmation-checker (ie: that both images were uploaded successfully) that would be great! Right now, the confirmation message is based only off the thumb... Which kinda makes sense since the thumb is created from the first one, but I think there must be a better way! Thanks again!
  14. you could save yourself some time by simply storing the times plainly (without all your formatting) like, just a timestamp... but then PULL IT OUT with the formatting. You would pull from your mysql table with: SELECT DATE_FORMAT('date_column','%Y-%M-%d') AS date.....
  15. Hrm, this would be risky..... it SOUNDS like you are planning on having an extensive DB... and with so many hotlinked images that you have NO control over.. what happens? What if someone stops hotlinking? or the site shuts down... I personally dislike people stealing MY bandwidth But anyway, the best thing to do is have a table column called URL or something, and just type manually the URL to the picture you wish to steal. There would be no way to just type the ISBN and have your script find the correct image to hotlink... Even amazon has their pictures named in a fashion that does not reflect ISBN. ----------------- in other words... what you expect to come from this is probably not possible. you would need to do a lot more work than just supplying the ISBN. perhaps save your pennies and try not to hotlink other's images?
  16. onLoad is normally associated with Javascript.... it wouldn't have any affect with a php file. what are you trying to achieve by this? If you want a function that exists within a php file to occur when a page is loaded, you should include that file with one of the methods that have been shown to you... and then manually call the required function(s) for what you need. ie: litterally type functionName() somewhere in your document after the inclusion...
  17. Um, works just fine for me... I mean, I get errors obviously, because I don't have those .txt docs.. but yeah: Warning: include(staticdoc2.txt) [function.include]: failed to open stream: No such file or directory in /home/zedthrea/public_html/store/index2.php on line 49 Warning: include() [function.include]: Failed opening 'staticdoc2.txt' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/zedthrea/public_html/store/index2.php on line 49 was what I got when I set OldPage=2 in my URL o.O; Try it again? lol
  18. That works just perfectly thank you! I guess what I learned here today is that everytime $otherItems = mysql_fetch_array($otherresult); is called, it advances to the next row, is that correct? I was thinking that no matter how many times you call that, it would fetch the exact same array that the original result came up with
  19. If you are going to have a TONNE of different animals (or whatever) you can use: $filename = ''; $c = ''; if(isset($_GET['c'])) { $c = $_GET['c']; $filename = $c . ".txt"; } because it is unreasonable to have a hundred different if statements. I didn't show the complete code... hopefully you can adapt if needed.
  20. $imgname (pulled from that cell in the DB table) if($imgname == NULL) // or whatever you set as default { echo "<img src='default.gif'>" /> } else { echo "<img src='uploads/<?=$imgname?>' />" } edit: When the form is submitted, you can check to see if they are uploading something or not, and then set the DB cell to whatever you decide Then check based on that.
  21. I guess I am having an understanding-block. I thought I could just ask one question and magically I would figure it all out haha. However, I now see that I need more help, so I will share my entire problem. Okay, so I am having a loop build the following table: The cyan cells are filled with content from the main loop, while the red cell is the "Feature Item" and pulled from a different query. The code for the table loop is: function showGrid($feature) { $featureresult = @mysql_query("SELECT * FROM matrix WHERE productcode = '$feature' LIMIT 1"); $featureItem = mysql_fetch_array($featureresult); $otherresult = @mysql_query("SELECT * FROM matrix WHERE productcode != '$feature' ORDER BY rand()"); $otherItems = mysql_fetch_array($otherresult); ?> <center> <table border="1"> <tr> <?php $upper=1; $int = 0; while($otherItems = mysql_fetch_array($otherresult)) /////// this is where the problem is!!! { if($upper==1) { if($int==2) { echo "<td rowspan='2' colspan='2' width='250' height='304' align='center'>" . $featureItem[brand] ."</td></tr><tr>"; $int++; } elseif($int==4) { echo "<td width='125' height='152' align='center'>" . $otherItems[brand] ."</td></tr>"; $upper=0; $int++; } else { echo "<td width='125' height='152' align='center'>" . $otherItems[brand] ."</td>"; $int++; } } else { if($int%4 == 1) { echo "<tr>"; } echo "<td width='125' height='152' align='center'>" . $otherItems[brand] ."</td>"; if($int%4 == 0) { echo "</tr>"; } } }?> </tr> </table> </center> <?php } //end function SHOWGRID Okay, so as you can see above, the table loop is BASED off the results from the OTHER (non-feature) items. However, if there are only 3 items on this page, 2 non-feature, 1 feature... the table will only create 2 cells (because it will never reach the third iteration of the loop). I would LIKE to convert that while statement to for($i=0; $i < $num; $i++) where $num = mysql_num_rows($otherresult) + 1; (to include the feature). So that is why I wanted to use the incremental approach for my array... Any better ideas? Thanks!
  22. hrm o.O; Couldn't you have your login page, submit to a login_check page... and if login successful, then: header("Location: whateverpage.php?user=" . $username); Headers have to be set before anything is printed on screen... And whatever.php page could be that person's own "page/database" whatever... you now have their username to make whatever DB queries you need to make
  23. Of course, I apologize for giving barely any info lol. Array ( [0] => 1 [id] => 1 [1] => jeantest [productcode] => jeantest [2] => True Religion [brand] => True Religion [3] => Micky Big T [style] => Micky Big T [4] => Denim [category] => Denim [5] => Wild Bill [colour] => Wild Bill [6] => 200 [cost] => 200 [7] => 300 [retail] => 300 [8] => 250 [sale] => 250 [9] => 0 [green] => 0 )
  24. Hello everyone I am trying to figure out how to access the array returned from this function using the incremental approach ($i)... however $array[column][$i] doesn't seem to work... it just returns the first letter of that column's entry. I can't use the standard while($row = mysql_fetch_array($result)) for what I am doing: say that loop runs 6 times. I am filling a table with 10 cells always - pulling the remaining cells from a completely different query. Right now, my table is being constructed with only 6 cells SO I want to have a FOR loop, and then use that $i to get what I need from both queries. Anyway, all I am looking for is a description of the array returned, and how to access each column, and each row using increments. Thanks!
×
×
  • 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.