psyion
-
Posts
13 -
Joined
-
Last visited
Never
Posts posted by psyion
-
-
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"> </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> </p>
</body>
</html> -
sorry it was a double post.
-
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. -
<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> </p>
<p>try downloading dreamweaver 8, it'll help. </p>
</body>
</html> -
[!--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. -
i think the
$mkeyperson = ["name"];
in your link 44 should be
$mkeyperson = $_POST["name"];
-
thanks alot...
-
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> </p>
<p> </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"> </td>
<td><input type="submit" value="Insert record"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p> </p>
<p> </p>
</body>
</html>
<?php
mysql_free_result($rand_pick);
?>
-
here is my problem, i'm need to randomly pick 15 names from a table call student and store them to another table call temp_class
here is the random part
SELECT name
FROM student
ORDER BY RAND() LIMIT 15
but than how do i send this 15 names to temp_class????? -
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... -
Thanks man.... my problem solved....
so if the string is from my server.
i just need to add a nl2br().
<?php echo nl2br($row_rsQuestion['question']); ?>
instead of just
<?php echo $row_rsQuestion['question']; ?> -
i have the same problem too....
i can load strings from my server to my textarea with line breaks but not in to tables... the line breaks just.. Gone!
Need Help With The Date And Time Thing.
in PHP Coding Help
Posted
hmmm... now i got the idea of the code...
but, how do i change this and print it out as my local GMT? GMT+8:00 is my area