This topic is locked
[SOLVED]

 Trying to get a link to child table

8/4/2017 10:15:00 AM
PHPRunner General questions
S
swanside author

Hi Guys

I have this code.

SELECT

ID,

Make,

Model,

SerialNumber,

concat('http://localhost/qrtest/MotorMaintenance_list.php?masterkey1=$data["ID"]&mastertable=Motor''>http://localhost/qrtest/MotorMaintenance_list.php?masterkey1=$data["ID"]&mastertable=Motor';) AS LiveurlText

FROM Motor


But I am trying to get this to work, Instead of clicking on the child table, just have a link to click on, that will go to the table for inputting data in the MotorMaintenance_list page from the Motor ID page? But I cant figure it out.

concat('http://localhost/qrtest/MotorMaintenance_list.php?masterkey1=$data["ID"]&mastertable=Motor''>http://localhost/qrtest/MotorMaintenance_list.php?masterkey1=$data["ID"]&mastertable=Motor';) AS LiveurlText


Anybody suggest please?

Thanks

jadachDevClub member 8/4/2017

You need to add the html tags (<a href...) to make it clickable, then make sure it is set as view as html

S
swanside author 8/4/2017



You need to add the html tags (<a href...) to make it clickable, then make sure it is set as view as html


Cheers.

I have it set as a QR Code, but I am struggling getting the masterkey1=$data["ID"]

It just shows the text and not getting the ID. I have something wrong with the masterkey1=$data["ID"] setup
Cheers

jadachDevClub member 8/4/2017

Try adding this right in your SQL Query:

'http://localhost/qrtest/MotorMaintenance_list.php?masterkey1='+CONVERT(varchar(10), ID) AS LiveurlText


I am using SQL Server.

S
swanside author 8/4/2017

Thnaks, but im on MySQL. I tried it anyway and it throws back an error with the convert in it.

Thanks anyway <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=82828&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />



Try adding this right in your SQL Query:

'http://localhost/qrtest/MotorMaintenance_list.php?masterkey1='+CONVERT(varchar(10), ID) AS LiveurlText


I am using SQL Server.

admin 8/4/2017

You should not be using PHP code in your SQL like $data["ID"]. You can use string values and field names there:

https://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_concat

https://www.tutorialspoint.com/mysql/mysql-concat-function.htm
You should not include 'localhost' in the URL either, your solution will not be portable.

SELECT

ID,

Make,

Model,

SerialNumber,

concat('MotorMaintenance_list.php?masterkey1=', ID , '&mastertable=Motor') AS LiveurlText

FROM Motor
S
swanside author 8/4/2017

Cheers Sergey

Cant believe I was in fact trying too hard to get the ID and not just using ID!!!

The localhost is only for testing out, it will be replaced by the IP address once I get it working

Cheers



You should not be using PHP code in your SQL like $data["ID"]. You can use string values and field names there:

https://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_concat

https://www.tutorialspoint.com/mysql/mysql-concat-function.htm
You should not include 'localhost' in the URL either, your solution will not be portable.

SELECT

ID,

Make,

Model,

SerialNumber,

concat('MotorMaintenance_list.php?masterkey1=', ID , '&mastertable=Motor') AS LiveurlText

FROM Motor