Hello there smart fella!
I'm gonna explain this as good as I can whit my bad English, and my even worse php-skilllzzz
I've got, as usual, a header.php, where i store the code:
This basically gives me the IDs of the table and echo out them in a <A> tag with the correct name.
In my index.php I have the code:
So, when I click the link in the header it leads to:
mypage/?action=viewInfo&staticinfoId=1
And here I want to display the info from the database with the Id=1, (or 2 depending on the <A tag>) and the content.
Right now in viewInfo.php, I got it to work with:
But I just want to display the name and text related to the Id=1, not the whole content from every Id.
The foreach{} gives me everything, as it gets all content from the DB.
But how do I manage to get just the name and text for Id 1?
Probably kind of basic, but I'm stuck and I need a smart and skilled person to help me aout
Best regards,
JJ
I'm gonna explain this as good as I can whit my bad English, and my even worse php-skilllzzz

I've got, as usual, a header.php, where i store the code:
<?php
$query = "SELECT id, name FROM staticinfo";
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
while($row = mysql_fetch_array($result))
{ echo "
<li><a href=.?action=viewInfo&staticinfoId=$row[id]>$row[name]</a></li>";
}?>
This basically gives me the IDs of the table and echo out them in a <A> tag with the correct name.
In my index.php I have the code:
$results = array();
$data = Info::getList();
$results['staticinfo'] = $data['results'];
$results['pageTitle'] = "Info | ";
require( TEMPLATE_PATH . "/viewInfo.php" );
So, when I click the link in the header it leads to:
mypage/?action=viewInfo&staticinfoId=1
And here I want to display the info from the database with the Id=1, (or 2 depending on the <A tag>) and the content.
Right now in viewInfo.php, I got it to work with:
<?php foreach ( $results['staticinfo'] as $info ) { ?>
<h3><?php echo $info->name?></h3>
<p><?php echo $info->text?></p>
<?php } ?>
But I just want to display the name and text related to the Id=1, not the whole content from every Id.
The foreach{} gives me everything, as it gets all content from the DB.
But how do I manage to get just the name and text for Id 1?
Probably kind of basic, but I'm stuck and I need a smart and skilled person to help me aout

Best regards,
JJ



