-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
If you don't have a database, you're going to have to use a flatfile, or make a really long array of usernames and have that array included on all your pages. You're basically going to take the content where a name may appear, and make a loop, looping through each name, and do some regex to search for that name and replace it with anchor tag wrapped around it. -make a list using a file/array (since no db) -make a loop -use regex to find and replace in the content. there's your battleplan. If you get stuck on some code, post it and we'll try to help.
-
well basically you would first run a basic query using the id like "select status from table where id = '$id'" then do a condition based on that. assuming you retrieve it and put the status in $status: if ($status == 'active') { // it's valid, do your code here } else { // it's not valid. do something here. Log it, throw out an error, w/e }
-
well I don't really know a whole lot of js myself, but I think if you assign an id or name to an element, you can use js to onclick, add content to that element block (your extra input field for your form). As far as letting php know that there's a new input element in your form..I think the most efficient method for that is to use an array as your name in your input element. Example: <script = 'javascript'> function addanotherelement () { <!-- js code here --> } </script> <form id='myform' name = 'myform' action = 'target.php' method = 'post'> <input type = 'text' name = 'blah[]'><br /> <button onclick='addanotherelement();'>add another</button> <input type = 'submit' value = 'submit'> </form> The key there is name = 'blah[]' makes an array. Each time you add a new input element to your form, it will simply say name = 'blah[]' and when the form is submitted, all of the information can be accessed by $_POST['blah'][0] // first text field $_POST['blah'][1] // 2nd text field etc... Obviously that is not how to really code the javascript. I'm going to move your thread to the javascript section so someone can help you on that part....
-
okay well then yes, go for some ajax. Virtually every beginner ajax tutorial shows you how to do what you wanna do, so doing a "ajax tutorial" google search will yield lots of results.
-
an example of this would be: index.php <form action = 'test.php' method='post'> <input type="text" name="wall"> <input type="submit" value="Post Comment!"> </form> test.php <?php if ($_POST['wall']) { echo $_POST['wall']; } ?> Yes, you can use ajax to make a request and update an element on the page without refreshing the whole page.
-
if you want php to know what the user put in the form, a request has to be sent to the server, via the get or post method, and it would be accessed via the get or post array. That's your only option with php.
-
use $_POST['wall'] instead of $wall
-
What you are wanting to do is a very basic ajax method. Virtually all beginner ajax tutorials explain how to do what you are wanting to do. To be honest though, you don't really need to do ajax. All you're wanting to do is add an extra element to your form... just do it with javascript. The point to ajax is needing to get more information from the server without refreshing the page. This is useful for instance with multiple dropdown selections, where dropdown #2 data is based on dropdown #1 selection sort of thing. But you're just wanting to add a basic form element. No need to bother the server for that. Just use a javascript onclick call.
-
If you want to do this only with php, you're going to have to have page reloads. You can use a session variable for data persistence. Your other options include using a clientside language like javascript, or a mix between php and javascript, using ajax. ^ ajax still involves sending requests to the server, just not a full page reload. edit: Only thing you got to consider though is that using javascript or ajax can cripple your site, as people can turn it off. If you wish to go that route, I suggest first doing it the strict php method and then doing it the js or ajax method on top of that, so that your script has something to fall back on if js is disabled.
-
can't you just go into your norton program and make your site an exception to it's rule?
-
Populate A Drop Down Box With Values From Database!
.josh replied to murtz's topic in PHP Coding Help
if everything works when you hardcode it but not when you use the variable, then the problem is the variable. Did you name your input 'dropdownbox' (spelled right?) in your form? did you use method = 'post' in your form tag? -
After making sure the id value is the correct format (if using integers, check to make sure it's an integer, use mysql_real_escape_string on the variable, etc...), since you are expecting to only show/alter/whatever active clients, do a query check on the passed variable to see if that client is active. If not, then kick an error message or whatever.
-
okay, so what are you intentions here? You want a user to enter in something in a form, then take that value, search your database for it, and return a thumbs up if it finds it, thumbs down, if not?
-
unless your doSelectAndGetRow is taking your post array and selecting info based on it and returning results into the same post array...which I don't really see why it would be (I'm not psychic, but honestly I've never seen anybody do something like that, lol) your post array is being assigned whatever is in that method call. Maybe nothing at all and it's returning true or false. In any case, by the time it gets to $w9status = $_POST['w9'] it's more than likely not assigning anything at all. Or at best, a boolean value (true/false). But again, I'm not psychic.
-
so then just add some css or html like in my example, before the include.
-
oh and I forgot to increment $x : $ribbon_select = 'select * from phpbb_medal_user'; $ribbon_result = mysql_query($ribbon_select) or die("$ribbon_select does not make any sence;<br>" . mysql_error()); $x = 0; while ($list = mysql_fetch_assoc($ribbon_result)) { echo $list['medal_id']; echo (($x % 9) == 0) ? "<br />" : " "; $x++; }
-
you're trying to run a query on a result source from another query. remove the mysql_query from $ribbon_select, just put it in quotes as a query string: $ribbon_select = 'select * from phpbb_medal_user'; $ribbon_result = mysql_query($ribbon_select) or die("$ribbon_select does not make any sence;<br>" . mysql_error()); $x = 0; while ($list = mysql_fetch_assoc($ribbon_result)) { echo $list['medal_id']; echo (($x % 9) == 0) ? "<br />" : " "; }
-
ermm...what exactly do you mean? PHP is not in charge of colors/fonts. That's straight html/css. are you wanting the user to be able to pick from a list? make a form with a dropdown or something, and have php echo out the html/css with the color/font choice. But if you're looking to just have it output white in general..that's straight html/css <style = 'text/css'> #somestyle { color: #ffffff; } </style> <p id='somestyle'>example using css</p> <font color = 'white'>example using html</font>
-
example: $sql = "select medal_id from table"; $result = mysql_query($sql); $x = 0; while ($list = mysql_fetch_assoc($result)) { echo $list['medal_id']; echo (($x % 9) == 0) ? "<br />" : " "; }
-
...well, you didn't really answer my question...what exactly is the problem? Do you see your data or not?
-
php doesn't parse javascript. your browser does. php just spits it out to your browser. Now, "It doesn't work" could mean that your variables aren't echoing what you want them to (I do see some $'s in there, which makes them php vars) but I don't see where you are setting them in the first place. You're going to have to be more specific about "it doesn't work." Is the data there, but it's just not showing/hiding? That's a javascript problem. Variables shooting blanks? Possibly php, possibly javascript. But again, you have to be more specific.
-
You can write it as a function, yes, but all of your script will be parsed, and all output sent to the browser, after it's parsed. so... <?php function showform () { echo <<<SOMEFORM <form action = 'target.php' method = 'post'> <input type = 'text' name = 'blah1'><br /> <input type = 'text' name = 'blah2'><br /> <input type = 'submit' value = 'submit'> </form> SOMEFORM; } // end form ...is a valid function. But you can't call it and wait for the user to get back to you before continuing your script. So you just have to setup conditions to check for it, and execute script, depending on it. This isn't the "best" way of doing it, but it's simplified for example purposes: <?php function showform () { echo <<<SOMEFORM <form action = 'target.php' method = 'post'> <input type = 'text' name = 'blah1'><br /> <input type = 'text' name = 'blah2'></br /> <input type = 'submit' value = 'submit'> </form> SOMEFORM; } // end form // no posted vars? show form if (!$_POST) { showform(); // else...something was posted, so... } else { // if nothing was posted in blah1... if(!$_POST['blah1']) { // make an error msg $errormsg = "fill out blah1!<br />"; } // end if // if nothing was posted in blah2... if(!$_POST['blah2']) { // make an error msg (or rather, add to it, cuz one might already have been started $errormsg.= "fill out blah12<br />"; } // end if // something not filled out? echo msg and show form if($errormsg) { echo "$errormsg<br />"; showform(); // everything seems to be in order so... } else { // do something with the posted vars } // end else } // end else ?>
-
You're going to have to change your way of thinking about program flow. It's not like real time environments like a stand alone app where it "waits" for an "event." It takes the code, parses it, spits back the results, and it's all over. It's like shaking a magic 8 ball and asking questions over and over. The 8 ball doesn't really "wait" for you to ask a question. You have to setup conditions like..a tumbling block, or a filter.
-
if you guys' PMs are related to this question, please keep it in the thread, as other people will not be able to benefit from the methods/solutions. Also, I'm not really seeing how this thread is any different than your other thread: http://www.phpfreaks.com/forums/index.php/topic,202065.0.html so I'm closing this thread.
-
well first off, your parse error in that code block is no comma separating needle from haystack in your array_key_exists