visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: PHP :: optional linking from data table


By: MasterMitch U.S.A.  Date: 11/04/2003 00:00:00  English  Points: 500 Status: Answered
Quality : Excellent
I have a list of clubs that are pulled from a database. currently each club is linked to bring up additional info in a seperate window. I want to remove that link from *specific* clubs that are not paying for advertising. So they would still be listed but not linked to their info in the database. I made a column in the table called "paid" and put "yes" for those that paid, and then get linked and "no" to those that didnt pay. What would be the proper php to call this new list having those that are linked and those that are not. Right now I have

<?php

while($aRow=mysql_fetch_array($sResult) ) {
?><a href="<?php print $PHP_SELF; ?>?t=<?php print $HTTP_GET_VARS['t']; ?>&i=<?php print $aRow['a_id']; ?>"><?php print $aRow['name']; ?></a>

<?php

this works for bringing the list up. can this statement be modified for what I need?

thanks for huge huge huge HUGE H U G E help!!

Mitch
Phoenix, AZ
By: VGR Date: 11/04/2003 07:30:00 English  Type : Comment
of course :

<?php
if (isset($_GET['t'])) $t=$_GET['t']; // and not $t=$HTTP_GET_VARS['t']; (deprecated)

while($aRow=mysql_fetch_array($sResult) ) {
$haspaid=($aRow['paid']=='yes');
echo (($haspaid)?"<a href=$PHP_SELF?t=&i={$aRow['a_id']}>":'').$aRow['name'].(($haspaid)?'</a>':'').'
';
?>

PS you could also learn to use the trick :
echo <<<EOS
any html with $variables in it
EOS;


By: VGR Date: 11/04/2003 07:32:00 English  Type : Comment
this can also be written with three lines and two IFs like this, if you prefer :

<?php
if (isset($_GET['t'])) $t=$_GET['t']; // and not $t=$HTTP_GET_VARS['t']; (deprecated)

while($aRow=mysql_fetch_array($sResult) ) {
$haspaid=($aRow['paid']=='yes');
if ($haspaid) echo "<a href=$PHP_SELF?t=&i=".$aRow['a_id'];
echo $aRow['name'];
if ($haspaid) echo '</a>';
echo '
';
} // end while
?>
By: MasterMitch Date: 11/04/2003 08:16:00 English  Type : Comment
that looks good, may I ask what "(deprecated)" means in those instances. Do I have to put "no" in the paid column at all if you are just looking for the "yes" variable in the column. since you gave 2 examples, do you have a preference which is easier to use. to me code is code.
By: MasterMitch Date: 11/04/2003 09:38:00 English  Type : Comment
ok I tried the first example and the list came up fine with 2 exceptions: (the second example created a php parsing error with the other php on page so lets concentrate on the first one to use)

1. the "no" values, the ones that do not have links are coming up without the css filter on it. I have a css filter for links. how can I implement a different css filter to keep the non-link text the same size but not linked.

2. when I click on a link of a club that has a "yes" value then I get no record from the database. The url should look like index.php?t=1&i=4 (saved from the old working version), the new url is /index.php?t=?&i=1

I do not know how to change the script to look for the t=1 in the working example. any help is greatly appreciated.
By: bljak Date: 11/04/2003 10:38:00 English  Type : Comment
Np, i will help out my old friend VGR a bit, can you post us how $sResult looks like? :) (preferable with WHOLE sql syntax pls)
Thank You very much

//bljak
By: MasterMitch Date: 11/04/2003 10:47:00 English  Type : Comment
I'll do you one better. Here is the entire code for the entire page and you can see how the page is laid out completely and where the results go which is on the right compared to the table listed on the left. I hope this helps. thanks tons for your help.


<?php

$sDbcnx = mysql_pconnect('localhost','****','$.$bryan$.$');
mysql_select_db("*****");

?>

<html><!-- InstanceBegin template="/Templates/members.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Playtime Magazine</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- Fireworks MX Dreamweaver MX target. Created Thu Jan 30 13:19:06 GMT-0700 (US Mountain Standard Time) 2003-->
<LINK REL="Stylesheet" TYPE="text/css" HREF="/members/style1.css">

<?php require_once('<A HREF="http://www.playtime.com/nav/nav_members.shtm">http://www.playtime.com/nav/nav_members.shtm</a>'); ?>
<!-- InstanceBeginEditable name="head" -->




<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="../../js/popup.js"></SCRIPT>

<!-- InstanceEndEditable -->

</head>
<body bgcolor="#000000" text="#FFFFFF" link="#FFFFFF" vlink="#00CCFF" alink="#00CCFF" leftmargin="0" topmargin="0" marginwidth="0">
<table width="782" border="0" align="center" cellpadding="0" cellspacing="0">
<!-- fwtable fwsrc="/images/outline.png" fwbase="outline.gif" fwstyle="Dreamweaver" fwdocid = "742308039" fwnested="0" -->
<tr>
<td><img src="/images/template/spacer.gif" width="341" height="1" border="0" alt=""></td>
<td><img src="/images/template/spacer.gif" width="18" height="1" border="0" alt=""></td>
<td><img src="/images/template/spacer.gif" width="390" height="1" border="0" alt=""></td>
<td><img src="/images/template/spacer.gif" width="11" height="1" border="0" alt=""></td>
<td><img src="/images/template/spacer.gif" width="1" height="1" border="0" alt=""></td>
<td><img src="/images/template/spacer.gif" width="1" height="1" border="0" alt=""></td>
</tr>
<tr>
<td rowspan="6" colspan="4"><img name="outline_r1_c2" src="/images/template/outline_r1_c2.gif" width="780" height="118" border="0" alt=""></td>
<td rowspan="5"><img name="outline_r1_c9" src="/images/template/outline_r1_c9.gif" width="1" height="116" border="0" alt=""></td>
<td><img src="/images/template/spacer.gif" width="1" height="12" border="0" alt=""></td>
</tr>
<tr>
<td><img src="/images/template/spacer.gif" width="1" height="9" border="0" alt=""></td>
</tr>
<tr>
<td><img src="/images/template/spacer.gif" width="1" height="75" border="0" alt=""></td>
</tr>
<tr>
<td><img src="/images/template/spacer.gif" width="1" height="14" border="0" alt=""></td>
</tr>
<tr>
<td><img src="/images/template/spacer.gif" width="1" height="6" border="0" alt=""></td>
</tr>
<tr>
<td rowspan="2"><img name="outline_r6_c9" src="/images/template/outline_r6_c9.gif" width="1" height="35" border="0" alt=""></td>
<td><img src="/images/template/spacer.gif" width="1" height="2" border="0" alt=""></td>
</tr>
<tr>
<td colspan="4" valign="top" bgcolor="CCCCCC"><script>PlaceMenu("mainmenu")</script></td>
<td><img src="/images/template/spacer.gif" width="1" height="33" border="0" alt=""></td>
</tr>
<tr> </tr>
<tr>
<td colspan="4" valign="top"><table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="2%"><img src="images/spacer.gif" width="25" height="1" border="0" alt=""></td>
<td width="94%"><img src="images/spacer.gif" width="648" height="1" border="0" alt=""></td>
<td width="4%"><img src="images/spacer.gif" width="26" height="1" border="0" alt=""></td>
</tr>
<tr>
<td colspan="3"><img name="template_r1_c1" src="../../images/template/template_r1_c1.gif" width="100%" height="26" border="0" alt=""></td>
</tr>
<tr>
<td background="/images/template/template_r2_c1.gif">&nbsp;</td>
<td valign="top" bgcolor="#000000"><!-- InstanceBeginEditable name="content" -->
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td valign="top" align="center" width="202" rowspan="4"> <span class="header"><font size="2" face="Times New Roman, Times, serif">
</font></span><span class="white"><font size="2" face="Times New Roman, Times, serif"><font color="#FFFFFF">Select
a type of club you want to view from the right slections:</font></font></span>



<!-- FOR LEFT SIDE> CHECKS -->
<?php

/* check to see if the type isset */

if(!empty($HTTP_GET_VARS['t'])) {

$sSql = "SELECT * FROM adult WHERE type='".$HTTP_GET_VARS['t']."'";
$sResult = mysql_query($sSql);
$iNumrows = mysql_num_rows($sResult);

/* type isset, now look for the total amount of rows. */

if($iNumrows > 0) {

/* number of rows are greater than zero, display the links */

?>
<img src="../../images/adultdirectory/ad<?php print $HTTP_GET_VARS['t']; ?>.gif" border="0">



<!--begin new-->
<?php
if (isset($_GET['t'])) $t=$_GET['t']; // and not $t=$HTTP_GET_VARS['t']; (deprecated)

while($aRow=mysql_fetch_array($sResult) ) {
$haspaid=($aRow['paid']=='yes');
echo (($haspaid)?"<a href=$PHP_SELF?t=?&i={$aRow['a_id']}>":'').$aRow['name'].(($haspaid)?'</a>':'').'
';
?>
<!--end new-->

<?php

} //end while

/* nothing found for this type */

} else {

?>
<p>No adult clubs posted in this section yet!</p>
<?php

} // end Numrows

/* Nothing set, so lets display the text for featured club (w/o name) */

} else {

?>
<!-- <IMG SRC="../../images/adultdirectory/adult_main.gif" BORDER="0">-->
<?php

} //end empty

?>
</td>
<td height="21" colspan="2" align="left" valign="top" bgcolor="#FFFFFF">
<div align="center"><a href="<?php print $PHP_SELF; ?>?t=1"><img src="../../images/adultdirectory/topless_button.gif" alt="Topless Clubs" width="101" height="21" border="0"></a><a href="<?php print $PHP_SELF; ?>?t=2"><img src="../../images/adultdirectory/nude_button.gif" alt="Nude Clubs" width="78" height="21" border="0"></a><a href="<?php print $PHP_SELF; ?>?t=3"><img src="../../images/adultdirectory/social_button.gif" alt="Social Clubs" width="83" height="21" border="0"></a><a href="<?php print $PHP_SELF; ?>?t=4"><img src="../../images/adultdirectory/incall_button.gif" alt="In Call Service" width="109" height="21" border="0"></a><a href="<?php print $PHP_SELF; ?>?t=5"><img src="../../images/adultdirectory/adult_button.gif" alt="Adult Shops" width="133" height="21" border="0"></a></div></td>
</tr>
<?php

/* check to see if ID has been passed */

if(isset($HTTP_GET_VARS['i'])) {

$sSelect = "SELECT * FROM adult WHERE type='".$HTTP_GET_VARS['t']."' AND a_id='".$HTTP_GET_VARS['i']."'";
$sSelectR = mysql_query($sSelect);
$iFind = mysql_num_rows($sSelectR);

/* ID has been passed, check to see if it is in the database */

if($iFind > 0) {

$aFind = mysql_fetch_array($sSelectR);

?>
<tr>
<td height="25" colspan="2" align="right" valign="top" bgcolor="#FFFFFF"><div align="center"><img src="../../images/adultdirectory/ads/feat<?php print $HTTP_GET_VARS["t"]; ?>.jpg" height="25" width="504" alt="Directory"></div></td>
</tr>
<tr>
<td height="10" colspan="2" align="right" valign="top" bgcolor="#FFFFFF">&nbsp;</td>
</tr>
<tr>
<td width="302" align="right" valign="top" bgcolor="#FFFFFF">
<a href="javascript:displayWindow('../../images/adultdirectory/ads/<?php print $aFind['image_big']; ?>',400,265);"><img src="../../images/adultdirectory/ads/<?php print $aFind['image_small']; ?>" alt="<?php print $aFind['name']; ?>" width="200" border="0"></a>

<img src="../../images/adultdirectory/clicktozoom.gif" alt="Click to Zoom Ad" width="117" height="20" border="0">


<a href="valleymap.php"><img src="../../images/adultdirectory/view_map.gif" alt="View Map" width="200" height="17" border="0" vspace="1" hspace="1"></a>

<?php

if(empty($aFind['image_map']) ) {

} else {

?>
<img src="../../images/adultdirectory/maps/<?php print $aFind['image_map']; ?>" alt="<?php print $aFind['name']; ?>" width="200" height="132" border="0">

<?php

}

/* simple check for coupon */

if($aFind['coupon'] == "yes") {

?>

<img src="../../images/adultdirectory/print_coupon.gif" alt="Print Coupon" width="149" height="57" border="0">

<?php

}

?>
</td>
<td width="222" align="left" valign="top" bgcolor="#FFFFFF"> <blockquote>
<h3><font color="#000000"><?php print $aFind['name']; ?></font></h3>
<p><font color="#000000"><?php print nl2br($aFind['description']); ?></font></p>
<font color="#000000">
<!-- <P CLASS="bold">Don't forget to print out your coupon for free entry!</P> -->
</font>
<p><font color="#000000"><?php print $aFind['hours']; ?>

Phone:
<?php empty($aFind['phone']) ? print "N/A" : print $aFind['phone']; ?>


<?php empty($aFind['web']) ? print "" : print "WWW : <A HREF=\"<A HREF="http://">http://</a>".$aFind['web']."\">".$aFind['web']."</A>"; ?>
</font> </p>
</blockquote></td>
</tr>
<?php

/* not found in database */

} else {

?>
<tr>
<td valign="top" align="right" height="50" colspan="2">No record
found. Please seach again.</td>
</tr>
<?php

} //end Numrows


/* nothing has been set, so show the featured club */

} else {

$sMain = "SELECT * FROM adult WHERE featured='yes' LIMIT 1";
$sMainR = mysql_query($sMain);

$aMain = mysql_fetch_array($sMainR);
?>
<tr>
<td height="25" colspan="2" align="right" valign="top" bgcolor="#FFFFFF"><div align="center"><img src="../../images/adultdirectory/ads/feat.jpg" height="25" width="504" alt="Featured Club"></div></td>
</tr>
<tr>
<td height="10" colspan="2" align="right" valign="top" bgcolor="#FFFFFF">&nbsp;</td>
</tr>
<tr>
<td width="202" align="right" valign="top" bgcolor="#FFFFFF">
<a href="javascript:displayWindow('../../images/adultdirectory/ads/<?php print $aMain['image_big']; ?>',400,265);"><img src="../../images/adultdirectory/ads/<?php print $aMain['image_small']; ?>" alt="<?php print $aMain['name']; ?>" width="200" height="132" border="0"></a>

<img src="../../images/adultdirectory/clicktozoom.gif" alt="Click to Zoom Ad" width="117" height="20" border="0">

<a href="valleymap.php"><img src="../../images/adultdirectory/view_map.gif" alt="View Map" width="200" height="17" border="0" vspace="1" hspace="1"></a>


<img src="../../images/adultdirectory/maps/<?php print $aMain['image_map']; ?>" alt="<?php print $aFind['name']; ?>" width="200" height="132" border="0">

</td>
<td width="302" align="left" valign="top" bgcolor="#FFFFFF"> <h3><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php print $aMain['name']; ?>



&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;THE PREMIERE TOPLESS
CLUB IN ARIZONA</font></h3>
<blockquote>
<p><font color="#000000"><?php print nl2br($aMain['description']); ?></font></p>
<p><font color="#000000"><?php print $aMain['hours']; ?>

Phone : <?php print $aMain['phone']; ?>

<?php empty($aMain['web']) ? print "" : print "WWW : <A HREF=\"<A HREF="http://">http://</a>".$aMain['web']."\">".$aMain['web']."</A>"; ?>
</font> </p>
</blockquote></td>
</tr>
<?php

} //end empty

?>
</table>
<!-- InstanceEndEditable --></td>
<td background="/images/template/template_r2_c3.gif">&nbsp;</td>
</tr>
<tr>
<td colspan="3"><img src="/images/template/template_r3_c1.gif" alt="" name="template_r3_c1" width="100%" height="22" border="0"></td>
</tr>
</table></td>

</tr>
</table>
</body>
<!-- InstanceEnd --></html>
By: bljak Date: 11/04/2003 10:54:00 English  Type : Comment
One more thing before i go through this all code:
What is PHP version you use? :)

