Gavski
Members-
Posts
13 -
Joined
-
Last visited
Everything posted by Gavski
-
Well, I now have value $box2[0] successfully stored as a $var. this will allow me to finish building the page and others that use similar. seems my mistake was thinking $new_var = $_POST['box2']; made $new_var as a string but it's not, it's an array that can then be imploded. I have learned a lot from this, but most of all how good ppl will hep you out if you get stuck. so many cheers for all the help and thanks for your patience.
-
Great, nearly there? page source now shows $id values, printf('<pre>%s</pre>', print_r($_POST, true)); returns - Array ( [box2] => Array ( [0] => 5 ) I now have the value i want in box2 array. Final problem I cant seem to the value out of box2 array? eg $new_var = $box2[0]; echo $new_var; doesnt work, also echo count($box2); returns 0 I really need to get $box2[0] as a var, I've tried implode() but get invalid parameter error??? thanks
-
no, the checkbox doesn't display a value but the displayed list does display a value for $id, therefore $id definitely does have a value but the checkbox doesn't seem to wan to post it, this is my problem. cheers and thanks for your patience
-
also, If I substitute $id in the 'value' of the checkbox with a static value( eg 1,2 or A,B) box2[ ] posts this value fine.
-
sorry, I simplified the form to post it on here and the ,"] were the end of another set of values. The check box's do appear ok, one along side each record that is displayed but when I tick a check box the box2[ ] array fails to post the 'value' $id.
-
This doesn't work?? when a checkbox is checked, and the form posted, the posted value $_POST['box2'] is null, I am expecting it to hold the value $id for the record associated wit it?
-
I'm trying to display an array in HTML and next to each record is a checkbox, as below. I then want to be able to select a record by checking the checkbox and posting the 'value' of box2[ ] for that record. The problem I am having is the checkbox doesn't seem to post the value ($id), it only seems to handle static values (1,2,3 etc) instead of a string. Any ideas how to work this, or suggesions for marking an individual record to then post it's id? thanks $linkid=dbconnect("db"); mysql_select_db("db"); if(!($result = mysql_query("SELECT * FROM table WHERE id = '$id'"))) die ("Result error"); { echo "<table>\n"; while ($myrow = mysql_fetch_array($result)) { printf("<tr><td>%u</td><td><input type='checkbox' name='box2[ ]' value='$id'></td><td>%s</td><td>%s</td></tr>\n", $myrow["id"],$myrow["descr"],$myrow["batno"],"]); } echo "</table>\n"; }//endwhile }//endif
-
Thanks Cyber Robot, Managed to do this from your help and it works fine. $num_results = mysql_num_rows($result); if($num_results > 0) returns 0 if no records found. Also Barand, I have gone through my function and amended it (I kind of knew globals were a bad thing), now running like a well oiled address book, thanks for all help and tips
-
This is a function that searches an address DB, compares the $name with 'LIKE' and returns the address details. If no address is found, I want to go to another function. In my form, if I leave $name blank it works, but if I put a $name that is not in the database, $result still returns a value and doesn't seem to recognize that there is no record?? any ideas, thanks. <?php function getsupp() { global $name,$address1,$address2,$address3,$address4,$pcode,$email; mysql_select_db("picture_cards"); $result = mysql_query("SELECT * FROM supplier WHERE name LIKE('$name%')") or die(mysql_error()); if($result ){ while($row = mysql_fetch_array($result)) { $name = $row['name']; $address1 = $row['address1']; $address2 = $row['address2']; $address3 = $row['address3']; $address4 = $row['address4']; $pcode = $row['pcode']; $email = $row['email']; }//endwhile }//endif }// endfunc getsupp() ?>
-
Thanks, that's great, Ive found a similar but simpler solution - if ($_SERVER["REQUEST_METHOD"] == "POST") { myfunction(); } test whether a post has been made (in pre hypertext process.) thanks again.
-
Sorry here it is again without the glaring error - <?php session_start(); $_SESSION['regName'] = $regValue; $token = 0; //here's the function function doThis() { echo "Do this Function";} if ($token = 1) { doThis(); } $token = 1; echo $token; ?> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" > <input type="text" name="regName" value=""> <input type="submit"> </form>
-
Here's my form, it contains a function (really!). I want this function to work only after the form has been posted (not on initial loading). Here PHP reads the value of $token inside the function on loading (setsit to 1) and so executes the function when the page is loaded, there must be a way round this? <?php session_start(); $_SESSION['regName'] = $regValue; $token = 0; //here's the function function doThis() { echo "Do this Function";} if ($token = 1) { doThis(); $token = 1; } echo $token; ?> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" > <input type="text" name="regName" value=""> <input type="submit"> </form>
-
I have a form that contains a function. i want this function to be activated only when the user reposts the page to itself. (php_self). ie. the user access the page and the function is hidden, the user then inputs data, repost the page and the function is activated. I've tried flagging the function with a variable - $var = 0, then $var = 1 at the end of the page but $var just resets itself to 0 when the page is posted. Sure this is simple but I just cant get it? thanks