Hello All,
This is my very first post and my very first attempt at coding (as I recently took up trying to learn php/mysql).
I'm trying to create a "printer friendly version" of my dynamic web pages.
My URLs typically look like this:
I'm trying to strip everything except for the actual id number (after the second =)
Heres my code so far:
<?PHP
$db_name = "database";
$link = mysql_connect("localhost", "user", "passwd") or die("Could not connect to server!");
?>
<?PHP
$articlenum = trim or parse url to id number after second =;
if ($articlenum != '') {
$query = "SELECT id, title, text FROM articles WHERE (id " . $articlenum . ") ";
$select_db = mysql_select_db($db_name, $link);
$results = mysql_query($query, $link) or die("Could not complete database query");
$num = mysql_num_rows($results);
if ($num != 0) {
while ($row = mysql_fetch_array($results)) {
echo "<b>$row[title]</b><br /><br />$row[text])<br />";
}
} else {
echo "<font color=red>Nothing to Print</font><br>";
}
}
?>
I read up on the parse_url function but I didn't understand how to use it here.
Thanks in advance. I look forward to learning possible solutions for this scenario.
This is my very first post and my very first attempt at coding (as I recently took up trying to learn php/mysql).
I'm trying to create a "printer friendly version" of my dynamic web pages.
My URLs typically look like this:
Code:
http://www.domain.com/dir/?act=article&id=9
I'm trying to strip everything except for the actual id number (after the second =)
Heres my code so far:
<?PHP
$db_name = "database";
$link = mysql_connect("localhost", "user", "passwd") or die("Could not connect to server!");
?>
<?PHP
$articlenum = trim or parse url to id number after second =;
if ($articlenum != '') {
$query = "SELECT id, title, text FROM articles WHERE (id " . $articlenum . ") ";
$select_db = mysql_select_db($db_name, $link);
$results = mysql_query($query, $link) or die("Could not complete database query");
$num = mysql_num_rows($results);
if ($num != 0) {
while ($row = mysql_fetch_array($results)) {
echo "<b>$row[title]</b><br /><br />$row[text])<br />";
}
} else {
echo "<font color=red>Nothing to Print</font><br>";
}
}
?>
I read up on the parse_url function but I didn't understand how to use it here.
Thanks in advance. I look forward to learning possible solutions for this scenario.
Last edited by a moderator: