Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
php/mysql help can some fix or tell me how to please
Old 05-21-2009, 02:36 AM php/mysql help can some fix or tell me how to please
Junior Talker

Posts: 3
Trades: 0
ok i got a code that display the mysql query file it all works good
but i only what it to output the row with the same catid number for a ex(if u click on
<code><a href='$pagename.php?act=view&id=$id&cat=$catid'>$n ame</a><br /></code>) i wants to only get the rows with the catid 5 or 6 or what ever name is that link when its click on. can some please please fix this for me

heres my code
categorie.php this show the links to the next page that will display subcategories
Code:
<?
  include("conn.php");
 $pagename ="subcategories"; $table = site_post; $tableid = catid;
 $max = 25;
/*$qset = "select * from $table";
$rset = mysql_query($qset) or die(mysql_error());
$r = mysql_fetch_array($rset);*/

$p = $_GET['p'];
if(empty($p))
{
$p = 1;
}
$limits = ($p - 1) * $max;
$sql = mysql_query("SELECT * FROM $table LIMIT ".$limits.",$max") or die(mysql_error());
//the total rows in the table
$totalres = mysql_result(mysql_query("SELECT COUNT($tableid) AS tot FROM $table"),0);
//the total number of pages (calculated result), math stuff...
$totalpages = ceil($totalres / $max);
//the table
while($r = mysql_fetch_array($sql))   {
$id = $r['catid'];
$catid = $r['catid'];
$name = $r['name'];
echo "<a href='$pagename.php?act=view&cat=$id'>$name</a><br />";
}
for($i = 1; $i <= $totalpages; $i++){
//this is the pagination link
echo "<a href='$pagename.php?p=$i'>$i</a>|";
}
 ?>
subcategorie.php this show the links to the next page that will display the items
Code:
<?
  include("conn.php");
 $pagename ="view"; $table = site_post; $tableid = id;
 $max = 25;
/*$qset = "select * from $table";
$rset = mysql_query($qset) or die(mysql_error());
$r = mysql_fetch_array($rset);*/

$p = $_GET['p'];
if(empty($p))
{
$p = 1;
}
$limits = ($p - 1) * $max;
$sql = mysql_query("SELECT * FROM $table LIMIT ".$limits.",$max") or die(mysql_error());
//the total rows in the table
$totalres = mysql_result(mysql_query("SELECT COUNT($tableid) AS tot FROM $table"),0);
//the total number of pages (calculated result), math stuff...
$totalpages = ceil($totalres / $max);
//the table
while($r = mysql_fetch_array($sql))   {
$id = $r['id'];
$catid = $r['catid'];
$name = $r['name'];
echo "<a href='$pagename.php?act=view&cat=$catid'>$name</a><br />";
}
for($i = 1; $i <= $totalpages; $i++){
//this is the pagination link
echo "<a href='$pagename.php?p=$i'>$i</a>|";
}
 ?>
view.php this will view the list from the id that was sent this work fine its the top im haveing a time with
Code:
include("conn.php");
$table= site_post; $tableid= id;
$max = 10; //amount of articles per page. change to what to want
$p = $_GET['p'];
if(empty($p))
{
$p = 1;
}
$limits = ($p - 1) * $max;
//view the news article!
if(isset($_GET['act']) && $_GET['act'] == "view")
{
$id = $_GET['id'];
$catid = $_GET['catid'];
$sql = mysql_query("SELECT * FROM $table WHERE $tableid = '$id'" );
while($r = mysql_fetch_array($sql))
{
echo "<div style=\"position: absolute; top:150px; left: 240px\">
<div>";
 if($r["images1"]==""){
        echo "<img src=\"images/noimage.jpg\" width=\"99\" height=\"99\">";
              }else{
        echo '<a target="_blank" href="images/'.$r["images1"].'"><img src="images/'.$r["images1"].'" border="0" width="120" height="100" hspace="1" vspace="1"></a>';
        }
 if($r["images2"]==""){
         }else{
echo '<a target="_blank" href="images/'.$r["images2"].'"><img src="images/'.$r["images2"].'" border="0" width="120" height="100" hspace="1" vspace="1"></a>';
 }
  if($r["images3"]==""){
}else{
echo '<a target="_blank" href="images/'.$r["images3"].'"><img src="images/'.$r["images3"].'" border="0" width="120" height="100" hspace="1" vspace="1"></a>';
}
if($r["images4"]==""){
          }else{
echo '<a target="_blank" href="images/'.$r["images4"].'"><img src="images/'.$r["images4"].'" border="0" width="120" height="100" hspace="1" vspace="1"></a></div>';
}
echo '<br>';

 if($r[resume]==""){
          echo '<br>No Info Text Found<br><a class="link1" href="javascript:history.back();">Back</a>';
          }else{
echo '<div style="width:658px; text-indent:8px;">'.$r["resume"].'</div>
<a class="link1" href="javascript:history.back();">Back</a>
</div>';
}
}
}
mysql
Code:
CREATE TABLE `site_post` (
  `id` int(11) NOT NULL auto_increment,
  `catid` int(11) default NULL,
  `subcatid` int(11) default NULL,
  `catname` text,
  `name` text,
  `resume` text,
  `images1` text,
  `images2` text,
  `images3` text,
  `images4` text,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;
INSERT INTO `site_post` (`id`, `catid`, `subcatid`,`catname`, `name`, `resume`, `images1`, `images2`, `images3`, `images4`) VALUES
(1, 1,5, 'movies','name1', 'des gos here', '1.jpg', '', '', '')
(2, 2,1, 'tv shows','name2', 'des gos here', '3.jpg', '4.jpg', '', ''),
(3, 3,3, 'cars','name3', 'des gos here', '1.jpg', '3.jpg', '4.jpg', ''),
(4, 4,3, 'bikes','name4', 'des gos here', '1.jpg', '4.jpg', '', ''),
(5, 5,4, 'atv','name5', 'des gos here', '1.jpg', '2.jpg', '3.jpg', '4.jpg'),
(6, 6,4, 'flashgames',''name6', 'des gos here',  '1.jpg', '3.jpg', '', '');
this else so in mysql thread
chase2005 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to php/mysql help can some fix or tell me how to please
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.08476 seconds with 12 queries