Jump to content

some php help needed!


BigX

Recommended Posts

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  ;D

Does anyone know how to get this done??

 

thanks in advance!!

Link to comment
Share on other sites

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  :D

 

thanks for any input!!

Link to comment
Share on other sites

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
Share on other sites

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  ;D 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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.