![](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
nikkieijpen
-
Posts
31 -
Joined
-
Last visited
Never
Posts posted by nikkieijpen
-
-
try this?:
function loadimages(){ var picsx = canvasX/4; var picsy = canvasy/2; var pic1 = document.createElement('img'); pic1.setAttribute("src", "img1.jpg"); pic1.style.left = picsx+"px"; pic1.style.top = picsy+"px"; var div = document.getElementById('button1'); div.appendChild(pic1); } <div id="button1"></div>
-
Javascript (put it in the 'head' tag):
<script language="javascript" type="text/javascript"> function saveForm(){ var confirmSaveBox = confirm("Do you wish to save?"); if(confirmSaveBox == true){ document.form1.submit(); } } </script>
HMTL:
<form name="form1" action="save.php"> <input type="button" value="Save!" onClick="saveForm();" /> </form>
-
use quotes around the letter in the hyperlink. Like this <a href='#' onclick="sndReqArg('A',1)"> Javascript will now read it as a string. If you do not use quotes, javascript will think it's a variable and will trow an error because it's not defined.
Use firefox's firebug. It's a very nice debugging tool, also for javascript!
-
var instance = "qty_" + i; if (document.getElementById(instance) != null) { notblank=1; }
-
I use FCK Editor
-
MadTechie is right. You have use a hidden field which contains a user ID so your scripts knows which record it has to update. Also put the table inside the form and add a submit button. You also have al your textfield named "age". Give every textfield a unique name. PHP will use that name to extract the value out of it. Once you submit the form it creates a $_POST['textfieldname'] variable to store in the value of that particular textfield.
Here's a code sample:
<form method="post" action="updateStats.php"> <table> <tr> <td>Age:</td> <td><input type="text" name="age" size="5" value="<?=$stat['age']?>" /></td> </tr> <tr> <td>Knowledge:</td> <td><input type="text" name="knowledge" size="5" value="<?=$stat['knowledge']?>" /></td> </tr> <tr> <td>Submit the form:</td> <td><input type="submit" name="sumbit" value="Submit" /><input type="hidden" name="userID" value="<?=$stat[userID]?>" /></td> </tr> </table> </form>
updateStats.php:
<?php if(isset($_POST['userID'])) { $knowledge = $_POST['knowledge']; $usID = $_POST['userID']; $age = $_POST['age']; mysql_query("UPDATE table SET knowledge = 'knowlegde', age = '$age' WHERE userID = '$usID'"); } ?>
-
<?php $time1 = "14:00:03"; $time2 = "12:30:03"; echo (strtotime($time1) - strtotime($time2)); // displays the time difference in seconds. ?>
-
$fd = fopen($filename, 'r') or die("Can't Open File"); $contents = fgets($fd); fclose($fd); echo $contents;
-
This creates a string of 8 characters long, extracted from a md5 hash of the Employee Number.
<?php $name = array("ZEINA MORRIS", "LEANNE DENNIS", "NICKY BROPHY"); $employee_number = array("A393", "A394", "A493"); $password_length = 8; for ($i=0; $i < count($name); $i++){ $pass = md5($employee_number[$i]); $password = substr($pass,rand(0,strlen($pass)-$password_length),$password_length); mysql_query("INSERT INTO cms_users (name, employee_number, pin_code) VALUES ('$name[$i]', '$employee_number[$i]', '$password')") or die(mysql_error()); } ?>
-
Try seperate functions and invoke the filenamecreator function from the first and let de filenamecreator return the filename to the first function which stores the returned filename in a variable:
function filenamecreator() { $chars = "abcdefghijkmnopqrstuvwxyz023456789"; srand((double)microtime()*1000000); $i = 0; $newfilename = '' ; while ($i <= 7) { $num = rand() % 33; $tmp = substr($chars, $num, 1); $newfilename = $newfilename . $tmp; $i++; } return $newfilename; } function addLogFile() { $flag = 0; while ($flag == 0) { $flag = 1; $newfilename = filenamecreator(); $get_otherfilenames = mysql_query("SELECT * FROM logfileinfo"); $num=mysql_numrows($get_otherfilenames); $count = 0; while ( $count < $num ) { $otherfilename = mysql_result($get_otherfilenames, $count, "filename"); if ( $newfilename == $otherfilename ) { $flag = 0; } $count++; } } $add_logfile = mysql_query("INSERT INTO logfileinfo (hotelID, filename) VALUES ('$hotelID','$newfilename')"); }
-
Javascript:
function doSomething(value) { url = "customers.php?letter="+value; req.open('get', url); req.onreadystatechange = handleResponse req.send(null); }
HTML:
<a href="javascript:doSomething('A');">Click Here</a>
-
cookie example:
if(!isset($_COOKIE["mailsent"])) { $mail = mail($to, $subject, $msg, "From: $fname $lname<$email>"."\r\n"."CC:test2@domain.com"); if($mail) { setcookie("mailsent", "1", time()+3600); } }
-
Date:
<INPUT NAME="web_date" TYPE="text" ID="web_date" VALUE="<?php echo date("Y-m-d", strtotime($web_time)); ?>" SIZE="48">
Time:
<INPUT NAME="web_date" TYPE="text" ID="web_time" VALUE="<?php echo date("H:i:s", strtotime($web_time)); ?>" SIZE="48">
-
Javascript:
function createXMLHttpRequest() { var ua; if(window.XMLHttpRequest) { // if not using IE try { ua = new XMLHttpRequest(); } catch(e) { ua = false; } } else if(window.ActiveXObject) { // if using IE try { ua = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { ua = false; } } return ua; } var req = createXMLHttpRequest(); function doSomething(value) { url = "script.php?variable="+value; req.open('get', url); req.onreadystatechange = handleResponse req.send(null); } function handleResponse() { if(req.readyState == 4) { var response = req.responseText; div = document.getElementById('gridDiv'); div.innerHTML = response; } }
HTML:
<select name="selectName" id="selectName" onChange="doSomething(this.value);"> <option value="blaat">Blaat</option> <option value="blaat2">Blaat2</option> </select> <div id="gridDiv"></div>
PHP
if(isset($_GET) { $var = $_GET['variable']; // do mysql execution here $textToReturn = // put anything you want to display in the grid in a variable echo $textToReturn; } else { $textToReturn = "No variables are set." echo $textToReturn; }
-
Ajax = Asynchronous Javascript and XML
Javascript is required for Ajax implementation, so when people disable javascipt it can't work
-
If they didn't upload a photo the the value stored in the database field 'photo1' really is 0 or is it empty?
if it's empty:
<?php if(empty($photo1)) { switch ($gender) { case "male": echo "<img src='uploads/no_pic_male.jpg' />"; break; case "female": echo "<img src='uploads/no_pic_female.jpg' />"; break; default: echo "<img src='uploads/no_pic.jpg' />"; break; } else { echo "<img src='uploads/$photo1' border='0' />"; } ?>
If it's 0 just leave the if statement as you already had it.
-
What is the error you're getting?
Take a look at this code:
<form action="<?= $_SERVER['PHP_SELF'] ?>" method="post"> Enter your folder name <input type="text" name="name" /> <input type="submit" /> </form> //does the dir already exist <?php $name =$_POST['name']; $filename = '/guests/$name'; if (!file_exists($filename) && !isset($_POST['submit'])) { // the ! means 'not'; The $_POST['submit'] has a value (or: is set) when the submit button is being clicked.... This means that when the button is clicked the directory will not be created. mkdir("/guests/$name", 0777); echo "Your folder was created"; } else { echo "The foldername already exists"; } ?>
-
Two ways:
1. you can count unique visits by IP addresses. If an IP address is already logged, don't log it.
2. use sessions. If a visit is being logged, set a session variable to 'logged' (or whatever you like). Don't log a visit when the session has that value.
-
<a href=""><img src=" . $row['stg1'] . " class="float" /></a>"
-
$usdate = date("m/d/Y"); $ukdate = date("d/m/Y", strtotime($usdate));
-
maybe this helps (I'm not sure)
session_start(); if (isset($_POST['txtusername'])) $_SESSION['test'] = $_POST['txtusername']; session_register('test');
-
is the textfield and the button put in a form?
<td><input type="text" name="tsdate" value="" id="data" size="12" disabled="true"> <input type="submit" id="trigger" name="trigger"></td>
-
This code only works if you only store the highest score, not if you want a list if i.e. the ten highest scores. However, this script might help you further...
if(isset($_GET) { $score= $_GET['score']; $username = $_GET['name']; $file = "http://localhost/test/highscore.txt"; //contains i.e. "Username,Highscore"; $fh = fopen($file, "r"); $content = fread($file); fclose($fh); $content = explode(",",$content); $highScore = $content[1]; if($score > $highScore) { $fh = fopen($file, "w"); $newContent = $username.",".$score; fwrite($fh, $newContent); fclose($fh); }
-
1. No, only showing the details
2. You put the <a href=..... in the while loop
3. No, The difference between GET and POST is in the way of sending data to the page, while the GET method sends data using URL, the POST method sends them through the standard entrance STDIO.
Does every 'Personal Trainer' have an unique number (ID)? Or is Thumbnail unique? You need something unique to pass to the details page so the details page knows which trainer's details to show...
Try this code in your results page:
$query = "SELECT * FROM PersonalTrainers WHERE Postcode = '".$_POST['Postcode']."' AND Age = '".$_POST['Age']."' AND Sex = '".$_POST['Sex']."'"; $result=mysql_query($query); $row_result = mysql_fetch_assoc($result); mysql_close(); echo "<center>Personal Trainers</center>"; while ($row_result = mysql_fetch_assoc($result)) { echo '<center><a href="details.php?id='.$row_result['Thumbnail'].'">'.$row_result['Thumbnail'].'</a></center>'; }
Change in the details page:
$id = $_GET['Thumbnail'];
into:
$Thumbnail = $_GET['Thumbnail'];
cronjob and timer
in PHP Coding Help
Posted