Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 14th, 2014, 03:58 AM
Registered User
 
Join Date: Jun 2013
Posts: 9
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Hello,
i am new in php.
i want to get value from url and retrieve the info from database to other page,
please help.

here is url value

PHP Code:
http://localhost/ad_Display.php?id=1&cat=1&ut=s

where cat category and ut usertype 
here is my code.

PHP Code:
<?php

include_once ("dbconnect.php");
$id "";

if (isset(
$_GET['id'])) {
     
$id preg_replace('#[^0-9]#i'''$_GET['id']);
   }
$id preg_replace('#[^0-9]#i'''$id);



$sql_post mysql_query("SELECT * FROM adpost WHERE id='$id' LIMIT 1");

while(
$row mysql_fetch_array($sql_post)){
    
    
$postid $row["id"];
    
$category $row["category"];
    
$usertype $row["usertype"];
    
$adtitle $row["adtitle"];
    
$cond $row["cond"];
    
$price $row["price"];
    
$stype $row["stype"];;
    
$sloc $row["sloc"];
    
$sarea $row["sarea"];
    
$slandmark $row["slandmark"];
    
$postdate $row["postdate"];
    
$convertedTime = ($myObject -> convert_datetime($postdate));
    
$whenPost = ($myObject -> makeAgo($convertedTime));
}

if (isset(
$_GET['category'])) {
     
$category $_GET['category'];
   }
   
if (isset(
$_GET['usertype'])) {
     
$usertype $_GET['usertype'];
   }

$sql mysql_query("SELECT * FROM adpost WHERE category='$category'  AND usertype='s' ORDER BY postdate DESC LIMIT 5" );

$adDisplayList "";
$numRows mysql_num_rows($sql);
if (
$numRows 1) {
    
$adDisplayList "There are no Ad in this Category yet. You can be the first to post.";
} else {    
$adDisplayList .= '<a href="http://p2p.wrox.com/ad_Display.php?id=' $postid '&cat=' $category '&ut=' $usertype '"><div id="adlist" onmouseover="this.style.background=\'#555\';" onmouseout="this.style.background=\'#333\';">
         <table width="100%" height="100%" border="0">
           <tr>
             <td width="18%" rowspan="3" valign="middle"><div style="width: 95px; height: 90px; padding-left:5px;"><img src="http://p2p.wrox.com/images/photo_not_available_small.jpg" width="100" height="90" /></div></td>
             <td height="39" colspan="3" valign="top"><p>
             <div style="padding-left:10px;"><font class="fontsz1" color="#C93"><strong> ' 
$adtitle'</strong></font> - ' $cond '</div></td>
             </tr>
           <tr>
             <td height="24" colspan="3"> &nbsp;<font class="fontsz" color="#999">  ' 
$sloc' | ' $sarea' | ' $slandmark ' </font></td>
             </tr>
           <tr>
             <td width="32%" height="24"><div id="prctab"> &nbsp;' 
$price ' </div></td>
             <td width="25%"> &nbsp;<font class="fontsz" color="#999"> ' 
$whenPost ' </font></td>
             <td width="25%">&nbsp;<font class="fontsz" color="#999"> ' 
$stype ' </font></td>
           </tr>
         </table>
       </div></a>'
;
    }
?>

I want to display all ad using category and user type. but getting error undefined index: category & usertype
plz help.
thanks

Last edited by farwall.ghost; January 14th, 2014 at 04:03 AM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to retrieve PUBLIC FOLDER INFO using MAPI shivaraj.malannavar Classic ASP Basics 1 November 30th, 2006 12:42 PM
Retrieve Info from Database miniskirt Classic ASP Basics 0 November 2nd, 2006 04:35 AM
URL INFO knowledege HTML Code Clinic 1 January 20th, 2005 03:01 AM
Retrieve info about Lookup RowSource for a table c Proteus_3k Pro VB Databases 0 December 2nd, 2004 07:05 AM
Retrieve Info... betzy XML 7 June 4th, 2004 02:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.