Jump to content

earl_dc10

Members
  • Posts

    71
  • Joined

  • Last visited

    Never

Posts 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. 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]
  6. 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 ;)
  7. 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]
  8. 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
  9. [!--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]
  10. 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 ;)
  11. 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)
  12. 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!
  13. 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
  14. 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.