earl_dc10
Members-
Posts
71 -
Joined
-
Last visited
Never
Everything posted by earl_dc10
-
looks good, but Im a little confused why you want to shop off the end of $query [code] $query = substr($query,0,-1).") VALUES ("; [/code] also minor change [code] $query = substr($query,0,-1).") VALUES ("; for($i=0; $i<count($data); $i++) { $query .= "'$fields[$i]',"; // for values should be $data[$i], correct? [/code] Thanks for the input!
-
include doesn't necessarily display the data, it just, like it's name implies, includes its info into the current document and php is server code, it is parsed before it ever reaches the user, they can only see the output [code] <?php echo "<h1>Hello<h1>"; ?> //displays in web source code <h1>Hello<h1> [/code]
-
Im creating an admin page where I can edit all of my tables and stuff like that. I use 1 form for everything and just apply it to seperate tables with radio buttons (selecting the different tables). anyway, if I want to add a new row or update a new row, I update the form with the number of text fields that correspond with the number of fields in the table, this is stored in an array. since the number of fields can vary, how would I right an Insert/Update query to accomodate that? I thought of having just 1 Insert and then the rest Update off of that Insert, but if I have 2 that are the same it would do both rows instead of the new one. Thanks! EDIT -> Inspiration just struck, but I'll ask anyway to see if there are any better ideas than mine this is my idea but we'll see what you come up with, since all my tables have id's I'll just insert the new id and run the updates off of that
-
you could also do something similar to this : [code] if(empty($garage) || empty($cellar) || empty($garden) || empty($pool)) { echo "Please fill all fields"; } [/code] if you don't like that you can just combine sford999 's code into a similar statement [code] if(($garage == "") || ($cellar == "") || ($garden == "") || ($poll == "")) { echo "Please fill all fields"; } [/code]
-
CHMOD is a fancy term for the permissions that you give a file
-
ensure that your echo statement uses single quotes for the echoing ', if you have doubles " you'll need to do an escape slash [code] echo " <form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\" name=\"input\"> [/code]
-
are you echoing the form inside of php? if you are try this : [code] echo ' .... <form action="'.$_SERVER['PHP_SELF'].'" method="POST" name="input"> [/code] hope that helps!
-
try this : [code] $query = "SELECT * from $db_table ORDER by $some_field DESC"; // don't have a LIMIT in it $select_query = mysql_query($query, $link) or die("Couldn't select from $db_table ".mysql_error() ); $num_rows = mysql_num_rows($select_query); // gets number of rows [/code]
-
if you want a realtime counter I would recommend javascript
-
hi, try changing [code] <form method=POST name=input> [/code] to [code] <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST" name="input"> [/code]
-
Getting a forward slashes in my text whenever there is an apostrophe
earl_dc10 replied to eldredm's topic in PHP Coding Help
is it a problem? you could just use stripslashes() when you print the data from the table -
if you are deleting a row do this : [code] $query = "DELETE FROM $table WHERE $column = '$field_value'"; [/code] I believe DROP is used for removing Indexes, and deleting tables and databases P.S. double check your row values before deleting, this saved me alot of grief ;)
-
try this [code] $sql = "UPDATE $table SET $field_name ='$new_entry' WHERE post_id = '$post_id' [/code] more on this at [a href=\"http://www.w3schools.com/sql/sql_update.asp\" target=\"_blank\"]http://www.w3schools.com/sql/sql_update.asp[/a]
-
at every query add a die statement with an error [code] $select = "SELECT * FROM example"; $select_query = mysql_query($select, $link) or die("Couldn't select from example".mysql_error() ); [/code] tell us what happens then
-
[code] <input type="submit" id="sbt_results" value="Query"/> [/code] try changing "id" to "name" EDIT -> looks like I type too slow ;)
-
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] (http://localhost/Der/writings/author.php?ID=5) but the list page is not accepting that variable. [/quote] if that is the exact URL (at least the ID=5 part) instead of [code] $recordID = $_GET['recordID']; [/code] You'll want [code] $recordID = $_GET['ID']; [/code]
-
ahh, I see what you mean now, pagination I think they call it (not really sure) yeah, ok in essence what you want to do is this : [code] $select_all = "SELECT * FROM $table"; // can replace * with a column that has all rows filled $num_all = mysql_num_rows($select_all); // now run that select script with a limit in it //and for the pages (really simplified) for($x = 0; $x <= $num_all; $x++) {if($x % 10 == 0) echo "page stuff"; } [/code] use the select limit query in conjunction with pagination and you should get what you want, EDIT looks like I take too long to type ;)
-
Unless this isn't what you want, couldn't you just do [code] $query = mysql_query("SELECT Name, URL_Image_Small, Price, URL_Product, Product_Type, Category, Description, Popular FROM db WHERE Category LIKE '$category' ORDER BY Popular LIMIT 10"); [/code] I use this on my blog (slightly altered) and Im assuming that $s is a page id or something, so just multiply $s*10 to get the id's you want to display (($s*10)-1 if your id's start at 0)
-
it may be to the fact that you have 6 opening brackets, but only 4 closing ones
-
wordwrap only works if there is breaks in the text ie, "how are you doing...." won't wrap "aaaaaaaaaaaaaaaaaaaaaaa....." maybe some CSS could remedy that
-
Help me, I have problem with php and check box form
earl_dc10 replied to thanhnguyen's topic in PHP Coding Help
Hi, what specific problems are you having? -
thanks, that was exactly what I needed, also my "fraction finder" script shown above was extremely flawed notice [code] {$temp = $input*$x; if(($temp/$x) == $input) // that was just stupid [/code] so I needed all the help I could get, thanks again!
-
hey, I have a field where the user inputs a number, and it can be a fraction, I could have 2 fields where it's like <field> / <field> but I don't want to do that. I need to seperate the fraction ie (2/3 = 2, and 3) and I devised a way to do that : [code] for($x = 1; $x <= 100; $x++) {$temp = $input*$x; if(($temp/$x) == $input) {$num1 = $temp; $num2 = $x; break; } } [/code] it only reads the first half of the fraction, if I were to multiply $input by $x, it does this: input will be 2/3 and $x will be 3, you'd think the output would be 2, right? it comes out as 6, it ignores what is after the "/" is there any way to resolve the fraction? ie, 2/3 = .6666... and go from there? thanks! -J
-
try specifiying the actual width you want: [code] <textarea name="textfield" rows="1" cols="20" wrap="virtual"></textarea> [/code]
-
sorry, I forgot that mysql_numrows is just an earlier version, but probly a good idea to change it anyway. do you receive any errors or does it just not run. oh, maybe a ";" after defining $email will do it