validation check, between and wildcard
Moderator: General Moderators
validation check, between and wildcard
i need some code to check if a variables are betwen a certain date and then check another variable to check if it begines with an "A":
E.G
$var=12-mar-06
$var2=13-mar-06
$var3=14-mar-06
$varcode= A3321
if $var2 is between $var and $var3
and if $varcode = A* (* being a wildcard)
then
echo 'validation complete'
else die('error message')
cheers
E.G
$var=12-mar-06
$var2=13-mar-06
$var3=14-mar-06
$varcode= A3321
if $var2 is between $var and $var3
and if $varcode = A* (* being a wildcard)
then
echo 'validation complete'
else die('error message')
cheers
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Have you picked up any tutorials or books yet? A lot of what you are asking are things covered by tutorials and PHP books. Just a suggestion...
For date ranges, you need to identify what you upper and lower limits are (just like for any BETWEEN type comparison), then identify what your checking, the check it...
As for the first letter checker, look at strpos().
For date ranges, you need to identify what you upper and lower limits are (just like for any BETWEEN type comparison), then identify what your checking, the check it...
Code: Select all
<?php
$enddate = strtotime('January 5, 2007');
$startdate = strtotime('November 10, 2005');
$checkdate = time();
if ($checkdate < $enddate && $checkdate > $startdate)
{
//We are between the date range limits
}
else
{
//We are not
}
?>feyd | Please use
i need to name the "check box" as the GRN number for the name
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
[quote="Everah"]Have you picked up any tutorials or books yet? A lot of what you are asking are things covered by tutorials and PHP books. Just a suggestion...
[/quote]
ha, yeah i know, i'm just really lazy...sorry about that, anyway this one i really have tried to find the answer to, in my little php book i got but cant:Code: Select all
$bg = '#eeeeee'; // Set the background color.
while ($row = odbc_fetch_array($result, OBDC_ASSOC)) {
$bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); // Switch the background color.
echo '<form name="form1" method="post" action="">';
echo '<tr bgcolor="' . $bg . '">
<td align="left"><input type="checkbox" name="checkbox" value="checkbox"></td>
<td align="left">' . $row['GRN_NUMBER'] . '</td>
<td align="left">' . $row['ITEM_NUMBER'] . '</td>
<td align="left">' . $row['ORDER_NUMBER'] . '</td>
<td align="left">' . $row['STOCK_CODE'] . '</td>
<td align="left">' . $row['DESCRIPTION'] . '</td>
<td align="left">' . $row['DATE'] . '</td>
<td align="left">' . $row['QTY_RECEIVED'] . '</td>
</tr>';
echo '</form>';feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Change this...
to this...
Code: Select all
<input type="checkbox" name="checkbox" value="checkbox">Code: Select all
<input type="checkbox" name="{$row['GRN_NUMBER']}" />Code: Select all
$bg = '#eeeeee'; // Set the background color.
while ($row = odbc_fetch_array($result, OBDC_ASSOC)) {
$bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); // Switch the background color.
echo '<form name="form1" method="post" action="">';
echo '<tr bgcolor="' . $bg . '">
<td align="left"><input type="checkbox" name="$row['GRN_NUMBER']" /></td>
<td align="left">' . $row['GRN_NUMBER'] . '</td>
<td align="left">' . $row['ITEM_NUMBER'] . '</td>
<td align="left">' . $row['ORDER_NUMBER'] . '</td>
<td align="left">' . $row['STOCK_CODE'] . '</td>
<td align="left">' . $row['DESCRIPTION'] . '</td>
<td align="left">' . $row['DATE'] . '</td>
<td align="left">' . $row['QTY_RECEIVED'] . '</td>
</tr>';
echo '</form>';Code: Select all
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in d:\Inetpub\wwwroot\batch2.php on line 117"<td align="left"><input type="checkbox" name="$row['GRN_NUMBER']" /></td>"
i can 't see where the ; would go, can anyone help?
cheers
sorry the code doesn't match to Everahs, as i said i have been trying to fix the code, at the start i copy and pasted the code into my code.Pimptastic wrote:I think you should read Everahs post again and do EXACTLY what he said.
The syntax highlighting kinda gives it away
anyway with this code
Code: Select all
$bg = '#eeeeee'; // Set the background color.
while ($row = odbc_fetch_array($result, OBDC_ASSOC)) {
$bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); // Switch the background color.
echo '<form name="form1" method="post" action="">';
echo '<tr bgcolor="' . $bg . '">
<td align="left"><input type="checkbox" name="{$row['GRN_NUMBER']}" /></td>
<td align="left">' . $row['GRN_NUMBER'] . '</td>
<td align="left">' . $row['ITEM_NUMBER'] . '</td>
<td align="left">' . $row['ORDER_NUMBER'] . '</td>
<td align="left">' . $row['STOCK_CODE'] . '</td>
<td align="left">' . $row['DESCRIPTION'] . '</td>
<td align="left">' . $row['DATE'] . '</td>
<td align="left">' . $row['QTY_RECEIVED'] . '</td>
</tr>';
echo '</form>';"Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in d:\Inetpub\wwwroot\batch2.php on line 117 "
Well, you could try doing it the way you have with all your other $row variables. That's what i would do.
Code: Select all
echo '<tr bgcolor="' . $bg . '">
<td align="left"><input type="checkbox" name="' . $row['GRN_NUMBER'] . '" /></td>
<td align="left">' . $row['GRN_NUMBER'] . '</td>
<td align="left">' . $row['ITEM_NUMBER'] . '</td>
<td align="left">' . $row['ORDER_NUMBER'] . '</td>
<td align="left">' . $row['STOCK_CODE'] . '</td>
<td align="left">' . $row['DESCRIPTION'] . '</td>
<td align="left">' . $row['DATE'] . '</td>
<td align="left">' . $row['QTY_RECEIVED'] . '</td>
</tr>';- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA