Jump to content

php_tom

Members
  • Posts

    264
  • Joined

  • Last visited

    Never

Everything posted by php_tom

  1. Split the keyword string into a word array by using PHP's strtok() or explode(). Then like so: <?php // Say the words are in $keyword_array... $search_query = "WHERE ("; for($i=0;$i<count($keyword_array)-1;$i++) $search_query .= "'file_name' LIKE '%".$keyword_array[$i]."%' "; $search_query .= "'file_name' LIKE '%".$keyword_array[count($keyword_array)-1]."%')"; ?> Hope that helps. Note: The code in the post above is BAD for security!!!
  2. <?php $conn = @mysql_connect( "blaaah", "nlaaah", "andblaaah") or die ("could not connect to mysql"); #Connect to mysql $rs = @mysql_select_db( "site23_thewu", $conn ) or die ("Could not select database"); #select database $sql = "Select `user` FROM profile_quickfacts"; //pull the users from the table $result= @mysql_query($sql, $conn ) or die(" Could not add style facts"); echo "<table>"; // display the users in table $c = 0; while($row = mysql_fetch_array($result)) { $user2 = $row['user']; if($c%6 == 0) echo "<tr>"; // If the counter has ticked 6 times, start a new row. echo "<td><a href='ViewProfile.php?view=$user2'>$user2</a></td>"; echo "<br /><img src='DisplayPic_Tiny/".$row['user'].".jpg'/>"; // use the varaible row to display image DisplayPic_Tiny/user if($c%6 == 5) echo "</tr>"; // If we're drawing the 6th pic, end this row. $c++; } if($c%6 != 5) echo "</tr>"; // If there isn't a number of pics divisible by 6, end the row echo "</table>"; // end the table ?> Maybe this will help you.
  3. <?php $f = file_get_contents("http://www.phpfreaks.com"); // Now $f is a string with the whole webpage source in it (line breaks and all). if(strstr($f, "forums")) echo "Forums"; else echo "No forums"; ?> Hope that helps.
  4. You're right, sessions die when the browser is closed, besides you probably want to keep order info server-side not client-side. I would make a table 'ordered_items' with fields like order number, item number, quantity. Then say I am a customer and I buy (3 pairs of shoes), (1 toothbrush), (12 rubber duckies). You could insert into the database the following: | Order Number | Item Number | Quantity | 2973684 12348793 3 <-- The shoes 2973684 49378984 1 <-- The toothbrush 2973684 29837023 12 <-- The rubber duckies Then you can figure out how many rubber duckies have been ordered by doing SELECT SUM(Quantity) FROM ordered-items WHERE item_num=12348793 Hope that helps.
  5. Presumably you have an SQL table with columns "| Scan | Manufacturer | Description | Code | Part Number |", and you're fetching rows from the table and displaying them. What you want is a button at the top of each column that will sort it by that column. Try this: <table> <tr> <td> <a href='thispage.php?sortby=Scan&sortorder=up'><img src='uparrow.jpg'></a> <a href='thispage.php?sortby=Scan&sortorder=down'><img src='downarrow.jpg'></a> </td> <td> <a href='thispage.php?sortby=Manufacturer&sortorder=up'><img src='uparrow.jpg'></a> <a href='thispage.php?sortby=Manufacturer&sortorder=down'><img src='downarrow.jpg'></a> </td> <td> <a href='thispage.php?sortby=Description&sortorder=up'><img src='uparrow.jpg'></a> <a href='thispage.php?sortby=Description&sortorder=down'><img src='downarrow.jpg'></a> </td> <td> <a href='thispage.php?sortby=Code&sortorder=up'><img src='uparrow.jpg'></a> <a href='thispage.php?sortby=Code&sortorder=down'><img src='downarrow.jpg'></a> </td> <td> <a href='thispage.php?sortby=PartNumber&sortorder=up'><img src='uparrow.jpg'></a> <a href='thispage.php?sortby=PartNumber&sortorder=down'><img src='downarrow.jpg'></a> </td> </tr> <tr> <td><b>Scan</b></td> <td><b>Manufacturer</b></td> <td><b>Description</b></td> <td><b>Code</b></td> <td><b>Part Number</b></td> </tr> <?php // First do mysql_connect(), mysql_select_db() if($_GET['sortby'] != "") $column = " ORDER BY ".$_GET['sortby']; else $column = ""; if($_GET['sortorder'] == "up") $ordr = " ASC"; if($_GET['sortorder'] == "down") $ordr = " DESC"; else $order = ""; $res = mysql_query("SELECT * FROM parts".$column.$order); while($row = mysql_fetch_row($res)) { for($i=0;$i<count($row);$i++) { echo "<td>".$row[$i]."</td>"; } } ?> </tr> </table> Hope that helps you. Post back if anything is unclear.
  6. You mean something lie the car in this link? http://homepage.ntlworld.com/bobosola/pngtestfixed.htm Please explain more.
  7. It should, or just disallow these chars (maybe others too): " ' ; ( ) [ ] < > and maybe the word javascript (although what if my web site is www.javascriptgod.com or something). HTMLentities is probably easier.
  8. MadTechie: I would not do this, it opens you up to all kinds of SQL hacks. E.g., mysite.com\page.php?sort=stuff&order=ASC; DROP TABLE stuff; -- Instead, make the link one of <a href=mysite.com\page.php?sort=stuff&order=up <a href=mysite.com\page.php?sort=stuff&order=down Then in PHP: if($_GET['order'] == "up") SELECT * FROM TABLE ORDER BY stuff ASC elseif($_GET['order'] == "down") SELECT * FROM TABLE ORDER BY stuff DESC else die("Invalid parameter error!"); I think this is much more secure.
  9. Just test like so: if($_GET['update'] == "success") // Do success stuff here. else // Assume it failed! Print error message or whatever. Or if you want to be funny: if($_GET['update'] == "success") // Do success stuff here. elseif($_GET['update'] == "failure") // It failed! Print error message or whatever. else echo "Stop hacking! Your IP ".$_SERVER['REMOTE_ADDR']." has been logged."; Hehehe... (1 @/\/\ teh 1337 hax0r!)
  10. Sure, make each arrow a link, so if someone clicks the down arrow over Code, it goes to index.php?sort=Code&order=desc Then when you do the SQL query, just slap in a "ORDER BY Code ASC" as figured out from the $_GET[] global. Hope that helps.
  11. If you have SQL available on the server you use, that would be easiest. Make a TABLE books with whatever id values you think will be useful, for example (Title, Author, Description, ISBNnum, ImageURL, Category, BookID) Then use SQL queries to narrow down the items you display to the user. For example, SELECT * FROM books WHERE Category='Horror' or whatever. Let us know if you can use SQL or if you need to do it with text-file databases.
  12. 1) center align the entire page (instead of left aligning it) 2a) Pick a better font for the navigation menu, the one there is boring. 2b) Make the entire box a link instead of just the text itself (in the navigation area) 3a) Fix (on the support page) 3b) Fix (on the order page) 4) Let people pay you with credit cards, it will look more professional than PayPal 5) In the bottom left, fix © as it shows up in firefox (this should just be ©) 6) On the privacy policy page the text runs over the height limit you've set. Pick a smaller font, or make it shorter, or split it into two pages, or something. 7) The tiny little scrollong horizontal bar to the right of the page is VERY annoying, and why don't you want the link to your band a bit bigger/less obnoxious? ???
  13. Are you trying to do something like this? http://www.javascriptkit.com/script/script2/imagezoom.shtml# or if you want it done nicer in flash: http://www.hotscripts.com/Detailed/49338.html (click 'download -- its a zip)
  14. Hey, I'm thinking that since you are using a square map, here's an algorithm that might work: 1) You start somewhere, say, (x_i, y_i). 2) You have at most four possible moves; (x_i+1, y_i), (x_i, y_i+1), (x_i-1, y_i), (x_i, y_i-1), or maybe less if the grid is sparse. 3) For each of these four points, calculate the linear distance between it and the destination (using pythagorean theorem) -- abs(x_i - x_f)^2 + abs(y_i - y_f)^2 = d^2. 4) Pick the point with the smallest resulting linear distance. 5) If two or more points have the same linear distance, repeat the algorithm for each point and go with the smallest resulting distance (this could probably be done with a recursive function). The above algorithm will hang... if your map has something like |-|-|-|-|-|-| |-|-|-|-|-|O|-|-|-| |-|-|X|-|-| |-|-|-|-|-|-|-|-| |-|-|-|-| |-|-|-|-|-|-|-| |-|-|-|-|-| |-|-|-|-|-|-|-|-| |-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-| (I hope this comes out.) where X is the beginning and O is the destination... maybe you can add a piece of code that checks if the algorithm is stuck in a corner or whatever (by checking if each possible move takes you FARTHER away from the destination), then starts over again but throws away that path as a possibility. Have fun coding this! I know I would...
  15. If you find one, you can probably get at least a masters degree at your pick of Ivy League graduate schools . (I.e., probably not easy to come up with a better solution). Are you implementing a game? If you're trying to figure out the optimal path for scoring, maybe it's easier to come up with a better scoring scheme... it's just an idea.
  16. not sure if this would help you: <form action='process.php' method='post'> <input type='hidden' id='hidddenElement1' name='theHeights' /> <input type='submit' value='Submit!' /> </form> <script type='text/javascript'> var str = ""; var images = Array("someImage1","someImage2","someImage3","someImage4","someImage5"); for(i=0;i<4;i++) { str += images[i] + "=" + document.getElementById(images[i]).height + "&"; } str += images[4] + "=" + document.getElementById(images[4]).height; document.getElementById("hiddenElement1").value = str; </script> Then in 'process.php': <?php parse_str($_POST['theHeights']); ?> Obviously the code abouve isn't complete, but is it approximately what you're looking for? Hope it helps.
  17. How big is your map going to be? If it's reasonably small (maybe a 10 x 10 grid or so), you could just try all possible paths, tally their lengths, and pick the shortest one. But for a big map this is unfeasible, you would need graph theory and stuff. I only know a bit about this... check out the links below: http://en.wikipedia.org/wiki/Graph_theory http://en.wikipedia.org/wiki/Shortest_path_problem http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm Please post back with details of what exactly you're trying to do.
  18. You could just put a PHP file 'index.php' with the following code: <?php // Redirect them to your site's main page header("Location: http://www.mydomain.com/"); ?> Of course, if someone knows the name of a file in the directory, they can just type it in, but if the script performs a sensitive task (uploading files, displaying sensitive info, etc.), you should probably be using sessions or something to stop unauthorized access anyway... For example when I do the admin part of a website, either I just password the directory with all the admin scripts, or I do a login script w/ sessions to prevent BAD stuff...
  19. use PHP's isset(), or test $asdf == NULL
  20. What the H.E. double hockey-sticks?? RPF!?!?! OK, weeeeiiiiiirdd site. Anyway did you implement the whole site or just the 'easy read' feature (which I don't know about others, but I thought was more like an 'impossible read' feature -- WAY to much whitespace)? In other words which part are we testing for errors?
  21. The problem is in AC_RunActiveContent.js. The function you're calling, AC_FL_RunContent(), calls the function AC_GetArgs(), with a parameter arguments, which is nowhere defined. The JavaScript engine interprets arguments to be null, then the scripts pukes when you call var currArg = args.toLowerCase() on a null string. To fix it, you need to define the variable arguments somewhere.
  22. Try: <?php $f = fopen("data.txt", "r"); echo "<select name='fruits'>"; while($line = fgets($f)) echo "<option value='$line'>$line</option>"; echo "</select>"; fclose($f); ?> Hope that helps. [edit] Hehe... mine is shorter than the below post
  23. hehe... no they didn't. I registered as "<marquee>hacked!" which it let me do, but I guess it stripped tags before printing on the screen. My thought was simply this: why would I upuload mp3s to a website and then listen to them, when I could just listen to them on my own computer? Is it a song 'sharing' service, or what?
×
×
  • 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.