Jump to content

how to make link that selects certain stuff


cerberus478

Recommended Posts

Hi I would like to know how to make a link select certain stuff from the database. For example the link called cape town with the id 11 is selected then the link must search through the events table for the city_id 11 and take that information and display it in another page.

 

I would like to know how to do that or can you let me know of place that I can look. I have tried google but I don't know how to put what I'm looking for in words

Link to comment
Share on other sites

In a PHP page, use the following code

 

<?php

echo $_GET['id'];

?>

 

Call that page using page.php?id=7

 

Hope this is a good start. Keep in mind, a user can enter anything as ?id so you should verify that it contains a number before using it in a query.

Link to comment
Share on other sites

I get this error

 

Warning: require_once(local.firecracker.co.za-404.html): failed to open stream: No such file or directory in /var/websites/local.firecracker.co.za/controller/seo_uris.controller.php on line 127 Fatal error: require_once(): Failed opening required 'local.firecracker.co.za-404.html' (include_path='.:/usr/share/php:/usr/share/pear') in /var/websites/local.firecracker.co.za/controller/seo_uris.controller.php on line 127

 

I have this in the listing.php page

<?php 
$cities_model = new cities_model('cities');
$cities = $cities_model->get_all();

foreach($cities as $city){
	$name = $city['name'];
	echo "<table>";
echo "<tr>";
echo "<td>";
echo "<a href=/events/view/".$city['id'].">$name</a>";
echo "</td>";
echo "</tr>";
echo "</table>";

}
?>

and I have this in the view.php page
[code]
<?php 
echo $_GET['id'];

?>

[/code]

 

Link to comment
Share on other sites

So.. apparently after figuring out how to use $_GET variables, you received this error

Warning: require_once(local.firecracker.co.za-404.html): failed to open stream: No such file or directory in /var/websites/local.firecracker.co.za/controller/seo_uris.controller.php on line 127 Fatal error: require_once(): Failed opening required 'local.firecracker.co.za-404.html' (include_path='.:/usr/share/php:/usr/share/pear') in /var/websites/local.firecracker.co.za/controller/seo_uris.controller.php on line 127

 

Which translates very easily to..

Warning: require_once(local.firecracker.co.za-404.html): failed to open stream: No such file or directory in /var/websites/local.firecracker.co.za/controller/seo_uris.controller.php on line 127

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.