Jump to content

animus

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Everything posted by animus

  1. Thanks akitchin! I'm pretty new to scripting so I'm still getting my feet, your example certainly helps me out. I hadn't thought of setting up the array like that. Thanks so much for the help! best, thom
  2. [b]PROBLEM:[/b] I am having trouble returning values from a function that dynamically creates/assigns variables based on database entries. The idea is to have just a page call to the database and have php make my page. However, each page will have a ton of links to other products and parts of the site. Therefore, I just want to have each page’s links/images/resources handled in the following way: <a title="<? echo $image_description_151; ?>" href="<? echo $image_url_151; ?>"><? echo $image_title_151; ?></a> I have got this to work when it is not encapsulated within a function. Any thoughts? [b]DB STRUCTURE:[/b] [color=red]DB:[/color] Pages Table       Links Table       Images Table       Resources Table       Pages table houses 1 Primary Key page_id and the foreign keys for the other tables Links table houses link_title, link_description, link_url, active & page_id (foreign key) Images and resources tables are exact same structure as links (i.e. resoure_title, images_title) [color=red]PHP:[/color]1 php file 'dbhook.php' (login information for DB)         1 php to return values from DB [b]PHP SCRIPT:[/b] <?php $myPage=1; $myPageData = array("link","image","resource"); $myPageData_length = count($myPageData); for($i=0;$i<=($myPageData_length-1);$i++){ getData($myPage,$myPageData[$i]); } function getData($page,$searchOn){ ### Function to retrive all page data from database #### /* Date: 07.13.06     Varible structure: VARIABLE_title_NUMBER, VARIABLE_description_NUMBER, VARIABLE_url_NUMBER where NUMBER is the link number on the page & VARIBLE is what section of database to look under, all three should be used on each link line [color=orange]example: <a title="<? echo $VARIABLE_description_NUMBER; ?>" href="<? echo $VARIABLE_url_NUMBER; ?>"><? echo $VARIBLE_title_NUMBER; ?></a>[/color] */ //create a plural variable for the DB query $plural = $searchOn."s"; //include my hook into the database include('dbhook.php'); //connect to mySQL mysql_connect(localhost,$username,$password); //select the correct database @mysql_select_db($database) or die("I am sorry but I do not see the database you requested"); //assign query variables $query="SELECT aagtest.$plural.".$searchOn."_title, aagtest.$plural.".$searchOn."_description, aagtest.$plural.".$searchOn."_url, aagtest.$plural.active FROM aagtest.pages LEFT JOIN aagtest.$plural ON aagtest.pages.page_id = aagtest.$plural.page_id WHERE aagtest.$plural.page_id =$page"; //perform querys $result=mysql_query($query); $totalNumberOfFields=mysql_num_fields($result); $totalNumberOfFields=$totalNumberOfFields-1; //set arrays for processing returned results $myLinks=array(); //determine row amounts $num=mysql_num_rows($result); #loop through returned results and dynamically create varibles #assign these varible names to dynamically created array values $linkNum=0; for($i=0;$i<=($num-1);$i++){ for($z=0;$z<=($totalNumberOfFields-1);$z++){ $myColumnHeading=mysql_field_name($result,$z); $myVar=$myColumnHeading."_".$linkNum; $info=@mysql_result($result,$linkNum,$myColumnHeading); $myLink=$myVar; $$myLink=$myLinks[$linkNum][$z]=$info; } $linkNum++; } mysql_close(); } ?>
  3. Hello, I have an issue that I cannot seem to resolve using XML and PHP. [b]Given:[/b] The XML [a href=\"http://www.aagrating.com/19space.xml\" target=\"_blank\"]19space.xml[/a] The XSL [a href=\"http://www.aagrating.com/format.xsl\" target=\"_blank\"]http://www.aagrating.com/format.xsl[/a] The CSS [a href=\"http://www..agrating.com/table.css\" target=\"_blank\"]http://www..agrating.com/table.css[/a] Given this setup I would like to be able to filter my data given a PHP variable (i.e. form submits, loads XML and filters based off of user input). I can use xpath to output the format to a table correctly, but when I attempt to set a variable for XPath it locks up. the php script:[a href=\"http://www.aagrating.com/xmlTest.txt\" target=\"_blank\"]xmlTest.php[/a] I have attempted to use "$myVar", '$myVar' " '+myVar+' ", but I cannot find the correct syntax. Is this eveb possible? Any thoughts? Thanks in advance! -thom
×
×
  • 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.