to nico_swd and Krakjoe

Discussion in 'PHP' started by Rizzler, Apr 2, 2007.

  1. #1
    Hey! :) since you 2 helped out yesterday it's bether to ask you again the making someone else that dosent know anyting about what we talked about confused! :p

    After slapping myself and crying i managed to edit the script a bit :)

    you se down bellow where it say "<--[ID]-->" it appeard under every picture, what i cant figure out now is how can i make it say "this is picture X" and X = ID for that pictures, so in short it should display each pictures ID under it with that text,

    maybe you 2 could help me out with this ? =)
    
    <style type="text/css">
    .masterContent{width:900px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10pt; color:#0066CC; background-color:#FFCCFF; margin:0 auto; text-align:center;}
    .imagePlaceholder{}
    .itemPlaceholder{float:left; margin-right: 5px; width: 210px;}/*this controls the column snaking*/
    .dataPlaceholder{}
    .imagePlaceholder img{ border:none;}
    .imagePlaceholder a{text-decoration:none; cursor:pointer;#0066CC;}
    .imagePlaceholder a:visited {text-decoration:none; cursor:pointer; color:#0066CC;}
    </style>
    <?php
    $theform = <<<END
    <form name="input" action="{$_SERVER['PHP_SELF']}" method="post">
    Cell number:
    <input type="text" name="number">
    <input type="submit" name="submit" value="Search">
    </form>
    END;
    
    define("MYSQL_SERVER", "sss");
    define("MYSQL_USERNAME", "sss");
    define("MYSQL_PASSWORD", "sss");
    define("MYSQL_DATABASE", "sss");
    
    $con = mysql_connect( MYSQL_SERVER, MYSQL_USERNAME, MYSQL_PASSWORD )
                OR die("Cannot connect to mysql " . mysql_error());
    mysql_select_db( MYSQL_DATABASE )
                OR die("Cannot select database " . mysql_error());
    
    //check click
    if(isset($_POST['submit'] )){
        //check variables
        if (empty($_POST['number'])){
            die ("you must provide a number");
        }
        //cleanse the number
        $number = sqlPrepare($_POST['number']);
        
        $result = mysql_query("    SELECT
                                    *
                                FROM
                                    mms
                                WHERE
                                    sender = '$number'", $con )
                    OR die("Cannot query server. ".mysql_error());
     
        /*
        it is wrong to think of this as true/false.  
        if the query fails it will drop out above.
        if it runs ok then you need to think in terms of the number of records that it returns.  
        you are testing for a blank recordset
        */
        if(mysql_num_rows($result) === 0 ){
            die("No records found");
        } else {
    
    placeholders
            // css.
            $display = "";
            while($row = mysql_fetch_assoc($result)){
                $display .= <<<HTML
        <div class="itemPlaceholder">
            <div class="imagePlaceholder">
                <a href="visabild.php?id={$row['id']}" class"imgLink">
                    <img width="100%" src="data/{$row['id']}.jpeg" />    
                </a>
            </div>
            <div class="dataPlaceholder">
                <--Detta är dom bilder du laddar du från: Phonenumber-->
            </div>
        </div>
    HTML;
        //end of the heredoc
            }    //end of while
            echo "<div class=\"masterContent\">\r\n $display </div>";
        }//end of numrows if
    }else{
        echo $theform;
    }
    
    function sqlPrepare($var){
    
        set_magic_quotes_runtime(false);
        if (get_magic_quotes_gpc()){
            //undo the magic quotes damages
            $var = stripslashes($var);
        }
        //return a cleaned up variable
        return mysql_real_escape_string(trim($var));
    }
    ?>
    
    Code (markup):
     
    Rizzler, Apr 2, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Find this line:
    
    <img width="100%" src="data/{$row['id']}.jpeg" />
    
    HTML:
    And place this under:
    
    <br />This is picture {$row['id']}
    
    HTML:
     
    nico_swd, Apr 3, 2007 IP