Jump to content

URL help


vj5

Recommended Posts

I am trying to pass variable in URL. I am not getting the value as expected. Here is my URL link:<a href=pers-searchresult.php?groupno=$groupno&asofstart=$asofstart&asofend=$asofend>$groupname</a>This is how I retrieve the info in the next page.

if (isset($HTTP_GET_VARS['groupno'])) {   $groupno = $HTTP_GET_VARS['groupno'];} else {   $groupno = $_POST['groupno'];}if (isset($HTTP_GET_VARS['asofstart'])) {   $asofstart = $HTTP_GET_VARS['asofstart'];} else {   $asofstart = $_POST['asofstart'];}if (isset($HTTP_GET_VARS['asofend'])) {   $asofend = $HTTP_GET_VARS['asofend'];} else {   $asofend = $_POST['asofend'];}

When I echo the asofstart and asofend, I don't see the value. Can someone please help?

Link to comment
Share on other sites

The way your link looks, with php vars inside, I'm assuming that's the for it takes in a script, before it gets rendered in the browser. Well, it won't work. Major quotation and interpolation problems.Try this:

<a href="pers-searchresult.php?groupno=<?php echo $groupno ?>&asofstart=<?php echo $asofstart ?>&asofend=<?php echo $asofend ?>"><?php echo $groupname ?></a>

Or you could put the whole href value into a var and just use one echo statement, but the php mini-script will still have to come inside quote marks so the quotes get printed.

<?php $myHREF = "pers-searchresult.php?groupno=$groupno&asofstart=$asofstart&asofend=$asofend"; ?><a href="<?php echo $myHREF ?>"><?php echo $groupname ?></a>

Link to comment
Share on other sites

Now, it is working. But I have another problem. After retrieving the URL, my sql statement is not working. Here is my sql statement:

$sql = "SELECT UCASE(ph.groupno) as groupno, ph.name, b.FirstName, b.LastName				FROM Policies p INNER JOIN persHorizon ph ON p.GroupNumber = ph.groupno				INNER JOIN Brokers b ON p.managing_broker_id = b.PersonID where 1";   if (strlen($groupno)!=0) {$sql = $sql." AND `groupno` LIKE '%".$groupno."%'";}   if (strlen($groupname)!=0) {$sql = $sql." AND `name` LIKE '%".$groupname."%'";}   //if (strlen($asofstart)!=0) {$sql = $sql."AND `asof` BETWEEN '".$asofstart."' and '".$asofend."'";}   if (strlen($asofstart)!=0)   {   if (strlen($asofend))		 $sql .= " AND " . " str_to_date(concat(right(asof, 4), '-', left(asof, 2), '-01'), '%Y-%m-%d') " . 	 		 " BETWEEN '" . substr($asofstart, 3) . "-" . substr($asofstart, 0, 2) . "-01" . 		   "' AND '" . substr($asofend, 3) . "-" . substr($asofend, 0, 2) . "-01'";	else		 $sql .= " AND `asof` = '{$asofstart}'";   }	elseif (strlen($asofend))  {	$sql .= " AND `asof` = '{$asofend}'";  }	$sql = $sql." ORDER BY `groupno` DESC";	$RESULT = mysql_query($sql, $objConn);	$CNT1 = mysql_num_rows($RESULT);

I am able to run from PHPMYADMIN area, but not working in webpage.

Link to comment
Share on other sites

Hi, it would be nice if you put the result url, the only thing i see so far is the lack of quotes.something like:$str = "<a href='pers-searchresult.php?groupno=$groupno&asofstart=$asofstart&asofend=$asofend' >$groupname</a>";and print the whole $_POST and $_GET to see what are you receiving.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...