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!! Link to comment https://forums.phpfreaks.com/topic/98715-some-php-help-needed/ 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?? Link to comment https://forums.phpfreaks.com/topic/98715-some-php-help-needed/#findComment-505178 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. Link to comment https://forums.phpfreaks.com/topic/98715-some-php-help-needed/#findComment-505180 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............. ??? Link to comment https://forums.phpfreaks.com/topic/98715-some-php-help-needed/#findComment-505183 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 Link to comment https://forums.phpfreaks.com/topic/98715-some-php-help-needed/#findComment-505194 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?? Link to comment https://forums.phpfreaks.com/topic/98715-some-php-help-needed/#findComment-505195 Share on other sites More sharing options...
BigX Posted March 31, 2008 Author Share Posted March 31, 2008 bump Link to comment https://forums.phpfreaks.com/topic/98715-some-php-help-needed/#findComment-505281 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> Link to comment https://forums.phpfreaks.com/topic/98715-some-php-help-needed/#findComment-505285 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 Link to comment https://forums.phpfreaks.com/topic/98715-some-php-help-needed/#findComment-505297 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!! Link to comment https://forums.phpfreaks.com/topic/98715-some-php-help-needed/#findComment-505301 Share on other sites More sharing options...
BigX Posted March 31, 2008 Author Share Posted March 31, 2008 Maybe today anyone?? Link to comment https://forums.phpfreaks.com/topic/98715-some-php-help-needed/#findComment-505525 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> Link to comment https://forums.phpfreaks.com/topic/98715-some-php-help-needed/#findComment-505582 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? Link to comment https://forums.phpfreaks.com/topic/98715-some-php-help-needed/#findComment-505605 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.