//bljak
By: MasterMitch Date: 11/04/2003 11:00:00 English  Type : Comment
I believe its PHP4 . thats what our hoster says.
By: bljak Date: 11/04/2003 11:02:00 English  Type : Comment
create file called for example phpinfo.php
and write following in it
<?php
phpinfo();
?>
and open that page, php version is printed with DAMN BIG LETTERS at top of the page, you can not miss it

//bljak
By: MasterMitch Date: 11/04/2003 11:06:00 English  Type : Comment
good idea, I am so brain dead today. duh

PHP Version 4.2.3

thanks once again!
By: bljak Date: 11/04/2003 11:16:00 English  Type : Comment
Bah however, i see you have problems with $_GET, might be some 4.0.x version whch didn't support those variables afaik

VGR's code is right but you want to use in your while-loop following
instead of this:
if (isset($_GET['t'])) $t=$_GET['t']; // and not $t=$HTTP_GET_VARS['t']; (deprecated)

while($aRow=mysql_fetch_array($sResult) ) {
$haspaid=($aRow['paid']=='yes');
echo (($haspaid)?"<a href=$PHP_SELF?t=?&i={$aRow['a_id']}>":'').$aRow['name'].(($haspaid)?'</a>':'').'
';

try this (is actually what you wanted, to use your thing but modified):
// if you want to echo those who paid only

while($aRow = mysql_fetch_array($sResult))
{
if(trim($aRow["paid"]) == "yes") //don't worry about trim
{
echo "<a href=\"".$PHP_SELF."?t=".$HTTP_GET_VARS["t"]."&i=".$aRow["a_id"]."\">".$aRow["name"]."</a>
";
}
}
//end of while

So much for that, should work nicely

//bljak
By: bljak Date: 11/04/2003 11:42:00 English  Type : Comment
And if you want to echo those who have not paid, and want them as nonline and want css file to edit and so on and so on, lets use this
in css file add entry (which is 1:1 copy of A)
if not used H1 then use H1 or any other til H6 which is not yet used
H1
{
font-family: blah;
font-size: blah;
color: blah;
}

so lets assume it was H1 and while-loop would look like this now
while($aRow = mysql_fetch_array($sResult))
{
if(trim($aRow["paid"]) == "yes") //don't worry about trim
{
echo "<a href=\"".$PHP_SELF."?t=".$HTTP_GET_VARS["t"]."&i=".$aRow["a_id"]."\">".$aRow["name"]."</a>
\n";
} else {
echo "<h1>".$aRow["name"]."</h1>
\n";
}
}

//bljak

By: MasterMitch Date: 11/04/2003 11:58:00 English  Type : Comment
ok I have to work through what you wrote becuase I am not the php genius you are.
so I should use the second and last example and I can use any header even one that is already predefined but you are just using as an example.
and it should look like this:

<?php
if (isset($_GET['t'])) $t=$_GET['t']; // and not $t=$HTTP_GET_VARS['t']; (deprecated)

while($aRow = mysql_fetch_array($sResult))
{
if(trim($aRow["paid"]) == "yes") //don't worry about trim
{
echo "<a href=\"".$PHP_SELF."?t=".$HTTP_GET_VARS["t"]."&i=".$aRow["a_id"]."\">".$aRow["name"]."</a>
\n";
} else {
echo "<h1>".$aRow["name"]."</h1>
\n";
}
}

?>


By: bljak Date: 11/04/2003 12:04:00 English  Type : Comment
Yes, no need for line
if (isset($_GET['t'])) $t=$_GET['t']; // and not $t=$HTTP_GET_VARS['t']; (deprecated)
can delete it
As for code, you can expirience PROBLEMS if you just want to insert this as is in your page IF you do not remove last closing brackets } on my last line, else you will get some php errors

