Jump to content

mrdamien

Members
  • Posts

    186
  • Joined

  • Last visited

Posts posted by mrdamien

  1. My problem is that this code works perfectly for me in Firefox and Safari in OS X, however it will not work in Windows XP or Vista.  In Windows, the table "blue_table" should only be displayed once at the beginning.  However, it is displayed throughout the updating process.

    OS X/Windows has nothing to do with the problem. Your browsers rendering engine does.

     

    You have to add in the </table> tag after your done looping through the results.

     

                } // end while
              echo "</table>";
            } // end if(!isset($cmd))
    

  2. Unless your essay is only 255 characters or less, you'll want to use something bigger.

     

    Pick from these:

    VARCHAR( ) A variable section from 0 to 255 characters long.

    TINYTEXT A string with a maximum length of 255 characters.

    TEXT A string with a maximum length of 65535 characters.

    BLOB A string with a maximum length of 65535 characters.

    MEDIUMTEXT A string with a maximum length of 16777215 characters.

    MEDIUMBLOB A string with a maximum length of 16777215 characters.

    LONGTEXT A string with a maximum length of 4294967295 characters.

    LONGBLOB A string with a maximum length of 4294967295 characters.

  3. Well, you can 'query' a CSV file per se, but you can find it with regular expressions, or simply by going through each line.

     

    $file = file('csv.txt');

    foreach($file as $line){

    list($id, $name, $addess) = explode(",", $line);

    if($id == 123){

    }

    }

  4. while($d = mysql_fetch_array($qry_course))	
    {
    $coursenames[] = $d['coursename']; // Adds $d['coursename'] into the $coursenames array
    echo  $d['coursename'];
    }
    

     

    You just need to find out which index for both the $coursenames and $colorList arrays point to your desired values, then your query will just look like this:

    "UPDATE tbl SET color = '{$colorlist[$colorIndex]}' where course='{$coursenames[$courseIndex]}'"

  5. Well:

    A) Make sure you added the corresponding fields to your database.

    B) You need to edit your query to reflect the changes to your new structure. (I.e. add the mname/lname fields/values in your INSERT query);

     

    If you post the query/database part that will be more helpful.

  6. Change

      $name = $_POST['name' . $i];

      $age = $_POST['age' . $i];

      if(strlen($name) > 0){

        $values[] = array('name'=>$name, 'age'=>$age);

      }

     

    to

     

      $name = $_POST['name' . $i];

      $age = $_POST['age' . $i];

      if(strlen($name) > 0 && strlen($age) > 0){

        $values[] = array('name'=>$name, 'age'=>$age);

      }

     

    See if that works.

  7. Don't bump so quickly. People will help, it just doesn't come instantly.

     

    <?php
    session_start();
    $host = 'localhost';
    $user = 'root';
    $password = '';
    $dbase = 'project';
    
    $dblink = mysql_connect($host,$user,$password);
    mysql_select_db($dbase,$dblink);
    
    $query= "INSERT INTO list (name,age) VALUES ";
    
    for($i=1; $i<8; $i++){
     $name = $_POST['name' . $i];
     $age = $_POST['age' . $i];
     if(strlen($name) > 0){
       $values[] = array('name'=>$name, 'age'=>$age);
     }
    }
    
    foreach($values as $key=>$value){
    $query .= "('{$value['name]}', '{$value['age']}')";
    if($key != 7){
     $query .= ",\n";
    }
    }
    
    echo $query;
    $result = mysql_query($query,$dblink);
    ?>

     

    (Not tested)

  8. <?php
    
    $path = ".";
    $dir_handle = @opendir($path) or die("Unable to open folder");
    
    function list_Pages($pg, $pages){
    for($i = 1; $i <= $pages; $i++){
    	if($i-1 == $pg){
    		$string .= "<b>{$i}</b>";
    	}else{
    		$off = $i-1;
    		$string .= "<a href='index.php?page={$off}'>{$i}</a>";
    	}
    }
    return $string."<br>";
    }
    
    ?>
    <form name="form1" method="post" action="gallery_post.php">
    <?php
    
    while (false !== ($file = readdir($dir_handle))) {
    if(!in_array($file, array("index.php","..","."))){
    	//explode to include only images
    	$explodefile = explode(".", $file);
    	if(in_array($explodefile[1], array("jpg","png","gif"))){
    		$fileList[] = $file;
    	}
    }
    }
    
    closedir($dir_handle);
    
    if(!isset($_GET['page'])){ 
    $page = 0; 
    }else{ 
    $page = $_GET['page']; 
    }
    
    $perPage = 10;
    
    $from = ($page * $perPage);
    
    for($i = $from; $i < $from + $perPage; $i++){
    if($fileList[$i] != ""){
      echo "<input type='checkbox' name='Files[{$fileList[$i]}]' value='y'>";
      echo "<a href='{$fileList[$i]}' target='_blank'>{$fileList[$i]}</a><br />";
    }
    }
    
    $pages = ceil(count($fileList) / $perPage);
    echo list_Pages($page, $pages);
    
    if($page > 0){ $prev = $page-1; }else{ $prev = 1; }
    if($page < $pages){ $next = $page+1; }else{ $next = $pages; }
    
    echo "<br><a href='?page={$prev}'>Back 1 page</a> <a href='?page={$next}'>Forward 1 page</a>";
    
    ?>
    <input name="delete" type="submit" id="delete" value="Delete">
    </form>

    Fixed. (Tested this time.)

  9. Use an absolute path:

    include ($_SERVER['DOCUMENT_ROOT'] . "/path/to/your/site/includes/file2.php");

    include ($_SERVER['DOCUMENT_ROOT'] . "/path/to/your/site/includes/file3.php");

     

    Should work no matter where you include it form.

  10. You should consider using a database for this, since it is much more suited to your needs.

     

    But try this:

    <?php
    
    $path = "/";
    $dir_handle = @opendir($path) or die("Unable to open folder");
    
    ?>
    <form name="form1" method="post" action="gallery_post.php">
    <?php
    
    while (false !== ($file = readdir($dir_handle))) {
    
    if($file == "index.php")
    continue;
    if($file == ".")
    continue;
    if($file == "..")
    continue;
    //explode to include only images
    $explodefile = explode(".", $file);
    if($explodefile[1] != "jpg" && $explodefile[1] != "gif" && $explodefile[1] != "png")
    continue;
    
    $fileList[] = $file;
    }
    
    closedir($dir_handle);
    
    $page = (int)$_GET['page'];
    $imagesPerPage = 10;
    
    for($i = $page*$imagesPerPage; $i < count($fileList) + $imagesPerPage; $i++){
      echo "<input type=CHECKBOX name='Files[$fileList[$i]]' value='y'>";
      echo "<a href='http://www.mysite.com/$fileList[$i]' target='_blank'>$fileList[$i]</a><br />";
    }
    echo "<a href='?page={$page-1}'>Back 1 page</a> <a href='?page={$page+1}'>Forward 1 page</a>";
    
    ?>
    <input name="delete" type="submit" id="delete" value="Delete">
    </form>
    

     

  11. This isn't an "if statement" problem. We don't write whole scripts for you.

     

    Here's some pseudo-code to get you started:

     

    -Connect to DB server

    -Select database

    -Query db: Select row from pp_goods

    -If pp_goods.feature == "y"

    --Then echo "some example text"

    --Else nothing

    -Disconnect from DB server

  12. You could make your ajax functions by yourself, but try using a javascript library like jquery.

    Other libraries include (google) mootools / prototype

    Once you download/include the jquery library do something like this:

    <script>
    function myFunction(id){
     $.get("page.php", { drink: id },
     function(data){
       alert("Data Loaded: " + data);
     });
    
    }
    </script>
    <option onchange="myFunction(this.value)">
    <select value="1">water</option>
    <select value="2">soda</option>
    <select value="3">beer</option>
    </option>
    <?
    #page.php
    switch($_GET['drink']){
     case 1:
      echo "water is okay";
     break;
     case 2:
      echo "yay for soda";
     break;
     case 3:
      echo "nice";
     break;
    }
    ?>
    

    This wasn't tested, but should give you the idea.

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