BigX Posted March 30, 2008 Share Posted March 30, 2008 Hi guys, I have a index.php site with on the left 8 buttons with links to index.php?categorie# with # being 1, 2, 3....8 for the 8 categories that i want to display!! $_GET will get the categorie number from the link and display all the results of that categorie on the page! I have this code that works fine: <?php if(isset($_GET['categorie'])) { $categorie = $_GET['categorie']; $organisaties_categorie = mysql_query("SELECT * FROM organisaties WHERE Categorie=" . $categorie." ORDER BY Organisatie ASC"); echo "<table width='350' cellspacing='0' border='0'> <tr> <th width='20' style='color: #CB0042' bgcolor='#FFFFFF'><div class='style11'><b>Organisaties</b></div></th> </tr> <tr> <th width='20' style='color: #CB0042' bgcolor='#FFFFFF'><div class='style11'><b> </b></div></th> </tr>"; while($row = mysql_fetch_array($organisaties_categorie, MYSQL_ASSOC)) { echo "<tr>"; echo "<td style='color: #000099'><div align='left'><a href='organisatie.php?id={$row['id']}'>• " . $row['Organisatie'] . "</a></div></td>"; echo "</tr>"; $organisaties_subcategorie = mysql_query("SELECT * FROM organisaties WHERE subcategorie=" . $row['id']); while($row = mysql_fetch_array($organisaties_subcategorie, MYSQL_ASSOC)) { echo "<tr>"; echo "<td style='padding-left: 30px; font-size: 14px'><div align='left'><a class='rood' href='organisatie.php?id={$row['id']}'>" . $row['Organisatie'] . "</a></div></td>"; echo "</tr>"; } } echo "</table>"; ; } else { echo "<table width='555' border='0'> <tr> <td width='378' bgcolor='#FFFFFF'><img src=\"juridischloket.jpg\" alt=\"\" width=\"365\" height=\"320\"/></td> <td width='177' bgcolor='#FFFFFF'><table width=\"177\" border=\"0\" align=\"right\"> <tr> <td><div align=\"left\"><span class=\"style3\">Loketgegevens</span></div></td> </tr> <tr> <td><div align=\"left\"><span class=\"style2\">Juridisch Loket Amersfoort</span></div></td> </tr> <tr> <td><div align=\"left\"><span class=\"style2\">Telefoon: 0900-8020</span></div></td> </tr> <tr> <td><div align=\"left\"><span class=\"style2\">Fax: 033-4622361</span></div></td> </tr> <tr> <td> </td> </tr> <tr> <td><div align=\"left\"></div></td> </tr> <tr> <td><div align=\"left\"><strong>Bezoekadres</strong></div></td> </tr> <tr> <td><div align=\"left\"><span class=\"style2\">Van Asch van Wijckstraat 2-4</span></div></td> </tr> <tr> <td><div align=\"left\"><span class=\"style2\">3822 LP Amersfoort</span></div></td> </tr> <tr> <td> </td> </tr> <tr> <td><div align=\"left\"></div></td> </tr> <tr> <td bgcolor=\"#FFFFFF\"><div align=\"left\"><span class=\"style3\">Postadres</span></div></td> </tr> <tr> <td><div align=\"left\"><span class=\"style2\">Postbus 2081</span></div></td> </tr> <tr> <td><div align=\"left\"><span class=\"style2\">3800 CB Amersfoort</span></div></td> </tr> <tr> <td> </td> </tr> <tr> <td><div align=\"left\"></div></td> </tr> <tr> <td><div align=\"left\"><strong>Openingstijden</strong></div></td> </tr> <tr> <td><div align=\"left\"><span class=\"style2\">Ma t/m Vr : 09.00-17.00 uur</span></div></td> </tr> </table></td> </tr>"; echo "</table>"; } ?> When one of the categories is being displayed now it says 'Organisaties' on top due to these lines: echo "<table width='350' cellspacing='0' border='0'> <tr> <th width='20' style='color: #CB0042' bgcolor='#FFFFFF'><div class='style11'><b>Organisaties</b></div></th> </tr> But what I would like is that it would display the name of the button that I clicked to display the categorie. For example the buttons are named buttonA buttonB buttonC ..... buttonI when I click on one of the buttons, i want the corresponding categorie to be displayed (index.php?categorie1 for example) with on top 'buttonA' I hope you guys understand what I mean Does anyone know how to get this done?? thanks in advance!! Quote Link to comment Share on other sites More sharing options...
BigX Posted March 30, 2008 Author Share Posted March 30, 2008 Should I use an if/els statement?? Quote Link to comment Share on other sites More sharing options...
ridiculous Posted March 30, 2008 Share Posted March 30, 2008 No. You should rather consider going on a rampage with an AK-47. Bulgarian made. Quote Link to comment Share on other sites More sharing options...
BigX Posted March 30, 2008 Author Share Posted March 30, 2008 No. You should rather consider going on a rampage with an AK-47. Bulgarian made. I'm not sure if that helped me............. ??? Quote Link to comment Share on other sites More sharing options...
ds111 Posted March 30, 2008 Share Posted March 30, 2008 its his way of saying "I dont know." lol Quote Link to comment Share on other sites More sharing options...
BigX Posted March 30, 2008 Author Share Posted March 30, 2008 its his way of saying "I dont know." lol Yeah I figured something like that Anyone does know how to do this?? Quote Link to comment Share on other sites More sharing options...
BigX Posted March 31, 2008 Author Share Posted March 31, 2008 bump Quote Link to comment Share on other sites More sharing options...
ds111 Posted March 31, 2008 Share Posted March 31, 2008 well if i understand u correctly i would do this: <a href="index.php?categorie=<?php echo $categorie;?>Click for Categorie <?php echo $categorie; ?></a> Quote Link to comment Share on other sites More sharing options...
maxudaskin Posted March 31, 2008 Share Posted March 31, 2008 Should I use an if/els statement?? No. You should rather consider going on a rampage with an AK-47. Bulgarian made. Try else... I don't think els will work to well in php... but java and turing, yes. Nahh, not an AK-47 but a MK11 / SR 25 Sniper Rifle http://www.globalsecurity.org/military/systems/ground/mk11.htm Quote Link to comment Share on other sites More sharing options...
BigX Posted March 31, 2008 Author Share Posted March 31, 2008 well if i understand u correctly i would do this: <a href="index.php?categorie=<?php echo $categorie;?>Click for Categorie <?php echo $categorie; ?></a> Sorry, i don't think that is what I mean! Thanks for heinput though! I appreciate it! What I meant is that when i click one of the buttons, it will show on index.php the categorie of my database that is associated with that button! For example there is a list shown with al the names of the organisations with categorie=1! This line: echo "<table width='350' cellspacing='0' border='0'> <tr> <th width='20' style='color: #CB0042' bgcolor='#FFFFFF'><div class='style11'><b>Organisaties</b></div></th> </tr> always puts the word "Organisaties" on top of that list but instead I would like to put the name of the button on top of that list, for example "Hospitals" if the button displayed Hospitals and categorie 1 are all the hospitals in the neighbourhood! So when a button is clicked it must display the name of the button (so what people see when they click on it) on top of the table and in the table are all the results of the categorie which is associated with that button ussing the index.php?categorie link!! I don't think I can be any clearer than this thanks for any input!! Quote Link to comment Share on other sites More sharing options...
BigX Posted March 31, 2008 Author Share Posted March 31, 2008 Maybe today anyone?? Quote Link to comment Share on other sites More sharing options...
oron Posted March 31, 2008 Share Posted March 31, 2008 Hmm not sure whether this is what you are on about either.. but you could instead of using numbers use strings. Then all you would have to do to get the title would be $catogorie = $_GET['catogorie']; <th width='20' style='color: #CB0042' bgcolor='#FFFFFF'> <div class='style11'><b><?php echo $catogorie; ?></b> </div> </th> Quote Link to comment Share on other sites More sharing options...
BigX Posted March 31, 2008 Author Share Posted March 31, 2008 Hmm not sure whether this is what you are on about either.. but you could instead of using numbers use strings. Then all you would have to do to get the title would be $catogorie = $_GET['catogorie']; <th width='20' style='color: #CB0042' bgcolor='#FFFFFF'> <div class='style11'><b><?php echo $catogorie; ?></b> </div> </th> Well, that is what I meant so we're on the right track here What you suggest should be a solution but the only problem with it is that i have to change al the numbers under categorie to the actual words 'categorie1' etc which is quite some work since it is quite a large database! Isn't it possible to do something like: echo "<table width='350' cellspacing='0' border='0'> <tr> <th width='20' style='color: #CB0042' bgcolor='#FFFFFF'><div class='style11'><b> if( $categorie == "1" ) {echo "Categorie1"}; if( $categorie == "2" ) {echo "Categorie2"}; if( $categorie == "3" ) {echo "Categorie3"}; </b></div></th> </tr> Like this it's not yet working but I believer I have a syntax error somewhere! Anyone? Quote Link to comment 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.