//bljak
By: MasterMitch Date: 11/04/2003 13:48:00 English  Type : Comment
I put this in:

<?php
{
if(trim($aRow["paid"]) == "yes") //don't worry about trim
{
echo "<a href=\"".$PHP_SELF."?t=".$HTTP_GET_VARS["t"]."&i=".$aRow["a_id"]."\">".$aRow["name"]."</a>
\n";
} else {
echo "<font color='#FFFFFF'>".$aRow["name"]."</font>
\n";
}

?>

I didnt get a list retured of any kind, just blank space on the left where it was supposed to be. The url that got returned was /index.php?t=1 ...the old working version url had the "=" in it such as index.php?t=1&i=4

any suggestions are very helpfull. I am very deeply greatful for your help. I think just the i= value is missing from the string somehow.
By: VGR Date: 11/04/2003 16:44:00 English  Type : Answer
disagree with bljak

if (isset($_GET['t'])) $t=$_GET['t']; // and not $t=$HTTP_GET_VARS['t']; (deprecated)
is good practice

it's http_get_vars[] who's deprecated in favour of $_get[], that's all and you are concerned given you've a 4.2.3 like me. The other name was "old pre 4.1" I guess)

I think I covered your question right, IF your data are correct (ie either 'yes' or 'no' in column 'paid', not anything else ;-)

