Jump to content

Using XML or array instead of mysql database


etrader

Recommended Posts

There is a "PHP ajax cascading dropdown using MySql" at codestips.com/php-ajax-cascading-dropdown-using-mysql/

 

I want to use this technique but with a XML or array file instead of mysql database, but my knowledge about mysql is very low. How I can modify this code to catch the categories and products from an array, instead of mysql database?

 $connect=mysql_connect($server, $db_user, $db_pass)
      or die ("Mysql connecting error"); 
echo '<table align="center"><tr><td><center><form method="post" action="">Category:<select name="category" onChange="CategoryGrab('."'".'ajaxcalling.php?idCat='."'".'+this.value);">';
$result = mysql_db_query($database, "SELECT * FROM Categories");
$nr=0;
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$nr++;
echo "<option value=".'"'.$row['ID'].'" >'.$row['Name']."</option>";
}
echo '</select>'."\n";
echo '<div id="details">Details:<select name="details" width="100" >';
$result = mysql_db_query($database, "SELECT * FROM CategoriesDetails WHERE CategoryID=1");
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
 echo "<option value=".$row['ID'].">".$row['Name']."</option>";
}
echo '</select></div>';
echo '</form></td></tr></table>';
mysql_close($connect);

 

ajaxcalling.php is

include("config.php");
$ID=$_REQUEST['idCat'];
$connect=mysql_connect($server, $db_user, $db_pass);
echo 'Details:<select name="details" width="100">';
$result = mysql_db_query($database, "SELECT * FROM CategoriesDetails WHERE CategoryID=".$ID);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
 echo "<option value=".$row['ID'].">".$row['Name']."</option>";
}
echo '</select>';
mysql_close($connect);

 

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.