Jump to content

litebearer

Members
  • Posts

    2,356
  • Joined

  • Last visited

Posts posted by litebearer

  1. You are still 'dividing" your text strings --'".$firstname/$lastname."', '".$day/$month/$year."',

     

    To join strings use the . (period on your keyboard) -

    $firstname = "Fred";
    $lastname = "Flintstone"
    $fullname = $firstname . " " . $lastname;
    echo $fullname; // would display Fred Flintstone (note the space we added between the names
    $fulldate = $day . "/" . $month . "/" . $year;
    

     

    Also, you might look into date options for your database; using datetime might end up a better choice depending upon what you anticipate doing with its values.

     

    And, it might be a good practice to put your queries into a string, it makes it easier to test if the values are what you expect.

     

    And, (lots of ands LOL), you should validate your form data.

  2. The following script will display a tables structure as well as its contents...

    <?php
    /*
        this small script can be used to
            (a) get and display a table's structure (field names and field type)
            (b)    get and display the field contents in an html table
    */
    
    /* set the database connection variables */
    $database="";
    $location = "";  
    $username = "";  
    $password = "";  
    $db_table = "";
    
    /*
    set the function switches
        0 means use
        1 means do NOT use
    */
    
    $display_table_structure = 0;
    $display_table_contents = 0;
    $csv_name = $db_table . "_" . time();
    $how_many = 0; /* use this value to limit the number of records returned in the data query (0 means no limit) */
     
    /* Start Defining the function(s) */
    
    
    /*        This function gets the field names */
    function my_db_get_table_field_names($table) {
        $sql = "SHOW COLUMNS FROM `$table`";
        $field_names = array();
        $result2 = mysql_query($sql);
        for($i=0;$i<mysql_num_rows($result2);$i++){
            $row = mysql_fetch_array($result2);
            $name = $row['Field'];
            array_push($field_names, $name);
        }
        return $field_names;
    }
    
    
    
    /* connect to the database */
    mysql_connect ($location, $username, $password);
    mysql_select_db($database) or die( "Unable to select database");
    $result0 = mysql_query("SHOW COLUMNS FROM $db_table");
    
    if (!$result0) {
      echo 'Could not run query: ' . mysql_error();
      exit;
    }
    
    
    /*    get the field names into an array and count them */
    $new_array = my_db_get_table_field_names($db_table);
    $fields = count($new_array);
    
    /* get all the data and count the records */
    
    if ($how_many == 0) {
        $result = mysql_query( "SELECT * FROM $db_table" )
        or die("SELECT Error: ".mysql_error());
        $num_rows = mysql_num_rows($result);
    }else{
        $result = mysql_query( "SELECT * FROM $db_table LIMIT $how_many" )
        or die("SELECT Error: ".mysql_error());
        $num_rows = mysql_num_rows($result);
    }
    
    /* display the general information */
    echo "This information is for the " . $database . " database. Table " . $db_table . "<br><br>";
    echo "There are " . $fields . " columns/fields  and " . $num_rows . " records.<br><br>";
    
    /*    display the table structure */
    if ($display_table_structure == 0) {
            echo "<hr>Table structure for " . $db_table . ": <br><br>";
            echo "<table border=1> <tr><td>Field #</td><td>Field Name</td><td>Field Type</td></tr>";
        $result9 = mysql_query("SHOW FIELDS FROM $database.$db_table");
        $i = 0;
        while ($row = mysql_fetch_array($result9)){
            echo "<tr><td>" . $i . "</td><td>" . $row['Field'] . "</td><td>" . $row['Type'] . "</td></tr>";
        $i = $i +1;
        }
            echo "</table>";
    }
    
    /* display the table contents */
    if ($display_table_contents == 0) {
        echo "<hr>Table data for " . $db_table . ": <br><br>";
        echo "<table width='100%' border=1>\n";
        $i = 0;
        echo "<tr>\n";
        for ($i=0;$i<$fields;$i++) {
          echo "\t<td><font face=arial size=1/>$new_array[$i]</font></td>\n";
        }
        while ($get_info = mysql_fetch_row($result)){
            echo "<tr>\n";
            foreach ($get_info as $field)
                echo "\t<td><font face=arial size=1/>$field</font></td>\n";
                echo "</tr>\n";
        }
        echo "</table>\n";
    }
    ?>
    
    

     

  3. Effectively, you are placing an <option></option> within an option. Your while loop should begin immediately after your opening select and end immediately prior to your closing select. If you look closely at your browser source you should see what is happening

  4. just a thought...

    rather than

    <?php
    
     
    
    //Defines a variable for the results file I'm pulling information from;
    
     
    
    $myFile = "./'results file here.txt'";
    
     
    
    // Define a variable and the string that is pulled from line 8 in the results file will be outputted
    
     
    
    $row1 = file($myFile); //Pulls First Row of the specific file
    
    echo $lines[8]; // Line 8
    
    ?>
    



    try this

    <?php
    $myFile = "FILE NAME AND PATH HERE"; /* no need for the single quotes */
    $lines = file($myFile) /* this creates an array of all the lines in the file NOT just the first line */
    echo $lines[8]; /* this will display the 9th line - Array element begin with zero - $lines[0] */
    ?>
    



    You will need to use explode to get each separate pice of data in a line
     

  5. Replace this

    echo "<img style='vertical-align: middle; float: right'; title='$curimg'; src='images/gallery/flowers/thumbs/$curimg'; /><br>\n";
    


    with this

    ?>
    <a href="images/gallery/flowers/<?php ech $curimg; ?>" target="_blank">
    <img style="vertical-align: middle; float: right"; title=<?php echo '$curimg; ?> src="images/gallery/flowers/thumbs/<?php ech $curimg; ?>">
    <br>\n";
    </a>
    <?php
    


     

  6. hint:

    <a href="<?php echo PATH large_image; ?>" target="_blank"><?php echo PATH thumb_image; ?></a>
    

    use  $curimg for both the large image as well as the thumb, simply insert the appropriate path.

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