I made a typo for parameter t, here is it corrected, and I also tried to show you how to keep css settings for links without having a link (what a strange idea :D)

<?php
if (isset($_GET['t'])) $t=$_GET['t']; // if register_globals=Off

// here your connection and your query
// giving out $sResult;

while($aRow=mysql_fetch_array($sResult) ) {
$haspaid=($aRow['paid']=='yes');
if ($haspaid) echo "<a href=$PHP_SELF?t=$t&i=".$aRow['a_id']; else echo "<p class=link>";
echo $aRow['name'];
if ($haspaid) echo '</a>'; else echo '</p>';
echo '
';
} // end while
?>

By: bljak Date: 12/04/2003 19:32:00 English  Type : Comment
Hehe
shouldn't have closed last bracer, since his code as in original doesn't have it closed also, if he copy/pastes this, as he will do, he will get parse error as in your post nr.2 :)))))))

//bljak
By: VGR Date: 12/04/2003 20:31:00 English  Type : Comment
yes, but as he complained about a "parse error" in my code, I suspected it was HIS mistake for the closing while bracket that bugged him :D

so I corrected this.
By: MasterMitch Date: 12/04/2003 20:47:00 English  Type : Comment
ok I am getting a
Parse error: parse error in /usr/site/www/<A HREF="http://www.playtime.com/members/adultdirectory/index.php">www.playtime.com/members/adultdirectory/index.php</a> on line 140

