i have a problem here..
i have a submit form...with textboxes and a combobox...
the combobox contains a list of ID's like A1,B1 and C1...
let say i select A1 and click submit...
then the second form appear...
FYI,at the earlier submit form,i did a substr function after select the A1...
i want to cut only the "A"...
the purpose is at the second page,the A from the substr,will be used...
the second page contains a combobox with list of ID's like A2,A3,B2,B3...
so,when i choose A1 from the submit page,the combobox at the second page will allow me to choose only IDs starting with A...and same with B1 or C1..
and i have problem at the second page..
the combobox has nothing to choose...
i wonder whats wrong...
how to do this?
i mean how to do a substr at the first page,and then use the cut item to compare it with the other item at the second page?
substr(let say A)-->post to 2nd page-->use the A to display records starting with A only
do u understand what i'm trying to do?
sorry for my bad english...
i'm trying to talk here...
pls help....
passing data and substr...HELP!!!!!!!!!!!!
Moderator: General Moderators
-
fastfingertips
- Forum Contributor
- Posts: 242
- Joined: Sun Dec 28, 2003 1:40 am
- Contact:
You have many ways to do that; one possibility is to take what in that string to his first break. Other way is to convert the string to an array and to take first part (this is the easy way) for that you have to use something like this:
Here you will find the functions that you may need to solve this in other ways:
http://ro2.php.net/strings
Code: Select all
<?php
$str = "Hello friend, you're
looking good today!";
$a = str_word_count($str, 1);
$b = str_word_count($str, 2);
$c = str_word_count($str);
print_r($a);
print_r($b);
print $c;
//Output may look like:
Array
(
[0] => Hello
[1] => friend
[2] => you're
[3] => looking
[4] => good
[5] => today
)
?>http://ro2.php.net/strings
....
thanks for your reply fingertips....
but i wanna do substr to item taken from mysql...
heres my code snippet...
at the submit page..
at the second page..i use the cut item from the substr function earlier...
but it seems i failed to do that...
what is the problem?
how to fix my code?pls help!!!!!!!!!!!!
but i wanna do substr to item taken from mysql...
heres my code snippet...
at the submit page..
Code: Select all
//----------------------------------------------------
$query2 = "Select idMajor from ".$DBprefix." tPartMinor where idmajor <>'' group by idmajor order by idmajor";
$mesin = mysql_query($query2);
while ($dbq = mysql_fetch_array($mesin)) {
echo("<OPTION VALUE=$dbqїidMajor] selected>$dbqїidMajor]</option>\n");
$ayam=$dbqїidMajor];
$depan=substr("$ayam",0,1);
}
?>
</select>
</td>
</tr>
</table>
<br><br>
<center>
<input type="hidden" name="ID" value="<?=$referNum?>">
<input type="hidden" name="hariIni" value="<?=$datToday?>">
<input type="hidden" name="front" value="<?=$depan?>">Code: Select all
$minor=@$HTTP_POST_VARSї"front"];
.
.
.
.
. <select name="idMinor" size="1">
<option value="0">ID Minor</option>
<?php
//----------------------------------------------------
// Access Data From MySQL
// TABLE : tPartMinor
//----------------------------------------------------
$query2 = "Select LEFT('idMinor',0) from ".$DBprefix." tPartMinor where LEFT('idMinor',0)='$minor'";
$result2 = mysql_query($query2);
while ($dbq2 = mysql_fetch_array($result2)) {
echo("<OPTION VALUE=$dbq2їidMinor] selected>$dbq2їidMinor]</option>\n");
}
?>
</select>what is the problem?
how to fix my code?pls help!!!!!!!!!!!!