Jump to content

psyion

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Posts posted by psyion

  1. i need to insert the current date and time of an entry into my database. how can i do this?
    in the last feaw lines of my script you can fine " <input type="hidden" name="timedate" value="">"
    what do i put for the value="" part? [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /]

    below is my script (generated by Dreamweaver) [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /]

    <?php require_once('Connections/msgBoard.php'); ?>
    <?php
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
    {
    $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

    switch ($theType) {
    case "text":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "long":
    case "int":
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
    break;
    case "double":
    $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
    break;
    case "date":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "defined":
    $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
    break;
    }
    return $theValue;
    }

    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
    $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
    $insertSQL = sprintf("INSERT INTO enquiry (name, email, timedate, msg) VALUES (%s, %s, %s, %s)",
    GetSQLValueString($_POST['name'], "text"),
    GetSQLValueString($_POST['email'], "text"),
    GetSQLValueString($_POST['timedate'], "date"),
    GetSQLValueString($_POST['msg'], "text"));

    mysql_select_db($database_msgBoard, $msgBoard);
    $Result1 = mysql_query($insertSQL, $msgBoard) or die(mysql_error());
    }
    ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>

    <body>
    <form method="post" name="form1" action="<?php echo $editFormAction; ?>">
    <table align="center">
    <tr valign="baseline">
    <td nowrap align="right">Name:</td>
    <td><input type="text" name="name" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Email:</td>
    <td><input type="text" name="email" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right" valign="top">Msg:</td>
    <td><textarea name="msg" cols="50" rows="5"></textarea>
    </td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">&nbsp;</td>
    <td><input type="submit" value="Insert record"></td>
    </tr>
    </table>
    <input type="hidden" name="timedate" value="">
    <input type="hidden" name="MM_insert" value="form1">
    </form>
    <p>&nbsp;</p>
    </body>
    </html>
  2. okey i'm also learning here... i just learn php for like about 2 weeks now... still learning thou.
    i hope the codes help ramki.

    The code that i give are partially made from dreamweaver using "record insertion form wizard" and modified just to send variable but not an sql. I found this way of passing variable while i was stuck with a page where i need to pass names and other variables only.

    But i need some explenation on some part that i really don't know what does the code mean.

    "code discription passing a variable name id from pageOne.php to pageTwo.php."

    pageOne.php
    [code]<?php
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }

    if ((isset($_POST["hiddenField"])) && ($_POST["hiddenField"] == "form1")) {
    $id = $_POST['id'];

      $insertGoTo = "pageTwo.php?id=$id";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $insertGoTo));
    }

    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>pageOne</title>
    </head>

    <body>
    <form id="form1" name="form1" method="post" action="<?php echo $editFormAction; ?>">
      <input name="hiddenField" type="hidden" value="form1" />
      Input id
        <input name="id" type="text" id="id" />
      <input type="submit" name="Submit" value="Submit" />
    </form>
    </body>
    </html>[/code]

    pageTwo.php
    [code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>pageTwo</title>
    </head>

    <body>
    id given is =
    <?php echo $_GET['id']; ?>
    </body>
    </html>[/code]

    [b]so what does this part of the code mean and what is happening here?[/b]

    [code]<?php
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }

    if ((isset($_POST["hiddenField"])) && ($_POST["hiddenField"] == "form1")) {
    $id = $_POST['id'];

      $insertGoTo = "pageTwo.php?id=$id";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $insertGoTo));
    }

    ?>[/code]

    And can you guys here teach me the easyway of doing this so i don't need to copy here and cut there just to pass a variable. i got the feeling that the code written have gone a really long way just to pass a variable. thank you.

  3. <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <script type="text/JavaScript">
    <!--
    function MM_openBrWindow(theURL,winName,features) { //v2.0
    window.open(theURL,winName,features);
    }
    //-->
    </script>
    </head>

    <body>
    <p><a href="#" onClick="MM_openBrWindow('http://www.phpfreaks.com/forums/index.php?showtopic=87846','','scrollbars=yes')">click this link</a></p>
    <p>&nbsp;</p>
    <p>try downloading dreamweaver 8, it'll help. </p>
    </body>
    </html>
  4. [!--quoteo(post=353360:date=Mar 10 2006, 03:59 AM:name=realjumper)--][div class=\'quotetop\']QUOTE(realjumper @ Mar 10 2006, 03:59 AM) [snapback]353360[/snapback][/div][div class=\'quotemain\'][!--quotec--]

    Just as an aside.....doesn't ORDER BY rand() do the same as shuffle()? If so, what's the point of having both? If not, what's the difference in the end result?

    [/quote]

    err... one is supported by MySql and the other one is php???

    but than this is what pop-up in dreamweaver:

    [!--coloro:#FF9900--][span style=\"color:#FF9900\"][!--/coloro--]rand([int min], int max)

    shuffle(array array_arg)[!--colorc--][/span][!--/colorc--]

    hmmm, i know what is array. but, don't really know how to use them much.
  5. can some one help me please... i've been stuck here for roughly 2 days i'll be happy if some one can help me... below are the code generate by Dreamweaver about showing a repeted table showing all the 15 randomly pick name and a text field that submit new name... can some one help me modify or show where i can get more example.


    <?php require_once('../Connections/activity.php'); ?>
    <?php
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
    {
    $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

    switch ($theType) {
    case "text":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "long":
    case "int":
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
    break;
    case "double":
    $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
    break;
    case "date":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "defined":
    $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
    break;
    }
    return $theValue;
    }

    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
    $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
    $insertSQL = sprintf("INSERT INTO temp_class (temp_name) VALUES (%s)",
    GetSQLValueString($_POST['temp_name'], "text"));

    mysql_select_db($database_activity, $activity);
    $Result1 = mysql_query($insertSQL, $activity) or die(mysql_error());

    $insertGoTo = "untitled.php";
    if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
    }
    header(sprintf("Location: %s", $insertGoTo));
    }

    mysql_select_db($database_activity, $activity);
    $query_rand_pick = "SELECT student.name FROM student ORDER BY RAND() LIMIT 15";
    $rand_pick = mysql_query($query_rand_pick, $activity) or die(mysql_error());
    $row_rand_pick = mysql_fetch_assoc($rand_pick);
    $totalRows_rand_pick = mysql_num_rows($rand_pick);
    ?>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>

    <body>
    <table border="1" cellpadding="0" cellspacing="0">
    <tr>
    <td>name</td>
    </tr>
    <?php do { ?>
    <tr>
    <td><?php echo $row_rand_pick['name']; ?></td>
    </tr>
    <?php } while ($row_rand_pick = mysql_fetch_assoc($rand_pick)); ?>
    </table>
    <p>&nbsp;</p>
    <p>&nbsp;</p>

    <form method="post" name="form1" action="<?php echo $editFormAction; ?>">
    <table align="center">
    <tr valign="baseline">
    <td nowrap align="right">Temp_name:</td>
    <td><input type="text" name="temp_name" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">&nbsp;</td>
    <td><input type="submit" value="Insert record"></td>
    </tr>
    </table>
    <input type="hidden" name="MM_insert" value="form1">
    </form>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    </body>
    </html>
    <?php
    mysql_free_result($rand_pick);
    ?>
  6. Hi there, I'm working with my project where I need to randomly pick data from a question database and place all the question that got lucky to a preview page to be printed if applicable.

    So, i manage to randomly pick 50 question randomly with a bank of 100 objective questions using SQL

    select * from question order by rand() limit 50

    [!--coloro:#FF6600--][span style=\"color:#FF6600\"][!--/coloro--]I'm having some problem in my printing part [!--colorc--][/span][!--/colorc--]...

    What i need to do with the printed page is to include a header of the Subject Code at the upper right of every page and bottom left the page number with the format of (current_page of total page)...

    My Standard Question paper page will have the margin of 1 inch on top , a margin of 2 inch for left and right, and a margin of 3 inch from the bottom...


    ~n00bie in programming and web building~
    I started to code in php and web building less than a week with the help of Dreamweaver 8... at list the php part was not so complicated as web building. feels like coding in c or java again...
×
×
  • 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.