Deviant Logo

Is it possible to do this in php?

post details top
Jun 4th, 2010
post details top


I need to run this script in a form to mail script, can it be done and if so how ?

script code:
$kode = ‘
$New="SELECT * FROM products";
$result = mysql_query($New);
$num=mysql_num_rows($result);
$x = 0;
while($x < $num){
$Code = mysql_result($result,$x,\'code\');
if (isset($_SESSION[$Code])){
?>


echo $Code ;
?>

echo $_SESSION[$Code]
?>

}
$x++;
}
?>
‘;

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

2 Comments

  • Colinc

    This is a very clumsy script. You can run any php from a form, the best way is to use php to build the form, then use $_SERVER[PHP_SELF] as the action and something like :
    < ?php
    //from a submit button called send, value='Send Details'
    //with a cancel submit button value='Cancel'
    if($_POST[cancel] == "Cancel"){
    //routine for cancelled entry
    }
    if($_POST[send] =="Send Details"){
    //routine to send data using the mail function
    }
    When working with php it is easiest to build the whole page with it and then display it in one hit :
    $display_string = "

    My Heading

    etc

    “;
    //above is the table headings row
    $query_string = “select * from stocklist where obsolete = ‘0′”;
    $result = mysql_query($query_string, $connect_id);
    while ($record = mysql_fetch_array($result)){
    $display_string .= “

    “;
    }
    //do not miss out the . to concatenate the strings above and below
    $display_string .= “

    first heading
    $record[id] $record[part_name] $record[description] $record[qty]

    “;
    ?>


    //your headers, title etc


    < ?php> echo $display_string; ?>

  • PaeKm

    $kode = ”
    < ?php
    $New="SELECT * FROM products";
    $result = mysql_query($New);
    $num=mysql_num_rows($result);
    $x = 0;
    while($x < $num){
    $Code = mysql_result($result,$x,'code...
    if (isset($_SESSION[$Code])){
    echo "

    “;
    echo $Code ;
    echo “

    echo $_SESSION[$Code]
    echo”


    }
    $x++;
    }
    ?>
    “;

Leave a Reply

Search

  • Partner links