Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to recognise variables

Status
Not open for further replies.

keepingbusy

Programmer
Apr 9, 2000
1,470
GB
Hello guys,

Not sure where to start with this one so I will try and explain it in my own way.

First off I have a line of script that we previously inserted in between some HTML coding on a web page for individual items. Here is the code:
Code:
<script language="javascript" src="[URL unfurl="true"]http://www.oursite.com/users/ourfile.php?cid=2"></script>[/URL]
This was straight forward as the page identified the cid number and associated that with the page shown.

On another website (PHP) I have some other information I would like to link back to the above by inserting the code into a PHP file.

The new site has three common fields (If that is the right description). The fields are called fatherID (Int 11) ListingID (Int 11) and TypeID (Int 11). These fields are also present in the other table.

So what I want it to do is when someone looks at a record/item on the PHP site (Let's say for example, that items unique ID numbers are fatherID=34&ListingID=5&TypeID=45 (but of course, these could be fatherID=34&ListingID=4&TypeID=34 or any other reference numbers stored in the table), I want the first code to be able to know that the fatherID, ListingID and TypeID matches.

I really hope that makes some sense and I apologise in advance if I have not made this very clear.

Please let me know if I can supply any further information and your guidance not the solution would be most advantageous.

Many thanks
Lee
 
Its not very clear what you want, and you are using javascript which has no real bearing on PHP to exemplify, making it even more confusing.

Still if miraculously i understand what you mean, you want to create links based on items in your database. A link for each item, so when you click on them it displays some more information based on on the fatherID ListingID TypeID
variables.

Am I close?

If not maybe you could try to explain a bit more what you want.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 

Hi

Yes. You are close but I will work out an easier way to try and explain this and post back tomorrow. Thank you for the quick reply.
 
Website 1

We have been using a website to display rental properties. Each property information page has been created separately to show the details e.g. layout, rooms etc. As part of that display page we have a separate database where the owners of those properties can update their own availability calendars via a website log in. There is a piece of php code that is inserted into the html code for the above property description, of which, each one has its own unique reference number and variable:

Example: 34 or 45 or 121 etc

The variable for this unique reference number is cid

Website 2

On a different website (php based) there is another separate database that also stores rental properties but with a different category. Each property that is created on this site comes with a set of unique reference numbers:

Example: fathered=38&ListingID=5&TypeID=45

When each page is displayed on website 2, I want to insert the code from website 1
Code:
(<script language="javascript" src="[URL unfurl="true"]http://www.oursite.com/users/ourfile.php?cid=2"></script>)[/URL]
that will link the availability calendar to the rental property on website 2

So what we have is two separate tables, with two different identifying unique reference numbers but relating to the same rental property.

So from a users point of view, I update my calendar via a web log on and when I view my property on an other website I can see the calendar from website 1 showing with the details on website 2.

Just as a note in case you need to know:
“Why is there a separate calendar available for users to update themselves?”
This has been written in such a way that users can log in, change their own details, which then gives them the option to copy and paste code which can then be inserted into their websites if they have one. It makes sense to have one set of availability dates in one place but for use in multiple places.

I hope that is a clearer than my last post.

Thanks again in anticipation and as before, I would be grateful for some guidance.

Lee
 
can we assume that somewhere you keep a join table mapping one unique reference number to the other?
 

jpadie
can we assume that somewhere you keep a join table mapping one unique reference number to the other?
Both tables have the same unique fields as listed above allbeit, they are in two different databases.

Is that what you meant?

Lee
 
keepingbusy said:
Both tables have the same unique fields as listed above allbeit, they are in two different databases.
I think jpadie was asking if you have a join table associating a (fathered, ListingID, TypeID) with a cid. For example, something like this:
Code:
fathered | ListingID | TypeID | cid
---------+-----------+--------+----
      45 |        53 |     12 |   6
      47 |        12 |     43 |   9
      42 |        45 |     21 |   3
In that case, when you pull the record for the page on site 2, you could simply join on this table and pull in the corresponding cid at the same time.

I'm not really clear on how the databases are working here. Do you have a table like the one above? If the rental properties table at site 2 looks up records by (fathered, ListingID, TypeID), where does that database store the cid used by site 1? And how do you determine that a particular set of (fathered, ListingID, TypeID) and a particular cid correspond to the same property?
 

Adahacker
... if you have a join table associating a (fathered, ListingID, TypeID) with a cid. For example, something like this:
What we have is two seperate websites with two separate databases containing tables. One of the tables has the calendar tables (thats the one with the variable cid) and the other table has the fatherID, ListingID, TypeID variables. What I have done is added some additional fields to the calendar table to match that of the second table.

I don't know that I may be confusing the issue here and perhaps not able to explain this clearer.

In a nutshell, I want someone to be able to do a search on website 2, find a property rental and then half way down the page it will show the calendar from Website 1 that relates to the property shown on screen from website 2.

I want to the link the two by a variable if possible.

Really appreciate your answers so far.
 
unless there is a link table that you maintain on one or both sites, i cannot see how one set of code will dynamically know the right uniqueID to pass to the user. to be able to update the other site.

the usual course of action here is to centralise the database. if the websites are not physically colocated, then you would either need to create an external link to the database (open the right ports) or create a query API via a webservice.
 

jpadie

Many thanks. I will consider moving the database then to the same server.
 
Ok, here is some code that might make it easier to explain. This is the code that is used from website 1 (I have changed the address but the variables are as is:
Code:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="[URL unfurl="true"]http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"[/URL] width="250" height="209" align="middle">
	<param name="allowScriptAccess" value="sameDomain" />
	<param name="movie" value="[URL unfurl="true"]http://www.ourwebite.com/users/thefile.swf?link=http://www.ourwebite.com/users/our-data.php&[/URL][b]cid[/b]=$Link&owner=website.com" /><param name="quality" value="high" />
	<param name="bgcolor" value="#FFFFFF" />
	<embed src="[URL unfurl="true"]http://www.www.ourwebite.com/users/thefile.swf?link=http://www.ourwebite.com/users/our-data.php&[/URL][b]cid[/b]=$Link&owner=ourwebsite.com" quality="high" bgcolor="#FFFFFF" width="250" height="209" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="[URL unfurl="true"]http://www.macromedia.com/go/getflashplayer"[/URL] />
</object>
So as you can see there is a variable cid above but in the table its actually ID (INT 11).

Now on our other website in the show.php file, about halfway down I want to insert the above code but have the cid variable recognise a field in the property table that is called calurn (INT 11)

I read up on variables and tried adding the following at the start of the php file:
Code:
$calListingID=calurn
and then changed the cid to
Code:
.... users/our-data.php&[b]calurn[/b]=$Lin....
and
Code:
.... users/our-data.php&[b]$calurn[/b]=$Lin....
but this threw up errors.

I also tried:
Code:
If ($calurn > 0) {
  // Show the code above
}  elseif ($calTypeID < 1) {
  Echo (“Availability calendar to be updated”) ;
}
Am I on the right track guys or two steps back from last time?
 

Well finding the variable value and assigning it to another was straight forward:
Code:
$callink = $_GET['ListingID'] ;
Can any assist with the correct coding now to replace the below with the $callink variable?
Code:
....ourwebite.com/users/our-data.php&[b]cid[/b]=$Link&owner
Almost there (I think)
Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top