when I put that in. it is well after the code I put in. the portion of the side I am dealing with is:

<?php

/* check to see if the type isset */

if(!empty($HTTP_GET_VARS['t'])) {

$sSql = "SELECT * FROM adult WHERE type='".$HTTP_GET_VARS['t']."'";
$sResult = mysql_query($sSql);
$iNumrows = mysql_num_rows($sResult);

/* type isset, now look for the total amount of rows. */

if($iNumrows > 0) {

/* number of rows are greater than zero, display the links */

?>
<img src="../../images/adultdirectory/ad<?php print $HTTP_GET_VARS['t']; ?>.gif" border="0">



<!--begin new-->
<?php
if (isset($_GET['t'])) $t=$_GET['t']; // if register_globals=Off

// here your connection and your query
// giving out $sResult;

while($aRow=mysql_fetch_array($sResult) ) {
$haspaid=($aRow['paid']=='yes');
if ($haspaid) echo "<a href=$PHP_SELF?t=$t&i=".$aRow['a_id']; else echo "<font color=#'FFFFFF'>";
echo $aRow['name'];
if ($haspaid) echo '</a>'; else echo '</font>';
echo '
';
} // end while
?>



<!--end new-->

<?php

} //end while

/* nothing found for this type */

} else {

?>
<p>No adult clubs posted in this section yet!</p>
<?php

} // end Numrows

