Results 1 to 2 of 2

Thread: Gosh, got a little stuck with $_GET['...'] function

  1. #1
    Join Date
    Jul 2009
    Location
    Lithuania
    Posts
    25
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default Gosh, got a little stuck with $_GET['...'] function

    I creating a script letting similar to forums, however Got roblems with one file:
    I don't know if you understand what I mean, hovewer her you link to look it up:
    http://w-luife.uphero.com/galerija/
    Everything working except then you openning link, its getting not everythin is in sql..

    Galerija.php
    PHP Code:
    <?
        
    include('_include/dbsettings.php');
        
    mysql_connect(host,user,pass) or die(mysql_error());
        
    mysql_select_db(db_table);
        
        
    $name $_GET['pavadinimas'];
        
        
    $take "SELECT * FROM galerija_info WHERE pavadinimas='$name'";
        
    $get mysql_query($take);
        
        
    $n mysql_num_rows($get);
        
    $i 0;
        
        
    $pavadinimas $_GET['pavadinimas'];
        echo 
    "[ <a href='link_add.php?pavadinimas=".$pavadinimas."' > Prideti </a> ]<br />
    <br />"
    ;
        
        if(
    $i<$n){
            
    $pavadinimas2 mysql_result($get,$i,'pavadinimas');
            
    $aprasymas mysql_result($get,$i,'aprasymas');
            
    $photo mysql_result($get,$i,'photo');
            
            echo 
    "
                Cia "
    .$pavadinimas2.", o cia yra ".$photo." su ".$aprasymas."
            "
    ;
        } 
        
        
    $i++; 
        
        
    mysql_close();
        
    ?>
    SQL file:
    PHP Code:
    CREATE TABLE galerija (
    id int(6not null auto_increment,
    pavadinimas varchar(250not null,
    PRIMARY KEY (id)
    );

    CREATE TABLE galerija_info (
    id int(6not null auto_increment,
    pavadinimas varchar(250not null,
    aprasymas longtext not null,
    photo longtext not null,
    PRIMARY KEY (id)
    ); 
    here to add in link
    PHP Code:
    <?
        
    include('_include/dbsettings.php');
        
    mysql_connect(host,user,pass) or die(mysql_error());
        
    mysql_select_db(db_table);
        
                        
    $pavadinimas2 $_GET['pavadinimas'];

        
    ?>
    <form action="link_conf.php" method="post">
      <input type="hidden" name="pavadinimas" value="<? echo $pavadinimas2 ?>" /><br />
        Aprasymas:<br />
      <textarea name="aprasymas"></textarea>
        <br />
        Nuotrauka:<br />
        <input type="text" name="photo"  />
        <br />
    <br />
        <input type="submit" value="Ideti"  />
    </form>
    <? 
        mysql_close
    ();
    ?>
    It's confirm
    PHP Code:
    <?
        
    include('_include/dbsettings.php');
        
    mysql_connect(host,user,pass) or die(mysql_error());
        
    mysql_select_db(db_table);
        
        
    $pavadinimas $_POST['pavadinimas'];
        
    $aprasymas $_POST['aprasymas'];
        
    $photo $_POST['photo'];
        
        
    $take "INSERT galerija_info VALUES ('','$pavadinimas','$aprasymas','$photo')";
        
    mysql_query($take);
        
    mysql_close();
        echo 
    "Informacija sekmingai buvo ikelta i <b>".$pavadinimas."</b> skilti! <a href='galerija.php?pavadinimas=".$pavadinimas."'>Gristi</a>";
        
    ?>
    I want it select all things are with name pavadinimas=$pavadinimas2,
    but can't made it. With id I can do it, but with searching by ame not
    Hope you understood

  2. #2
    Join Date
    Mar 2010
    Posts
    28
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default

    Please this example, you may write like this.
    For looping the result set you may use for,while,foreach,
    You may also find out why "if" is not good for looping.

    <?php
    $rows=mysql_fetch_array($resultsetfromquery){
    print $row['name'];
    print $row['email'];
    }
    ?>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •