Page 1 of 1

validation check, between and wildcard

Posted: Thu Jul 27, 2006 10:35 am
by FE
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

Posted: Thu Jul 27, 2006 10:42 am
by RobertGonzalez
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...

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
}
?>
As for the first letter checker, look at strpos().

Posted: Thu Jul 27, 2006 11:20 am
by FE
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>';
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]

Posted: Mon Jul 31, 2006 9:46 am
by FE
sorry about that feyd

going to bump this to see if anyone can help me
cheers

Posted: Mon Jul 31, 2006 9:38 pm
by RobertGonzalez
Change this...

Code: Select all

<input type="checkbox" name="checkbox" value="checkbox">
to this...

Code: Select all

<input type="checkbox" name="{$row['GRN_NUMBER']}" />

Posted: Tue Aug 01, 2006 3:43 am
by FE

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>';
I've been messing around with this for ages and keep getting the error:

Code: Select all

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in d:\Inetpub\wwwroot\batch2.php on line 117
line 117 is

"<td align="left"><input type="checkbox" name="$row['GRN_NUMBER']" /></td>"

i can 't see where the ; would go, can anyone help?
cheers

Posted: Tue Aug 01, 2006 3:46 am
by JayBird
I think you should read Everahs post again and do EXACTLY what he said.

The syntax highlighting kinda gives it away

Posted: Tue Aug 01, 2006 3:49 am
by FE
Pimptastic wrote:I think you should read Everahs post again and do EXACTLY what he said.

The syntax highlighting kinda gives it away
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.

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>';
i still get the error:

"Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in d:\Inetpub\wwwroot\batch2.php on line 117 "

Posted: Tue Aug 01, 2006 3:53 am
by JayBird
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>';

Posted: Tue Aug 01, 2006 4:03 am
by FE
yeah cheers it worked
thanks

Posted: Tue Aug 01, 2006 8:52 am
by RobertGonzalez
You know, Pimps way is a lot better than mine. Glad you got it working.