₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,458 members, 8,422,171 topics. Date: Sunday, 07 June 2026 at 07:35 PM

Toggle theme

Php/mysql Help:how To Run Sql Query From A Link - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingPhp/mysql Help:how To Run Sql Query From A Link (7089 Views)

1 Reply (Go Down)

Php/mysql Help:how To Run Sql Query From A Link by GoodMuyis(op): 5:44pm On Oct 07, 2011
Hello friend I need some help on How i can  Execute sql query from a link as in :
 
<a>Edit</a>


Where the link will point to PHP file and at end echo[/b]some stuff out
please attach some cash of code to your answer to help me much while i keep Goooogling

What i really want to do is display row of result like below

Name | ID |
==================
Shola |256 | Edit
John | 128 |Edi

Here Edit will be a link [b]<a>Edit</a>
to a PHP page
Where the result will be handle by html form, Which Am sure i can handle
Regards
Re: Php/mysql Help:how To Run Sql Query From A Link by dellnet: 6:20pm On Oct 07, 2011
You can pass querystring to your php file. For example you <a href="http://example.com/phpfile.php?q=shola">click here to get shola's id</a>

in the php file you do

$query_from_a = $_REQUEST['q'];

$sqlquery= "SELECT ID FROM table_name WHERE Name='".$query_from_a."'";
Re: Php/mysql Help:how To Run Sql Query From A Link by Mobinga: 1:25am On Oct 08, 2011
Re: Php/mysql Help:how To Run Sql Query From A Link by GoodMuyis(op): 11:18am On Oct 08, 2011
dell_net:
You can pass querystring to your php file. For example you <a href="http://example.com/phpfile.php?q=shola">click here to get shola's id</a>

in the php file you do

$query_from_a = $_REQUEST['q'];

$sqlquery= "SELECT ID FROM table_name WHERE Name='".$query_from_a."'";
Mobinga:
http://goodmuyis.com/profile?get=lols

Use the $_GET array!!
Thank You guys for the help all work well my Own code below


<a href='updateEntry.php?edit=$getReport[studentID]
,
$request = $_REQUEST['edit'];

$sql = mysql_query("SELECT *FROM student, accomodation, class, guardian,passport WHERE student.studentID=$request\n"
. "AND accomodation.accomodationID=$request\n"
. "AND class.classID=$request\n"
. "AND guardian.guardianID=$request\n"
. "AND passport.passportID=$request\n"
. "LIMIT 1"wink;
Re: Php/mysql Help:how To Run Sql Query From A Link by Mobinga: 11:49am On Oct 08, 2011
Be careful, always use mysqli_real_escape_string(); to escape your data.

Somebody can just do this goodmuyis.com/mysql.php?q=DROP%20DB;
Re: Php/mysql Help:how To Run Sql Query From A Link by GoodMuyis(op): 2:57pm On Oct 08, 2011
Mobinga:
Be careful, always use mysqli_real_escape_string(); to escape your data.

Somebody can just do this goodmuyis.com/mysql.php?q=DROP%20DB;
Yea thank you i won't play with that, even thought i don;t care much about the project
Re: Php/mysql Help:how To Run Sql Query From A Link by dellnet: 4:47am On Oct 09, 2011
<a href='updateEntry.php?edit=$getReport[studentID] huh?

where did you get with it?
Re: Php/mysql Help:how To Run Sql Query From A Link by GoodMuyis(op): 10:59am On Oct 11, 2011
dell_net:
<a href='updateEntry.php?edit=$getReport[studentID] huh?

where did you get with it?
The above is from my project Code file although written badly


Pls Guys is OK to do SQL Query(MySQL) like this from PHP although i have not tried it "

$search = $_POST['search'];

$sql = "SELECT FROM one, two, three WHERE one.ID=$search OR two.ID=$search or three.ID=$search"
Re: Php/mysql Help:how To Run Sql Query From A Link by dellnet: 1:44pm On Oct 11, 2011
GoodMuyis:
The above is from my project Code file although written badly


Pls Guys is OK to do SQL Query(MySQL) like this from PHP although i have not tried it "

$search = $_POST['search'];

$sql = "SELECT FROM one, two, three WHERE one.ID=$search OR two.ID=$search or three.ID=$search"
Be wary of security issues if you are deploying it to the internet.
1 Reply

How To Make a DESKTOP Executable Software Using PHP,MYSQL,SQLITEUrgent Help On Sparql Query OntologyTrying To Run Php Project After Installing Wamp Server234

Pattern Chaser In Javascript: Coding ChallengeSorting Out A Simple Text Dictionary With PHPNew Private Spamming Tutorials 2016 + Tools + Video