laffin
Members-
Posts
1,200 -
Joined
-
Last visited
Everything posted by laffin
-
how about $narray=array_merge($array1,$array2); foreach($narray as $item) echo $item;
-
Please help me! Query results form another query
laffin replied to yandoo's topic in PHP Coding Help
<?php $step=isset($_POST['step'])?$_POST['step']:1; if($step==1) // Okay we start with step 1 our default { ?> <FORM METHOD="POST"><H2>Step 1</H2><BR> <INPUT TYPE="HIDDEN" NAME="step" value="2"> <INPUT TYPE="TEXT" Name="username" value="John Doe"> <INPUT TYPE="SUBMIT"> </FORM> <? elseif($step==2) { $username=$_POST['username']; ?> <FORM METHOD="POST"><H2>Step 2</H2><BR> <INPUT TYPE="HIDDEN" NAME="step" value="3"> <INPUT TYPE="HIDDEN" NAME="username" value="<?=$username;?>"> <INPUT TYPE="TEXT" Name="email" value="[email protected]"> <INPUT TYPE="SUBMIT"> </FORM> <? } else { <H2>Step 3</H2><BR> Username: <?=$_POST['username'];?> <BR> Email: <?=$_POST['email'];?><BR> } ?>[code] Okay quick example of what I mean. Step 1) Display form for Username Step 2) Save the username in a hidden field on the form, and ask for email Step 3) Display information from both steps above Step 1 does no processing Step 2 u can do processing before the form is displayed with the info from step 1 Step 3 is final processing this is where you want to update the database and do all the fun stuff [/code] -
ahhh, cuz it thinks the parameters are for itself. if u run do a print_r($_GET) in parse.php u will see what i mean. you can either rebuild the paramters in parse.php, not shure if u can use urlencode on this, might be worth a shot.
-
preg_replace("/[^a-zA-Z0-9 ]/ms", "", $data); you were matching the literal 's' i think u meant to use \s (whitespace) which includes \t \r \n and of cource space
-
toplays point is that php will stop with an error, cuz ya can't assigned a variable to a constant. thus having the constant on the left hand side of the comparisons. if($val=123) will not generate an error, as $val is assigned 123, and continue with whatever code is in the if statement if(123=$val) will generate an error, giving u a chance to fix it
-
Okay I didnt test this code (just typed it in as it came into my head). but this shud do it Using recursion it's just building a tree. first we build a function we can use for any level. and get our base/root nodes. function getnodes($parentid,$what="*") { nodes=array(); $res=mysql_query("SELECT $what from categegories where parentid=$parentid"); while($row=mysql_fetch_assoc($res)) $nodes[]=$row; return $nodes; } $root=getnodes(0,'cat_id'); now comes the fun recursive part adding child nodes function addchildren(&$node) { $node['child']=array(); $parentid=$node['cat_id']; $res=mysql_query("SELECT $what from categegories where parentid=$parentid"); while($row=mysql_fetch_assoc($res)) $nodes['child'][]=$row; foreach($node['child'] as $key => $val) addchild($node['child'][$key']); } $ok=true; foreach($root as $key => $node) addchildren($root[$key]); now u will have a tree with all the child nodes. displaying the tree even more fun is displaying the tree again recursion and a new array function buildtree($node,$level) { $marker=($level)?str_repeat('-',$level):''; $tree=array(); $ctr=0; foreach($node as $leaf) { $tree[$ctr][0]=$marker . $leaf['cat_name']; $tree[$ctr++][1]=$leaf['cat_id']; if(!empty($leaf['child']) { $branch=buildtree($leaf['child'],$level+1); $tree=array_merge($tree,$branch); } } return $tree; } $tree=buildtree($root,0); now u sould have an array in tree format ready for display $ctr=1; foreach($tree as $node) echo "$ctr) $node[0] ($node[1])<br>";
-
Please help me! Query results form another query
laffin replied to yandoo's topic in PHP Coding Help
Ahhh, i see where u are going now. U cant give a list of breeds unless the animal type is known. so on yer second form, which dusn yet update the db, u can keep them in hidden post fields. since u can get these post fields, u make a 2nd query SELECT * from breeds where AnimalTypeID=$_POST[AnimalType] now u can list the breeds for that animal type on the 2nd form (dropdown box or radio buttons) and submit to a 3rd script where u can take all the POSTs and do an db INSERT -
than u prolly have a windows based server. there is no which replacement. u can try looking thru phpinfo(); and see if u can find the php executable in there.
-
Please help me! Query results form another query
laffin replied to yandoo's topic in PHP Coding Help
SELECT * FROM animal LEFT JOIN breed on breed.animalTypeID=animalTypeID order by DESC AnimalID LIMIT 1 -
oops. replace find with which. <?php header("Content-type: text/plain"); echo "working path: ". get_cwd(); echo "php path: ". system("which php"); ?> had a brain burp.
-
[SOLVED] unable to start apache after using xampp installer
laffin replied to nderitk's topic in Apache HTTP Server
Cud be that Xampp is trying to start apache as a service, if you arent admin on the computer it will fail. you can either start it manually or install xampp from an admin capable acct -
u can always check where yer scripts are <?php header("Content-type: text/plain"); echo "working path: ". get_cwd(); echo "php path: ". system("find php"); ?> this shud work fine in linux environments, windows will fail on the find php command.
-
There is no reason not to use both, as Monkeh sez the Javascript can make it easier for users following the rules, while the php will catch those that dun want to play by the rules.
-
$provider = array("$_POST[provider]"); what u did here, is put "Array" into an array. since $_POST['provider'] is an array, php returns the string 'Array' basicly the same as doing this $provider=array('Array'); when all u needed was $provider=$_POST['provider'];
-
cuz it's an array. u have to loop through or implode the array.
-
<? function findlevel($exp){ $found = false; $arrayno = 0; $levels = array(0,250,500,750,1000,1500,2000,2500,3000,4000,5000,6000,7000,9000); $levelc = count($levels); $level=0; while($level < $levelc && $levels[$level]<$exp) $level++; return $level; } $level=findlevel(1234); echo($level); ?>
-
as the above example use full paths, than it dun matter where yer script is.
-
u can try. what u do is look at the headers provided by a normal browser and their VB Client. which is the most basic way. other ways, set up a cookie for , go to another page read the cookie back.
-
I prefer php validation over javascript anyhow. with javascript an end user may disable and alter the script. php they have no choice but go throught the validation process.
-
Most of this info is in the id3 tags of the mp3 already. Which u can retrieve directly. that is if u work exclusively with mp3's. and if u are attached to using the export function
-
that depends on your SQL creation for that field but it wud be easier if ur SQL was in date or datetime format. which makes building the query much easier than working with time() formats. use now() instead in the query and either date or datetime in the creation of yer table fields.
-
if your working with mp3's than it will be useful to pull information from the id3 tags. getid3 has such a tool for php
-
[SOLVED] C++ Programming Question
laffin replied to Ninjakreborn's topic in Other Programming Languages
system("pause"); shud work -
preg_match_all('@(.*)[\t\r\n]@',$sub,$matches); $matches[1] will contain the list of passwords