Jump to content

Recommended Posts

Hi everyone!

 

I made a php code to show a staff list when choosing a job title from a drop-down menu, everything work's fine when i use the staff.php file alone

BUT when i put it in JOOMLA (with JUMI plugins) i only can see the drop-down list and when i choose a job title from the drop-down menu i don't get anything from the staff list info.

 

it must something with JOOMLA, i mean i must have to change something in the code to work with JOOMLA, because it's working well when its alone

 

BEST REGARDS TO YOU ALL

 

===================

staff.php

===================

<?php

 

defined( '_JEXEC' ) or die( 'Restricted access' );

 

// Connect To MySQL

//mysql_connect("localhost", "UserName", "PassWord") or die(mysql_error());

//mysql_select_db("DatabaseName") or die(mysql_error());

//$YrkeSlkt="SELECT Yrke FROM TableName order by Yrke ASC";

 

$db =& JFactory::getDBO();

 

 

// Connect database

 

// If submitted, check the value of "select". If its not blank value, get the value and put it into $select.

if(isset($select)&&$select!="")

{

$select=$_GET['select'];

}

?>

 

 

<form id="YrkeForm" name="YrkeForm" method="get" action="<? echo $PHP_SELF; ?> ">

  <div align="center">

    <select name="select" onChange="submit()">

  <option value="">--- Välj Yrke ---</option>

  <?

// Get records from database (table "TableName").

$list=mysql_query("SELECT DISTINCT(Yrke) as Yrke FROM TableName ORDER BY Yrke ASC;");

 

// Show records by while loop.

while($row_list=mysql_fetch_assoc($list)){

?>

  <option value="<? echo $row_list['Yrke']; ?>" <? if($row_list['Yrke']==$select){ echo "selected"; } ?>><? echo $row_list['Yrke']; ?></option>

  <?

// End while loop.

}

?>

    </select>

   

  </div>

</form>

<hr>

<p>

<?

// If you have selected from list box.

if(isset($select)&&$select!=""){

 

// Get records from database (table "TableName").

$result1=mysql_query("select * from TableName where Yrke='$select'");

$row=mysql_fetch_assoc($result1);

?>

 

<?

// End if statement.

}

 

// Close database connection.

$query = sprintf("SELECT * FROM TableName WHERE Yrke='%s' order by FNamn ASC", mysql_real_escape_string($row['Yrke'])) or die ("Unable to Make the Query:" . mysql_error() );

 

 

// Perform Query

$result2 = mysql_query($query);

echo "<table border='1' align='center'>";

echo "<tr> <th>Fornamn</th> <th>Efternamn</th> <th>PersonNummer</th> <th>Stad</th> <th>Address</th> <th>PostNr</th> <th>PostAd</th> <th>Mobil</th> <th>Yrke</th> <th>Motte</th> </tr>";

// keeps getting the next row until there are no more to get

while($row = mysql_fetch_array( $result2 )) {

// Print out the contents of each row into a table

echo "<tr><td>";

echo $row['FNamn'];

echo "</td><td>";

echo $row['ENamn'];

echo "</td><td>";

echo $row['PersonNmr'];

echo "</td><td>";

echo $row['Stad'];

echo "</td><td>";

echo $row['Address'];

echo "</td><td>";

echo $row['PostNr'];

echo "</td><td>";

echo $row['PostAd'];

echo "</td><td>";

echo $row['Mobil'];

echo "</td><td>";

echo $row['Yrke'];

echo "</td><td>";

echo $row['Motte'];

echo "</td></tr>";

}

echo "</table>";

mysql_close();

?>

</p>

Link to comment
https://forums.phpfreaks.com/topic/204415-joomla-problem-with-php-code/
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.