I have the below code :
<?php
//Fetching the Category Name
$sql="SELECT * FROM subcategory WHERE CategoryID='$catid'";
$rs = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($rs)){
?>
<?php echo $row['SubCategoryName']; ?>
<?php } ?>
I have done a .htaccess file but still the rewrite is not working.
mysite/article.php?scid=9&page=1
I want them as mysite.com/categoryname_description_subcategoryname-1
You should alter the link names you've used in your design/html layout to the example I've posted below
<a href="question/categoryname/categoryid.html"</a>
Related
www.mydomain.com/filename/ instead of www.mydomain.com/file.php?id=1
currently im developing a Auto index site script
From index.php i had put a hyper link to download page Download page and on file.php page i had put
$id=$_REQUEST['id'];
$query = "update mydatabase SET views = views+1 where id ='".$id."'";
$update = mysqli_query($con,$query) or die(mysql_error());
$query = "SELECT * from mydatabase where id='".$id."'";
$result = mysqli_query($con,$query) or die(mysql_error());
$row = mysqli_fetch_assoc($result);
<?php echo $row['id'];?>
<?php echo $row['name'];?>
<?php echo $row['size'];?>
etc..
when i click on Download page it redirect me to www.mydomain.com/file.php?id=1 page and show the related file details.
But i really need to change the above url as www.mydomain.com/song/file-name
please can anybody advise or help me on this ??
Maybe you can try this on your download page.
history.replaceState(null, null, '/song/file-name')
I am trying to show it all with while loop on a dynamic page, but it wont show anything at all..
if (isset($_GET['id'])) {
$genre = $_GET['id'];
$sql = "SELECT * FROM movstream_genre WHERE ID = '$genre'";
$result = $db->query($sql);
$row = $result->fetch_assoc();
}else{
$sql = "SELECT ID, genre FROM movstream_genre";
$result = $db->query($sql);
}
<html>
<body>
<ul>
<?php while ( $row = $result->fetch_assoc() ): ?>
<li><?=$row['genre'];?></li>
<?php endwhile; ?>
</ul>
</body>
</html>
Anyone know why it wont show anything on the dynamic page, but if the page is not dynamic it works fine :)
Thanks.
If dynamic page means that your sending an id in Url an you are not getting result.
I think that the problem is that you are using $row = $result->fetch_assoc(); in if condition and also in while.
Please use fetching in one place. Better be in while loop.
Hope it helps.
I figured it out
if (isset($_GET['id'])) {
$genre = $_GET['id'];
$sql = "SELECT ID, genre FROM movstream_genre";
$result = $db->query($sql);
}
This it how it needs to look when its a dynamic page :)
well i think it is, it works now.
please echo the result ...
<li><?php echo $row['genre'];?></li>
And in href, it is only genre OR genre.php
In the first query..
$sql = "SELECT * FROM movstream_genre WHERE ID = '$genre'";
$result = $db->query($sql);
$row = $result->fetch_assoc();// this line not required
comment this line
$row = $result->fetch_assoc();
It looks like you haven't enclosed the first part of your PHP code in <?php ?> tags
I get my dynamic navigation menu from the database because I have a CMS, so here's my code:
<ul>
<?php
$result = mysql_query("SELECT id, name, DESCRIPTION FROM menu where VISIBLE='1' ORDER BY `order` ASC") or die(mysql_error());
while($row = mysql_fetch_array($result)){
printf('<li>%s %s </a></li> ', $row['name'],$row['DESCRIPTION']);
}
?>
to highlight the current page, i have to add this inside the li element
how should i do this? Thanks in advance.
u can try the following code
<?php
$currentpage = $_SERVER['REQUEST_URI'];?>
<ul>
<?php
$result = mysql_query("SELECT id, name, DESCRIPTION FROM menu where VISIBLE='1' ORDER BY
`order` ASC") or die(mysql_error());
while($row = mysql_fetch_array($result))
{
?>
<li<?php if(preg_match("/index/i", $currentpage)||($currentpage=="/")) { echo "
class='active'"; } ?>>Home</li>
<?
}
?>
instead of index you can also write $row[name] in a variable and replace /index/i with it
set a variable on the page like
$navlink = '<somevalue>'
and check the the value in li
<li <?php if($navlink == '<somevalue>') {echo "class='active'"}?>>
i think it will work.
I asked a question late last night and trying to work out a way to fix my issue
here
I included the link to the question encase it was relevant to this question
I am trying to display data from a file named example.php
in example.php i have the following code
<?php
//include database connection
include 'db_connect.php';
$query = "select id, name, surname
from contacts
where id='".$mysqli->real_escape_string($_REQUEST['id'])."'
limit 0,1";
$result = $mysqli->query( $query );
$row = $result->fetch_assoc();
$id = $row['id'];
$name = $row['name'];
$surname = $row['surname'];
?>
<?php echo$name; ?><br>
<?php echo$surname; ?>
so if i visited my page by going to example.php?id=100 it would display the client with the id off 100
but what i am trying to do is display this file depending on another table.
i have a table named repairs and in there is a column named client_id with is the same as the id of the contacts table.
I have tried to display the file by doing this.
<?php include'example.php?id=echo$client_id;'?>
But this did not work please advise me what the right code is and why this is wrong.
try:
<?php
$_REQUEST['id'] = $client_id;
include'example.php';
?>
I want to show MySQL data inside a tooltip.
Here is the code:
<?php
$abfrage = "SELECT * FROM tester";
$ergebnis = mysql_query($abfrage);
while($row = mysql_fetch_object($ergebnis)){
$Name=$row->Name;
$Bech=$row->Beschreibung;
}
?>
Test Link
It shows me an empty tooltip with nothing inside. If I print those two variables, the MySQL data appear. Is there any mistake in the code?
Thanks.
This is in conjunction with Seth McClaine's answer.
Echo your values using:
<?php echo $Name; ?> <?php echo $Bech; ?>
Instead of <?=$Name?> <?=$Bech?>
The use of short tags is not recommended for something like this.
Reformatted code:
<?php
$abfrage = "SELECT * FROM tester";
$ergebnis = mysql_query($abfrage);
$row = mysql_fetch_object($ergebnis);
$Name=$row->Name;
$Bech=$row->Beschreibung;
?>
Test Link
If you just want the first result remove the while...
<?php
$abfrage = "SELECT * FROM tester";
$ergebnis = mysql_query($abfrage);
$row = mysql_fetch_object($ergebnis);
$Name=$row->Name;
$Bech=$row->Beschreibung;
?>
Test Link