etsted
-
Posts
274 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by etsted
-
-
AJAX AND PHP
in PHP
i noticed something else, it doesnt show titel that does have a match.
-
AJAX AND PHP
in PHP
shoudnt this work?
if ($q !== ""){ $q=strtolower($q); $len=strlen($q);foreach($a as $name){if ( (strcmp(substr($name,0,$len), substr($q,0,$len)) ) == true){if ($hint===""){ $hint=$name; }else{ $hint .= "<br> $name"; }}}}Because it dont
In the DB i have 4 titels "6", "d", "green" and "nature" and if i type "n" then 6,d and green shows up then i try to type in "nature " (notice the space i put after nature) and then nature shows up at the end
-
AJAX and PHP
in PHP
Try changing
ajax.onreadystatechange() = function(){
to
ajax.onreadystatechange = function(){
whats the difference? show me an example
-
AJAX AND PHP
in PHP
ive tried to update it, and it almost work as i want i to but there are some small problems.
if ($q !== "") { $q=strtolower($q); $len=strlen($q); foreach($a as $name) { if (strcmp(substr($name,$len), substr($q,0,$len))) { if ($hint==="") { $hint=$name; } else { $hint .= "<br> $name"; } } } }
this script will shows you only what you search for, but if you search for "n"
and i have:
"green"
"nice tv"
then both of them will show, basically i want to make sure that when someone search for something the only matches should have what the user searched for at the beginning of the name, Not in the middle or the end or something like that.
-
AJAX AND PHP
in PHP
why does that matter?
its actually right above where i call it like include_once("connect.php");
-
AJAX AND PHP
in PHP
$type = $_REQUEST['type']; $sql = "SELECT tittel FROM $type GROUP BY titel"; $query = mysqli_query($con,$sql); while($row = mysql_fetch_array($query)) { $a[] = $row['titel']; } // get the q parameter from URL $q=$_REQUEST["q"]; $hint=""; // lookup all hints from array if $q is different from "" if ($q !== "") { $q=strtolower($q); $len=strlen($q); foreach($a as $name) { if (stristr($q, substr($name,0,$len))) { if ($hint==="") { $hint=$name; } else { $hint .= "<br> $name"; } } } } // Output "no suggestion" if no hint were found // or output the correct values echo $hint==="" ? "no suggestions" : $hint;exit();
this script is supposed to show suggested titels according to what the user is typing in.
But if i have several titel in the DB like this:
"my new name"
"name"
"new"
and i were to search "my new name" then all of the above titels will show, when only the first should.
-
AJAX and PHP
in PHP
i can see from here that the $_POST variables are not set, any clue?
function rate(username,rate_type,file_name){ var ajax = ajaxObj("POST", "watch.php"); ajax.onreadystatechange() = function(){ if(ajaxReturn(ajax) == true){ document.getElementById("rate_Box").innerHTML = ajax.responseText; } } ajax.send("rate_type="+rate_type+"&username="+username+"&file_name="+file_name); }
this is my AJAX
and this is my new PHP
if(isset($_POST['username'])) { $username = $_POST['username']; $file_name = $_POST['file_name']; $rate_type = $_POST['rate_type']; //check to see if the user has voted on this file before $sql = "SELECT rate_type,good_rate,bad_rate FROM rate WHERE username = '$username' && file_name = '$file_name'"; $query = mysqli_query($con, $sql) or die(mysqli_error($con)); $numrows = mysqli_num_rows($query); if($numrows != 1)//this means the user has not voted for this file before { $sql = "INSERT INTO rate VALUES('','$file_name','$username','$rate_type','','')"; $query = mysqli_query($con,$sql) or die(mysqli_error($con)); }// if else //this means it has voted before { //check to see what the user voted before $row = mysqli_fetch_array($sql); $DB_rate_type = $row['rate_type']; $DB_good_rate = $row['good_rate']; $DB_bad_rate = $row['bad_rate']; //if what the user wants to vote is not equal to what he voted before, continue... if($DB_rate_type != $rate_type) { if($rate_type === "good") { $DB_good_rate++; } else { $DB_bad_rate--; } $sql = "UPATE rate SET rate_type = '$rate_type' && good_rate = '$DB_good_rate' && bad_rate = '$DB_bad_rate' "; $query = mysqli_query($sql) or die(mysqli_error($con)); } else //else dont do nothing... { } } }
-
AJAX and PHP
in PHP
can u tell me what u want to do exactly..explain properly i may help u...!
I am trying to make a rating system.
-
AJAX and PHP
in PHP
<span onclick="rate('<?php echo $log_username;?>','good','<?php echo $file_url;?>')" onmouseout="normal(this)" onmouseover="green(this)"> Good </span> | <span onclick="rate('<?php echo $log_username;?>','bad','<?php echo $file_url;?>')" onmouseover="red(this)" onmouseout="normal(this)"> Bad </span> <span id="rate_Box"></span>
these are three divs. The two at the top are buttons. When you click on on of them they are supposed to trigger an AJAX function, but it doesnt work.
function rate(username,rate_type,file_name){ var ajax = ajaxObj("POST", "watch.php"); ajax.onreadystatechange() = function(){ if(ajaxReturn(ajax) == true){ document.getElementById("rate_Box").innerHTML = ajax.responseText; } } ajax.send("rate_type="+rate_type+"&username="+username+"&file_name="+file_name); }
i tried to use console.log on ajax.responseText, but nothing happened until i pressed one of the buttons, then it outputted "object is not a function".
here is the PHP it is supposed to communicative with, and all of there are in the same file.
if(isset($_POST['rate_type'])) { $username = $_POST['username']; $file_name = $_POST['file_name']; $rate_type = $_POST['rate_type']; //check to see if the user has voted on this file before $sql = "SELECT rate_type,good_rate,bad_rate FROM rate WHERE username = $username && file_name = $file_name"; $query = mysql_query($sql); $numrows = mysql_num_rows($query); if($numrows != 1)//this means the user has not voted for this file before { $sql = "INSERT INTO rate VALUES('','$file_name','$username','$rate_type')"; $query = mysql_query($sql); }// if else //this means it has voted before { //check to see what the user voted before $row = mysql_fetch_array($sql); $DB_rate_type = $row['rate_type']; $DB_good_rate = $row['good_rate']; $DB_bad_rate = $row['bad_rate']; echo "bra"; //if what the user wants to vote is not equal to what he voted before, continue... if($DB_rate_type != $rate_type) { if($rate_type === "good") { $DB_good_rate++; } else { $DB_bad_rate--; } $sql = "UPATE rate SET rate_type = $rate_type && good_rate = $DB_good_rate && bad_rate = $DB_bad_rate"; $query = mysql_query($sql); exit; } else//else dont do nothing... { exit; } } }
-
% difference
in PHP
Is there a function that allows me to compare two numbers, then give me the difference in %?
-
can somebody look at this link http://widegrass.com/watch.php?f=2014090332451907354600000047014883 then click on "about" under the picture and you will see that the "Titel" has to much margin-top even though i have not specified it
-
when i use this code for more usable code the facebook share and like buttons at the bottom disapear while the twitter share button statys
function random_files($name,$table) { //include a function used to get random files from the database echo "<h2>Random $name:</h2> "; include_once("functions.php"); echo get_random_files("$table"); echo "<br><br><br><br><br><br><br><br><br>"; } random_files("images","images"); random_files("audios","mp3"); random_files("videos","videos");
-
what functions would i use to create a live chat AJAX? or do i initiative echo functions in PHP? i can think of several ways to get there, but i dont have 2 computers so i woudnt be able to actually test it.
-
you could use cookies, where the timerfor the cookie is inside the DB, then change the value to a negative number
-
Seem to stack as they should to me.
when i add <br> tags before any <h2> tag the <br> tag doesnt have any effect
-
if i change the ext of a file for example a wmv file to mp4 will it run as a mp4 file? i tried it with HTML 5 but it didnt work, did i do something wrong?
-
when i try to add <br> before the h2 tags it doesnt have any effect.
-
at my website widegrass.com you can see that <h2> tags are not stacking properly. what wrong? i have tried to wrap all of the media file inside divs. i even used <br>
-
here is a link to my webpage widegrass.com
-
here i have a script that i run several times with a while loop bu every time the loop runs the next div has a higher margin-top than the next div
$videos .= "<div class='files' style='float:left; background:#eaeaea; width:150px; color: black;' id='file_".$id."'>n <a href='watch.php?f=".$file_url[0]."'><img src='$avatar' height='60' width='60' alt='$titel'> Click here</a> <br> <span style='float:left; text-overflow:ellipsis;'>Titel: $titel</span>n <br> <span>Uploaded by: <a href='user.php?u=$username'>$username</a></span> <br> <br> </div>n <br> <br>n";
-
// this makes every file name unique $fileName = $_FILES['Filedata']['name']; $kaboom = explode(".",$fileName); $ext = ""; $ext = end($kaboom); $ext = strtolower($ext); $fileName = date("YmdjzHhisu") . rand(10000000,99999999) . ".$ext"; // defines what the ext can be $imageTypes = array('jpg','jpeg','gif','png'); $videoTypes = array('mp4','webm','ogg','wmv'); $audioTypes = array('mp3','ogg','wav'); $title = $_POST['title']; $description = $_POST['description']; $username = $_POST['username']; // include DB connection include_once ("../connect.php"); // use the pathinfo to match the ext of the uploaded file $fileParts = pathinfo($_FILES['Filedata']['name']); $fileParts = $fileParts['extension']; $fileParts = strtolower($fileParts); if (in_array($fileParts,$imageTypes)) { // this is for images // insert into DB $sql = "INSERT INTO images VALUES('', '$title', '$description', '$username', '$fileName' , NOW(), '')"; $query = mysqli_query($con, $sql); move_uploaded_file($tempFile, "../u_image/" . $fileName); echo '1'; } else if(in_array($fileParts, $videoTypes)){ // this is for videos // insert into DB $sql = "INSERT INTO videos VALUES('', '$title', '$description', '$username', '$fileName' , NOW(), '')"; $query = mysqli_query($con, $sql); move_uploaded_file($tempFile, "../videos/" . $fileName); echo '1'; } else if(in_array($fileParts,$audioTypes)){ // this is for audios // insert into DB $sql = "INSERT INTO mp3 VALUES('', '$title', '$description', '$username', '$fileName' , NOW(), '')"; $query = mysqli_query($con, $sql); move_uploaded_file($tempFile, "../audio/" . $fileName); echo '1'; } else { echo "Invalid file."; }
this script is supposed to store images , videos and mp3. It only store images not mp3 or video file.
I have created the map for mp3 videos and images.
-
i dont find any functions for detecting browser type. I am trying to build an application so that depending on the users browser the HTML5 mediaplayer will use a different extension for the file being played.
-
get the properties of the page
-
CREATE TABLE IF NOT EXISTS comments ( id INT(11) NOT NULL, osid INT[11) NOT NULL, account_name VARCHAR(255) NOT NULL, author VARCHAR(255) NOT NULL, type ENUM NOT NULL, data TEXT, postdate DATETIME, PRIMARY KEY (id), )
It says i have an error at line 3
AJAX AND PHP
in PHP
Posted
why dont i put the % at the front?