Web Hosting Talk







View Full Version : Existing Values


ti_nhatrang
07-29-2007, 03:40 PM
Hi guys,

I have existing values on my index.php like, $car, $boat, etc, on my existing index.php page... however, my ajax page can't use it... looks like i have to put the whole ./config.php and mysql select commands into that ajax page in order for it to work...

can somebody please guide me to an easier way to do this?

thank you in advance.

Steve_Arm
07-29-2007, 03:51 PM
Provide some details. Are you trying to pass variables to a php page from a js page?

ti_nhatrang
07-29-2007, 08:09 PM
yes, perhaps... it's a ajax page: http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/index.htm

that's what I'm using...

ti_nhatrang
07-29-2007, 08:35 PM
this is what I have on my called out ajax/js page:


$attach2_db = mysql_query("SELECT attachmentid from tb_vbnews.attachment WHERE postid=$fpid ORDER BY dateline DESC LIMIT 3") or die(mysql_error());

while($attach2 = mysql_fetch_array($attach2_db)) {

echo "<a href=\"/news1/attachment.php?attachmentid=$attach2[attachmentid]\" rel=\"enlargeimage::click\" rev=\"loadarea\"><img src=\"/news1/attachment.php?attachmentid=$attach2[attachmentid]\" width=\"126\" height=\"110\" alt=\"$girl_title\" border=\"0\" /></a>";

}

foobic
07-29-2007, 09:01 PM
looks like i have to put the whole ./config.php and mysql select commands into that ajax page in order for it to work...If I understand that right, yes you will. Each AJAX request is a new request quite separate from the original page load - your PHP script will need to connect to the database, make any required queries and generate the response. And don't forget to sanitize any input data from the AJAX request...

ti_nhatrang
07-29-2007, 09:03 PM
oh boy, is there anyway we grab the $values from the original main page php file?

foobic
07-29-2007, 09:14 PM
Only if you cache them somehow. But if you can do that you probably don't need AJAX - could you just load all the content into hidden divs in the first place?

ti_nhatrang
07-29-2007, 09:15 PM
oh yeah! that's a great idea! How would I go about hidding the div and then making it apear when click on that tab?