March 27, 2011

convert this link to POST mode

Question by homlyn

How can I convert this $_GET method to $_POST method?

$linkword .= "n<A HREF="$self?letters=$alpha[$c]$letters&n=$n">$alpha[$c]</A> ";

Answer by Starx

Instead of creating a anchor tag. Create a hidden form

$linkword .= "n<A HREF="$self?letters=$alpha[$c]$letters&n=$n">$alpha[$c]</A>";

Here is a Sample

<form name="hiddenform" method="POST" action="page.php">
   <input type="hidden" name="letters" value="<? echo alpha[$c].$letters; ?>" />
   <input type="hidden" name="n" value="<? echo $n; ?>" />
   <a onclick="document.forms['hiddenform'].submit();">Test Link <? echo $alpha[$c]; ?></a>
</form>

Jsfiddle Demo

July 17, 2010

which is better single query or multiple query?

Question by mathew

I do have 8 tables. when a query fires from search page data from all these 8 tables is pulled out and displayed on the result page. What I want to know is which is the best optimized query method for this process??

what I do now is :

$result = mysql_query("SELECT * FROM TG_dat,TG_dat1,TG_dat2,TG_dat3 WHERE 
TG_dat.web = TG_dat1.web AND TG_dat.web = TG_dat2.web AND TG_dat.web = 
TG_dat3.web AND TG_dat.web='".$uri."'")or die(mysql_error());

or do i need to use this??

$result = mysql_query("SELECT * FROM TG_dat WHERE web='$uri'")or die(mysql_error());
$result = mysql_query("SELECT * FROM TG_dat1 WHERE web='$uri'")or die(mysql_error());
$result = mysql_query("SELECT * FROM TG_dat2 WHERE web='$uri'")or die(mysql_error());
$result = mysql_query("SELECT * FROM TG_dat3 WHERE web='$uri'")or die(mysql_error());

Answer by OMG Ponies

Your existing query is perfect – always try to use as few queries as possible.

Answer by Starx

your existing query is good. The point is to limit querying db server for better effieciency

...

Please fill the form - I will response as fast as I can!