nashsaint
-
Posts
84 -
Joined
-
Last visited
Never
Posts posted by nashsaint
-
-
Hi,
This is what I am trying to accomplish:
[] Male
[] Female
Simple tick boxes populated from sql but i just don't know how to do it.
I have the sql query and thinking of outputting it this way:
<form> <label for="maleID">malefromsql</label> <input type="radio" name="sex" id="maleID" /> <br /> <label for="femaleID">femalefromsql</label> <input type="radio" name="sex" id="femaleID" /> </form>
but i dont know how to pass the sql query result to a variable and finally output it .
Any help is appreciated greatly. thanks.
-
Hi,
is there a way not to refresh a page after submitting a form? I've seen some js that can do this job but am wondering if there's a simple code to achieve this.
thanks in advance.
-
and this is the input:
<input type="submit" id="btn" value="Update" onclick="showMagicDiv();"/> -
well, the effects work fine but when i actually sent the input to sql the timeout seems to speed up. instead of 2 seconds it's now only displays half a second.
this is the code that does the sql update:
if (!function_exists("GetSQLValueString")) {function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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']);
}
$ts = time();
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
$updateSQL = sprintf("UPDATE jobs_tbl SET job_no=%s, job_date=%s, week_no=%s, job_country=%s, job_status=%s, job_result=%s, time_stamp=%s, job_notes=%s WHERE jobs_id=%s",
GetSQLValueString($_POST['job_no'], "text"),
GetSQLValueString($_POST['job_date'], "text"),
GetSQLValueString($_POST['week_no'], "text"),
GetSQLValueString($_POST['job_country'], "text"),
GetSQLValueString($_POST['job_status'], "text"),
GetSQLValueString($_POST['job_result'], "text"),
GetSQLValueString($ts, "text"),
GetSQLValueString($_POST['job_notes'], "text"),
GetSQLValueString($_POST['jobs_id'], "int"));
mysql_select_db($database_jobCon, $jobCon);
$Result1 = mysql_query($updateSQL, $jobCon) or die(mysql_error());
}
help please. thanks.
-
thanks for the idea. this is what i done so far.
Function:
<script type="text/javascript">function showMagicDiv() {
document.getElementById( "magic_div" ).style.display = 'block';
setTimeout("hideMagicDiv()", 2000);
}
function hideMagicDiv() {
document.getElementById( "magic_div" ).style.display = 'none';
}
</script>
and the HTML
<div id="container"><div id="magic_div">Am a Div with Timeout</div>
</div>
<form name="form1" method="post" action="">
<label>Note
<input type="text" name="text" id="text">
</label>
<label>
<input type="button" name="btn" id="btn" value="Submit" onClick="showMagicDiv();">
</label>
</form>
It works so far. ill have to add CSS yet.
-
Hi,
It's one of those twitter effects again, it's driving me mad for days. If you are using twitter then you noticed that everything you send a message, a div (i think it is) appears for 2 seconds on the very top of the page then disappears. I like this effect. Does anyone here know or have any idea how to do this? Cause I have a form and I'd like that effect to appear as soon as Submit button is pressed.
Thanks in advance for any help.
-
Thank you very much keith for the idea. This is what i done and it works great.
<html>
<head>
<style type="text/css">
<!--
#mainDiv {
height: 50px;
width: auto;
background-color: #039;
}
#hiddenDiv1 {
height: 50px;
width: auto;
background-color: #960;
}
-->
</style>
<!-- trigger script. -->
<script type="text/javascript" language="JavaScript"><!--
function HideDIV(d) { document.getElementById(d).style.display = "none"; }
function DisplayDIV(d) { document.getElementById(d).style.display = "block"; }
//--></script>
</head>
<body>
<div id="mainDiv" onmouseover="HideDIV('mainDiv');DisplayDIV('hiddenDiv1')" onmouseout="HideDIV('hiddenDiv1');DisplayDIV('mainDiv')">
<p >This is the main div</p>
</div>
<div id="hiddenDiv1" style='display:none' onmouseover="HideDIV('mainDiv');DisplayDIV('hiddenDiv1')" onmouseout="HideDIV('hiddenDiv1');DisplayDIV('mainDiv')">
<p>This is Hidden Div 1. <a href="link1.php">Link 1</a>. <a href="link2.php">Link 2</a></p>
</div>
</body>
</html>
-
hi,
ive noticed the effects on the messages posted on twitter, when you hover the messages it displays another div, i think, with links on it: link to add as favorite or delete. does anyone knows how to add the link on hovering divs, or anything similar?
thanks.
-
hi keith,
It works!!!!
I am very greatful for this. thanks a lot keith..
-
and this is the script.
<?php require_once('../Connections/dbcon.php'); ?><?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}
$maxRows_crPercent = 10;
$pageNum_crPercent = 0;
if (isset($_GET['pageNum_crPercent'])) {
$pageNum_crPercent = $_GET['pageNum_crPercent'];
}
$startRow_crPercent = $pageNum_crPercent * $maxRows_crPercent;
mysql_select_db($database_dbcon, $dbcon);
$query_crPercent = "SELECT a.fname, (GoodResult / (GoodResult + BadResult)) * 100 Percentage FROM (SELECT fname, count(*) GoodResult FROM logs WHERE lresult = 'Good' GROUP BY fname) a INNER JOIN (SELECT fname, count(*) BadResult FROM logs WHERE lresult = 'Bad' GROUP BY fname) b ON a.fname = b.fname ORDER BY Percentage DESC";
$query_limit_crPercent = sprintf("%s LIMIT %d, %d", $query_crPercent, $startRow_crPercent, $maxRows_crPercent);
$crPercent = mysql_query($query_limit_crPercent, $dbcon) or die(mysql_error());
$row_crPercent = mysql_fetch_assoc($crPercent);
if (isset($_GET['totalRows_crPercent'])) {
$totalRows_crPercent = $_GET['totalRows_crPercent'];
} else {
$all_crPercent = mysql_query($query_crPercent);
$totalRows_crPercent = mysql_num_rows($all_crPercent);
}
$totalPages_crPercent = ceil($totalRows_crPercent/$maxRows_crPercent)-1;
?>
<!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=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<table border="0">
<tr>
<td>fname</td>
<td>Percentage</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_crPercent['fname']; ?></td>
<td><?php echo $row_crPercent['Percentage']; ?></td>
</tr>
<?php } while ($row_crPercent = mysql_fetch_assoc($crPercent)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($crPercent);
?>
-
Hi Keith,
sorry, It's working now. I just mistyped the field name when i echo it. I have one problem though. It doesn't show the ones with 100% result.
(GoodResult / (GoodResult + BadResult)) * 100The ones with 0 BadResult is not displayed in the output.
Thanks again Keith. You've helped me alot already.
-
Hi Keith,
you're right. I changed the double with single quote and it works. However, the output is only showing one record. In my phpadmin I have about a hundred. Sorry for the trouble Keith, really don't know how to sort this out.
Thanks.
-
Keith,
I tested it on phpadmin as well and it works fine but when i run the .php file i get this error:
Parse error: parse error in C:\wamp\www\percent.php on line 5line 5 is the start of the query.
-
thanks a lot Keith but I get a parse error?
-
yes,
.. yes.are you saying "lresult" is a field containing either "good" or "bad?"
You can use sub queries if thats the case
can you please show me a sample query? thanks.
-
you're right. real problem is how to separate the "good" from "bad" and then divide the "good" from over all total.
I tried this:
SELECT count(lresult) / count(lresult) * 100, fname FROM logs_tbl WHERE lresult = 'good' GROUP by fnamebut that mean only counting the ones with good result.
am thinking:
SELECT count(lresult="good") / count(lresult) * 100, fname FROM logs_tbl GROUP by fnamebut i doubt it's going to work.
-
Problem: calculate percentage in one sql query.
Table: logs_tbl
fields:
fname = varchar
lresult = varchar (either "good" or "bad" entries)
I tried making query but my knowledge is not great so i failed.
this is the formula i reckon is gonna be like but couldn't
translate it into sql query:
(lresult with "good" entries) / (all lresult entries) * 100
grouped by fname.
I only want the percentage for "good" entries.
any help is greatly appreciated. thanks.
-
works like a charm... thanks neil.johnson.
-
Hi,
Purpose: to echo an image. filename is stored in sql (e.g., mypix.jpg), and actual images stored inside images/ folder.
sql query:
mysql_select_db($database_cr, $cr);$query_topThree = "SELECT logs.eng_name, eng_names.eng_img FROM logs, eng_names WHERE eng_names.eng_name = logs.eng_name LIMIT 3";
$topThree = mysql_query($query_topThree, $cleanroom) or die(mysql_error());
$row_topThree = mysql_fetch_assoc($topThree);
My echo so far:
<?php echo "<img src='images/'" . $row_topThree['eng_img']; ?>Result: didn't work. nothing is displayed.
Your help is greatly appreciated.
-
no, i mean a:selected.
my a:active works fine as the link turns into italics when i click on it. but when the site is displayed after the click, the links goes back to a:link state instead of a:visited.
-
Hi,
I have a problem with my menu, it's only a simple text menu with simple text decorations. the link, hover and active works but the selected doesn't. When a link is clicked it only shows the "a" state.
This menu is saved on header.php which is then called by pages using php include command.
#navbar a {font-family: Verdana, Geneva, sans-serif;
color: #FFF;
text-decoration: none;
}
#navbar a:hover {
text-decoration: underline;
color: #202020;
}
#navbar a:active {
color: #333;
font-style: italic;
}
#navbar a:selected {
color: #202020;
text-decoration: underline;
}
help is greatly appreciated.
thanks.
-
the index.php yes but the profile.whatever.php is not known. what is shown is the source page which is the index.php.
-
This is very common on php sites but i dont know how to do it. Ive already searched for this but couldn't find the solution.
Like this site for example it uses this link to access profile page without displaying the actual php filename.
How should i do this?
Say, i have an index.php and want to access contact.php without displaying the actual location on hover or address bar.
help is much appreciated. thanks.
-
thanks a lot for your help. it worked but i have another problem. sorry if i didn't mention it beforehand.
This is how i'm hoping the result would look like:
and if i group it by month it produced a different result. I tried grouping it in Firstname but now the count result counts everything from the database and doesn't separate by month.
how to get file title tag
in PHP Coding Help
Posted
Hi,
I am not sure if this is possible but ill ask it anyway. I searched the web and this forum for any solution but unfortunately i couldn't find a solution. What i want to accomplish is this. I am trying to read the file's tag, or whatever you call it. I managed to read the filename, size and other information that $_FILES function gives. But there is one thing i couldn't extract from the file tags, the "title". How can i do this?
I have attached a picture to help explain what i meant.
[attachment deleted by admin]