Jump to content

11Tami

Members
  • Posts

    329
  • Joined

  • Last visited

    Never

Posts posted by 11Tami

  1. I added this to the top of my page and it didn't help. Its supposed to get the number variable out of the browser address so that the code will know what page its on.

     

    if(!isset($_GET['page'])){

        $page = 1;

    } else {

        $page = $_GET['page'];

    }

     

    Anyone see what else is wrong with the code?

  2. Ok fixed that, getting closer, here's the update. Numbered links are appearing on the bottom of the page now for a total of how many pages there are. And when I click on each different link such as 1 2 etc. the browser address changes to match the number like this: php?page=1 php?page=2 and so on.

     

    Problem now is the same database rows are showing up on each page, instead of different rows. I believe thats because as mentioned above $page hasn't been properly defined yet. Anyone have any ideas?

     

    <?php 
    // Connects to your Database 
    mysql_connect('', '', '') or die(mysql_error()); 
    mysql_select_db("") or die(mysql_error()); 
    
    //Here we count the number of results 
    //Edit $data to be your query 
    $data = mysql_query("SELECT fieldname FROM tablename") or die(mysql_error()); 
    
    $rows = mysql_num_rows($data); 
    
    //How many rows to put on each page 
    $page_rows = 10; 
    
    // Figure out the total number of results in DB: 
    $total_results = mysql_result(mysql_query("SELECT COUNT(*) as ID FROM tablename"),0); 
    
    // Figure out the total number of pages. Always round up using ceil() 
    $total_pages = ceil($total_results / $page_rows); 
    
    // Figure out the limit for the query based 
    // on the current page number. 
    $max = 'LIMIT ' .(($total_pages * $page_rows) - $page_rows);
    
    // Perform MySQL query on only the current page number's results 
    $data_p = mysql_query("SELECT fieldname FROM tablename $max") or die(mysql_error()); 
    
    //This is where you display your query results
    while($info = mysql_fetch_array( $data_p )) 
    { 
    
    Print $info['Name']; 
    echo "$info[fieldname]";
    } 
    
    echo "<p>";
    
    // Build Page Number Hyperlinks 
    echo "<center>Select a Page<br />"; 
    
    // Build Previous Link 
    if($page > 1){ 
        $prev = ($page - 1); 
        echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> "; 
    } 
    
    for($i = 1; $i <= $total_pages; $i++){ 
        if(($page) == $i){ 
            echo "$i "; 
            } else { 
                echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "; 
        } 
    } 
    
    // Build Next Link 
    if($page < $total_pages){ 
        $next = ($page + 1); 
        echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>"; 
    }
    ?>

  3. I found the problem with this:

     

    "warning, division by 0" Its because both of these have each others variables in them. total pages can't ask for $max if $max hasn't been defined yet. Anyone see what variable in these should be changed?

     

    // Figure out the total number of pages. Always round up using ceil()

    $total_pages = ceil($total_results / $max);

     

    // Figure out the limit for the query based

    // on the current page number.

    $max = 'LIMIT ' .(($total_pages * $page_rows) - $page_rows);

     

  4. OK that did something, at least this is progressing forward now with some help, I appreciate it very much. Now this is the message I get

    "warning, division by 0"

    here:

    $total_pages = ceil($total_results / $max);

     

    Can't figure out how to get it from dividing by 0. I don't know if this is the zero in the code above it is talking about ",0);" at the end of the  $total_results variable.

     

     

    Also, the $page variable isn't working at all yet for the page numbering at the bottom of the code because this is how they set it up

    here: http://www.phpfreaks.com/tutorials/73/0.php

    if(!isset($_GET['page'])){ 
        $page = 1; 
    } else { 
        $page = $_GET['page']; 
    } 

    I didn't add that yet, because I have id's in my table. I didn't know how to incorporate that for the code I am using instead. So $page is still undefined, some suggestions on that would be very helpful.

  5. Ok I'll show everybody what I've got in hopes that someone can help me. It is using the above link you gave me. This is the error message the page is giving me.

     

    "You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '-10' at line 1"

     

    It seems to be talking about $page_rows = 10;  Because whenever I adjust the row, the above message changes to the different number as well. Here's where I am using the link you gave above.

     

    <?php 
    // Connects to your Database 
    mysql_connect('databaseaddress', 'databasename', 'password') or die(mysql_error()); 
    mysql_select_db("databasename") or die(mysql_error()); 
    
    //Here we count the number of results 
    //Edit $data to be your query 
    $data = mysql_query("SELECT fieldname FROM tablename") or die(mysql_error()); 
    
    $rows = mysql_num_rows($data); 
    
    //How many rows to put on each page 
    $page_rows = 10; 
    
    // Figure out the limit for the query based 
    // on the current page number. 
    $max = 'LIMIT ' .(($total_pages * $page_rows) - $page_rows);
    
    // Figure out the total number of results in DB: 
    $total_results = mysql_result(mysql_query("SELECT COUNT(*) as ID FROM tablename"),0); 
    
    // Figure out the total number of pages. Always round up using ceil() 
    $total_pages = ceil($total_results / $max); 
    
    // Perform MySQL query on only the current page number's results 
    $data_p = mysql_query("SELECT fieldname FROM tablename $max") or die(mysql_error()); 
    
    //This is where you display your query results
    while($info = mysql_fetch_array( $data_p )) 
    { 
    Print $info['Name'];
    echo "$info[fieldname";
    } 
    
    echo "<p>";
    
    // Build Page Number Hyperlinks 
    echo "Select a Page"; 
    
    // Build Previous Link 
    if($page > 1){ 
        $prev = ($page - 1); 
        echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> "; 
    } 
    
    for($i = 1; $i <= $total_pages; $i++){ 
        if(($page) == $i){ 
            echo "$i "; 
            } else { 
                echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "; 
        } 
    } 
    
    // Build Next Link 
    if($page < $total_pages){ 
        $next = ($page + 1); 
        echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>"; 
    }
    ?>

  6. Thats pretty amazing, I already saw that link, but it didn't help. I couldn't adjust it for what I have. But thanks for the help. For instance I don't know what I'm supposed to do with this to populate my database with it. I guess I'm supposed to put the name of my table below instead of "pages" but how do I send it to my database?

     

    <?php  
    for($i = 1; $i <= 102; $i++){ 
        mysql_query("INSERT INTO pages (title) VALUES ('Item $i')"); 
        echo "Item $i inserted into db <br />"; 
    } 
    ?> 

  7. Hello, I have a certain amount of data in a database table.

     

    Then I have code that divides the total of all the rows in the database by so many rows per page. So the code knows how many pages total there are.

     

    Trouble is, how do I list links for all the individual pages so that the search engines will follow them? If I list the whole code here its such a mess, I won't get any help with it.

     

    Know that I have a basic pull from a database using the usual queries like this plus how to get into the database above this with passwords and such.

     

    $data = mysql_query("SELECT fieldname FROM table") or die(mysql_error()); 
    
    $rows = mysql_num_rows($data); 
    
    //This is the number of results displayed per page 
    $page_rows = 9; 
    
    //This tells how many pages there are
    $last = ceil($rows/$page_rows); 
    
    while($info = mysql_fetch_array( $data_p )) 
    {  
    echo "$info['fieldname']";
    }

     

    If I could get some suggestions on how to add the page links to the page, I can build the rest in this post with some help.

     

    Please get back to me on how to number the pages, thank you very much.

     

  8. Thanks, I'd like to be sure about this before I go to all the trouble of starting it. They said that all these addresses all over the place in google and others proove they search and read these type of pages and all the code in them, as real pages. Exactly like the others. Someone let me if this is not true please and why.

     

    www.codingforums.com/archive/index.php?t-36401.html - 4k -

  9. Thanks, I already know how to get the sql to the page with php. I need to know how all that mysql data now on the page, can then be sent on to the server as a new page.

     

    I am pretty sure from what I've heard, some people are generating web pages automatically with mysql data. And not making each page themselves, one at a time. I just don't know how its done.

     

    Here's one article that talks about it as a php plug in: http://www.sitepoint.com/article/publishing-mysql-data-web

  10. I thought you could do all sorts of extra if commands while items are being pulled onto a page with php. Because the browser is already talking to the server during that same time.

     

    Some data is being put on the page using mysql, php and a form. I was hoping while the data is being pulled onto the page the whole page could be grabbed and sent onto the server with the new data included, through some sort of "if" statement. To any  directory anywhere on the server.

     

    Because I am not getting how people are automatically generating new web pages with database data. I know they can't all be doing each page one at a time manually, they have to have some sort of program or script to help. Some sites are way too busy.

     

    So either something that will send the database data to web pages on my computer, or upload them to the server.  Anyone know?

  11. I think I had that wrong, the destination file is supposed to be where the page will go on the server. The source file I believe is the name of the web page being sent. Let me  know if I have that wrong. Thanks.

  12. Hello, I finally got my ftp set up mostly properly. But not sure why this isn't working. When I open this page in the browser I am getting no php errors, nothing is appearing on the page saying successful, nothing. Can anyone see anything wrong with it? The destination file is just the web address where this code is found. I am asking the php to send this web page to the server at the specified ftp directory.

     

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

    <HTML>

    <HEAD>

    <TITLE>File Uploading</TITLE>

    </HEAD>

    <BODY>

    </BODY>

    </HTML>

    <?php

    // set up basic connection

    $ftp_server = "server ip";

    $conn_id = ftp_connect($ftp_server);

     

    // login with username and password

    $ftp_user_name = "username";

    $ftp_user_pass = "password";

     

    $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

     

    // check connection

    if ((!$conn_id) || (!$login_result)) {

            echo "FTP connection has failed!";

            echo "Attempted to connect to $ftp_server for user $ftp_user_name";

            exit;

        } else {

            echo "Connected to $ftp_server, for user $ftp_user_name";

        }

     

    // upload the file

    $Destination_file = "/uploadedfiles/";

    $source_file = "http://www.mywebsite.com/thispage.php";

     

    $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);

     

    // check upload status

    if (!$upload) {

            echo "FTP upload has failed!";

        } else {

            echo "Uploaded $source_file to $ftp_server as $destination_file";

        }

     

    // close the FTP stream

    ftp_close($conn_id);

    ?>

     

     

    Please let me know why nothing is happening. Thank you very much.

     

  13. Hello, I am trying to connect to ftp using php.

     

    I'm not sure what php wants when it asks for this: $ftp_server

    I tried putting the port number there but it wouldn't take it.  The error message says "supposed to be a resource, boolean given" and I have no idea what that means.

     

    Please let me know what goes there, thank you very much.

  14. Hello I'm trying to upload a file to the server when a submit button is pushed. For instance,

     

     

    <?php

    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" /><HTML>

    <TITLE>Uploading a file</TITLE>

    </HEAD>

    <BODY>

    <FORM ENCTYPE="multipart/form-data" NAME=MyForm ACTION=submit.php METHOD="POST">

    <INPUT TYPE="hidden" NAME="command" VALUE="1">

    <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="100000">

    <INPUT NAME="MyFile" TYPE="File">

    <INPUT NAME="submit" VALUE="Upload" TYPE="submit">

    </FORM>

    <?php

    $link = mysql_connect('database address', 'databasename', 'password');

    if (!$link) {

    die('Not connected : ' . mysql_error());

    }

     

    $db_selected = mysql_select_db('databasename', $link);

    if (!$db_selected) {

    die ('Can\'t use database : ' . mysql_error());

    }

     

    $query = "SELECT softwarename FROM addsoftware WHERE `id` = '46'";

     

    $result = mysql_query($query) or die(mysql_error()."

    ".$query);

     

    while ($row = mysql_fetch_array($result))

     

    {

    echo <span>$row[softwarename]</span>";

    }

     

    ?>

    <BR><BR>

    </CENTER>

    </BODY>

    </HTML>

    <?php 

    $DestinationDir = "/uploadedfiles/";

    $DestinationFile = $DestinationDir . $_FILES['MyFile']['name'];

    If (move_uploaded_file($_FILES['MyFile']['tmp_name'], $DestinationFile)) {

    Echo "File uploaded successfully.";

    }Else{

    Echo $_FILES['MyFile']['error'];

    ?>

     

    But I don't know how to upload the whole file instead of only whats in the submit form. The whole above example I found online says its supposed to upload a whole file yet this: $_FILES['MyFile']['name'];  --is only asking for whats in the input of form of the page, not the whole page. Need help. Please let me know how to do this, thank you very much.

×
×
  • 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.