/* Nothing set, so lets display the text for featured club (w/o name) */

} else {

?>
<!-- <IMG SRC="../../images/adultdirectory/adult_main.gif" BORDER="0">-->
<?php

} //end empty

?>

You can see the code may have collisions under what you guys put in.

The best one that worked so far with the least amount of problems was the 2nd posting. As I said at the time, the only problems were the url was doing /index.php?t=&i=2
and should be doing index.php?t=1&i=2 (you can see the t=# is being left out) . If you can solve to put the t=# in and modify to put a place I can just keep the css, this example should work perfect. As is I do get the "no" as non linked and the "yes" as linked. so this example is great just needs to be modified. can you do that please. the code that worked is below for easy reference. I am sure I can give you "some small ways of appreciation" if you contact me off EE at mpalmer@playtime.com


<?php
if (isset($_GET['t'])) $t=$_GET['t']; // and not $t=$HTTP_GET_VARS['t']; (deprecated)

while($aRow=mysql_fetch_array($sResult) ) {
$haspaid=($aRow['paid']=='yes');
echo (($haspaid)?"<a href=$PHP_SELF?t=&i={$aRow['a_id']}>":'').$aRow['name'].(($haspaid)?'</a>':'').'
';
?>

By: VGR Date: 12/04/2003 20:51:00 English  Type : Comment
just put $t after the t=

that's in my corrected code above
By: bljak Date: 12/04/2003 20:53:00 English  Type : Comment
Yes, you have extra closing bracer
you have 2 times } //end while
remove one for god sake

//bljak
By: MasterMitch Date: 12/04/2003 21:17:00 English  Type : Comment
ok so this below should work (this is with the new code you guys gave me in the right spot) I am afk and doing this remotely to make sure this works with your approval and all the php code etc.:

<?php

/* check to see if the type isset */

if(!empty($HTTP_GET_VARS['t'])) {

$sSql = "SELECT * FROM adult WHERE type='".$HTTP_GET_VARS['t']."'";
$sResult = mysql_query($sSql);
$iNumrows = mysql_num_rows($sResult);

/* type isset, now look for the total amount of rows. */

if($iNumrows > 0) {

/* number of rows are greater than zero, display the links */

?>
<img src="../../images/adultdirectory/ad<?php print $HTTP_GET_VARS['t']; ?>.gif" border="0">



<!--begin new-->
<?php
if (isset($_GET['t'])) $t=$_GET['t']; // if register_globals=Off

// here your connection and your query
// giving out $sResult;

while($aRow=mysql_fetch_array($sResult) ) {
$haspaid=($aRow['paid']=='yes');
if ($haspaid) echo "<a href=$PHP_SELF?t=$t&i=".$aRow['a_id']; else echo "<p class=link>";
echo $aRow['name'];
if ($haspaid) echo '</a>'; else echo '</p>';
echo '
';
} // end while
?>



<!--end new-->

<?php

} //end while

/* nothing found for this type */

} else {

?>
<p>No adult clubs posted in this section yet!</p>
<?php

} // end Numrows

/* Nothing set, so lets display the text for featured club (w/o name) */

} else {

?>
<!-- <IMG SRC="../../images/adultdirectory/adult_main.gif" BORDER="0">-->
<?php

} //end empty

