ryanfc Posted August 21, 2007 Share Posted August 21, 2007 I need help creating a link if a value set in my client table is set as 1. I have a business directory that when a user clicks on a category, say Dining, it loads all the restaurants in my database. Here is the code for that: <?php $prev_row =''; echo '<table class=results>'; while($info = mysql_fetch_array( $data )) { $letter = strtoupper(substr($info['name'],0,1)); if ($letter != $prev_row) { if($count % 3) { for ($i = ($count % 3); $i < 3; $i++) echo '<td> </td>'; echo '</tr>'; $count =0; } $prev_row = $letter; echo '<tr bgcolor=#e7e7e7><td colspan=\"3\"><font color=#993833><b>',$letter,'</b></font></td></tr>'; } if ($count % 3 == 0) echo '<tr>'; $count++; echo '<td>', $info['name'], '<br />Phone: ', $info['phone'], "</td>\n"; if ($count % 3 == 0) echo '</tr>'; } if($count % 3) { for ($i = ($count % 3); $i < 3; $i++) echo '<td> </td>'; echo '</tr>'; } echo '</table>'; ?> Now I need to alter the above code so that if it is a paying customer the name of the business becomes a link and when the user clicks on the business name it takes them to a new page which will load more information about that business. So my question is how do i fix that code to do that. I have a column in the client table that is named paid and will be set to 1 if they are paying and 0 if they are not paying. Figured that would be the easiest way. Can anyone help me with how to do that? Thanks. (the name of the page it will take them to is client_detail.php) I am guessing it will be an if statement or something around this area: if ($count % 3 == 0) echo '<tr>'; $count++; echo '<td>', $info['name'], '<br />Phone: ', $info['phone'], "</td>\n"; but still new to php and not sure how to set that up when it is already in an if statement. Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/66006-solved-creating-a-link-if/ Share on other sites More sharing options...
lemmin Posted August 21, 2007 Share Posted August 21, 2007 In your query (which you don't show in that code) you will need to include "paid" in the SELECT clause (assuming you don't). After you have that, just make an if statement. if ($info['paid'] == 1) echo "<td><a href=\"client_detail.php\">", $info['name'], '</a><br />Phone: ', $info['phone'], "</td>\n"; else echo '<td>', $info['name'], '<br />Phone: ', $info['phone'], "</td>\n"; Quote Link to comment https://forums.phpfreaks.com/topic/66006-solved-creating-a-link-if/#findComment-330054 Share on other sites More sharing options...
ryanfc Posted August 21, 2007 Author Share Posted August 21, 2007 very simple......thank you Quote Link to comment https://forums.phpfreaks.com/topic/66006-solved-creating-a-link-if/#findComment-330150 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.