Jump to content

Change text based on database content?


JackW

Recommended Posts

Change text based on database content?I have a database full of items in several categories.Examples are:Cowhide/Leather Milano style FurnitureCowhide/Leather Remington style FurnitureCowhide/Leather Winchester style FurnitureLampsAccessoriesPine FurnitureEtc.What I want to do is write a code so when a link is clicked and the description page comes up the description for any item with Cowhide/Leather in the category name has some different text than what is on all the other pages. Example: This is a special order item.The code I have below seems to work for Cowhide/Leather Milano style Furniture. Is there a way I can write it so that it will echo the correct text for all of the categories that contain the word Cowhide/Leather?Your help will be greatly appreciated.

<?php$code=$_GET['code'];$style='Cowhide/Leather Milano style Furniture';@ $db = mysql_pconnect('myserver.net', 'mydatabase', 'password');mysql_select_db('mydatabase') or die( "Unable to select database");{$query= "select * from `table` where `ID` = '".$code."' order by ID DESC";$query_results=mysql_query($query);$match_results=mysql_num_rows($query_results);}for ($i=0; $i < $match_results; $i++){$row=mysql_fetch_array($query_results);if($row ['category'] ==$style){echo '<p class="centerbrown">';echo 'Write Something here';echo '</p>';}else{echo '<p class="centerbrown">';echo'Write something Different';echo '</p>';}}mysql_close($db);?>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...