?>


By: bljak Date: 12/04/2003 21:26:00 English  Type : Comment
NO, it does not work
Please copy and paste code i posted below (it is actually VGR's code but i removed those DAMN closing bracer you have too much and i get NO parsing error)

<?php

/* check to see if the type isset */

if(!empty($HTTP_GET_VARS['t'])) {

$sSql = "SELECT * FROM adult WHERE type='".$HTTP_GET_VARS['t']."'";
$sResult = mysql_query($sSql);
$iNumrows = mysql_num_rows($sResult);

/* type isset, now look for the total amount of rows. */

if($iNumrows > 0) {

/* number of rows are greater than zero, display the links */

?>
<img src="../../images/adultdirectory/ad<?php print $HTTP_GET_VARS['t']; ?>.gif" border="0">



<!--begin new-->
<?php
if (isset($_GET['t'])) $t=$_GET['t']; // if register_globals=Off

// here your connection and your query
// giving out $sResult;

while($aRow=mysql_fetch_array($sResult) ) {
$haspaid=($aRow['paid']=='yes');
if ($haspaid) echo "<a href=$PHP_SELF?t=$t&i=".$aRow['a_id']; else echo "<p class=link>";
echo $aRow['name'];
if ($haspaid) echo '</a>'; else echo '</p>';
echo '
';
?>



<!--end new-->

<?php

} //end while

/* nothing found for this type */

} else {

?>
<p>No adult clubs posted in this section yet!</p>
<?php

} // end Numrows

/* Nothing set, so lets display the text for featured club (w/o name) */

} else {

?>
<!-- <IMG SRC="../../images/adultdirectory/adult_main.gif" BORDER="0">-->
<?php

} //end empty

?>

I have no idea if this looks good when i post it, bit wider textarea would rock :)

