Jump to content


  • Posts

  • Joined

  • Last visited


Everything posted by earl_dc10

  1. 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!
  2. 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]
  3. 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
  4. 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]
  5. earl_dc10


    CHMOD is a fancy term for the permissions that you give a file
  6. 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]
  7. 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!
  8. 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]
  9. if you want a realtime counter I would recommend javascript
  10. hi, try changing [code] <form method=POST name=input> [/code] to [code] <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST" name="input"> [/code]
  11. is it a problem? you could just use stripslashes() when you print the data from the table
  12. 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 ;)
  13. 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]
  14. 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
  15. [code] <input type="submit" id="sbt_results" value="Query"/> [/code] try changing "id" to "name" EDIT -> looks like I type too slow ;)
  16. [!--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]
  17. 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 ;)
  18. 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)
  19. it may be to the fact that you have 6 opening brackets, but only 4 closing ones
  20. 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
  21. 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!
  22. 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
  23. try specifiying the actual width you want: [code] <textarea name="textfield" rows="1" cols="20" wrap="virtual"></textarea> [/code]
  24. 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
  • 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.