//bljak
By: bljak Date: 12/04/2003 21:26:00 English  Type : Comment
ahh, seems it came good :)

//bljak
By: MasterMitch Date: 12/04/2003 21:35:00 English  Type : Comment
ok boys. strangely the last example did not work. it grouped the listings and made all the links screwed from the database. Just as an example I put together this example at <A HREF="http://playtime.com/codetest.php">http://playtime.com/codetest.php</a> to show you how it looks with the latest version that you gave.

Now I did actually solve this problem by myself tweaking VGR's initial code example all the way at the top.

<?php
if (isset($_GET['t'])) $t=$_GET['t']; // and not $t=$HTTP_GET_VARS['t']; (deprecated)

while($aRow=mysql_fetch_array($sResult) ) {
$haspaid=($aRow['paid']=='yes');
echo (($haspaid)?"<a href=$PHP_SELF?t=$t&i={$aRow['a_id']}>":'').$aRow['name'].(($haspaid)?'</a>':'').'
';
?>

In the row before the PHP I put <td width="202" rowspan="4" align="center" valign="top" class="AD">
(I made a class called AD which is identical to the links but without the "link rollover".)

Now I get a list of everything and initially they come up in the same format but only the "paid" have actual links. I tried to figure out how to sort so that the "paid" links come out on top but that is a whole nother headache.

Check out the example I showed you, maybe seeing it will give you a better idea. Also contact me at mpalmer@playtime.com and I can give you access to the members site when it comes online this week for all your help. just a small way I can say thanks instead of the points since I can only give it to one and both were really helpful.
By: VGR Date: 13/04/2003 05:20:00 English  Type : Comment
ok, to sort the things so that "paid" come first, you've to modify the MySql query giving you sResult in a way alike to this :
SELECT * FROM ... WHERE... ORDER BY...*

* : add this :
,paid DESC;

desc because 'yes' has to come out before 'no'

if you didn't have an ORDER BY clause, then just add this at the end of your query :
ORDER BY paid DESC

and don't forget the closing semicolon

By: MasterMitch Date: 13/04/2003 05:44:00 English  Type : Comment
currently the SQL is:

SELECT * FROM `adult` WHERE 1

what should the new line be. I can just cut and paste what you write into the SQL function. I did not understand what you wrote above.


By: VGR Date: 13/04/2003 18:00:00 English  Type : Comment
SELECT * FROM adult ORDER BY paid DESC;
By: MasterMitch Date: 13/04/2003 18:09:00 English  Type : Comment
ok you are rated a php GOD..I bow before your amazing talents!!!! once again please contact me off EE at mpalmer@playtime.com so I can give you a password for the site. thanks!!!!
By: MasterMitch Date: 13/04/2003 18:10:00 English  Type : Comment
this guy is a php god. he really helped me out!
By: VGR Date: 13/04/2003 18:31:00 English  Type : Comment
no God nor Demi-God at all ;-)
a Hero at most ;-)
I don't have enough hit points :D
By: VGR Date: 13/04/2003 18:34:00 English  Type : Comment
we'll... your playtime.com site is... how to say... rather "adult", no ? :D

is it fun developing this ?

Do register to be able to answer

EContact
browser fav
page generated in 421.658990 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page