Система за подаръци

kristiqn2

Registered
Здравейте,
Имам една система за подаръци но не мога да искарам в профила на някой какви подаръци има ето го кода за изпращане на подарък:
PHP:
<?php
				if($_POST['sendgif'])
				{
				echo "<br />";
				$username = addslashes(htmlspecialchars($_POST['username']));
				$giftid = $_POST['giftid'];
				$rq = mysql_query("SELECT * FROM `users` WHERE username='$username'") or die (mysql_error());
				$memNum = mysql_num_rows($rq) or die (mysql_error());
				if($memNum < 1) {
				echo "<div class='err'> Няма такъв потребител. </div>";
				}
				else {
				$me = $_SESSION['username'];
				$rq = mysql_query("INSERT INTO `gifts` (`id`, `uid`, `fid`, `giftid`) VALUES ('', '$me', '$username', '$giftid')") or die (mysql_error());
				echo "<div class='usp'>Успешно. </div>";
                }
				
				echo "<br/>";
				}
				?>
				<table>
				<tr><td>До:<input type="text" name="username" size="32" class="textarea"></td></tr>
				<tr><td></td></tr>
				
				<td class="b">
				<input type="radio" name="giftid" value="1" ><img src="gift/1.jpg" width="50" height="50"/> <input type="radio" name="giftid" value="2" ><img src="gift/2.jpg" width="50" height="50"/><input type="radio" name="giftid" value='3' ><img src="gift/3.jpg" width="50" height="50"/>
				<br />
				<input type="radio" name="giftid" value="4" ><img src="gift/4.jpg" width="50" height="50"/> <input type="radio" name="giftid" value="5" ><img src="gift/5.jpg" width="50" height="50"/> <input type="radio" name="giftid" value="6" ><img src="gift/6.jpg" width="50" height="50"/>
				<br />
				<input type="radio" name="giftid" value="7" ><img src="gift/7.jpg" width="50" height="50"/> <input type="radio" name="giftid" value="8" ><img src="gift/8.jpg" width="50" height="50"/><input type="radio" name="giftid" value="9" ><img src="gift/9.jpg" width="50" height="50"/>
				<br />
				<input type="radio" name="giftid" value="10" ><img src="gift/10.jpg" width="50" height="50"/><input type="radio" name="giftid" value="11" ><img src="gift/11.jpg" width="50" height="50"/> <input type="radio" name="giftid" value="12" ><img src="gift/12.jpg" width="50" height="50"/>
				<br />
				<input type="radio" name="giftid" value="13" ><img src="gift/13.jpg" width="50" height="50"/> <input type="radio" name="giftid" value="14" ><img src="gift/14.jpg" width="50" height="50"/><input type="radio" name="giftid" value="15" ><img src="gift/15.jpg" width="50" height="50"/>
				<br />
				<input type="radio" name="giftid" value="16" ><img src="gift/16.jpg" width="50" height="50"/><input type="radio" name="giftid" value="17" ><img src="gift/17.jpg" width="50" height="50"/> <input type="radio" name="giftid" value="18" ><img src="gift/18.jpg" width="50" height="50"/>



				
				
				</td>
				<input type="submit" name="sendgif" value="Прати" class="btn"></td></tr>
				</table>
				</form>
ето го и кода за изкарването:
PHP:
 <?php
include 'connect.php';
$user2 = htmlspecialchars($_GET['username']);
function security($var)
{
$var = trim($var);
$var = addslashes($var);
$var = htmlspecialchars($var);
return $var;
}

$q1 = mysql_query("SELECT * FROM `users` WHERE username = '".$user2."'") or die (mysql_error());
$rowuser = mysql_fetch_array($q1);

$q2 = mysql_query("SELECT * FROM `gifts` WHERE `fid` = '".$rowuser['username']."' ORDER by `id` DESC") or die (mysql_error());
while($rowgift = mysql_fetch_array($q2)){
if($rowgift['giftid']== 1){$gift="<img src='gift/1.jpg'/>";} if($rowgift['giftid']== 2){$gift="<img src='gift/2.jpg'/>";}
if($rowgift['giftid']== 3){$gift="<img src='gift/3.jpg'/>";} if($rowgift['giftid']== 4){$gift="<img src='gift/4.jpg'/>";}
if($rowgift['giftid']== 5){$gift="<img src='gift/5.jpg'/>";} if($rowgift['giftid']== 6){$gift="<img src='gift/6.jpg'/>";}
if($rowgift['giftid']== 7){$gift="<img src='gift/7.jpg'/>";} if($rowgift['giftid']== 8){$gift="<img src='gift/8.jpg'/>";}
if($rowgift['giftid']== 9){$gift="<img src='gift/9.jpg'/>";} if($rowgift['giftid']== 10){$gift="<img src='gift/10.jpg'/>";}
if($rowgift['giftid']== 11){$gift="<img src='gift/11.jpg'/>";} if($rowgift['giftid']== 12){$gift="<img src='gift/12.jpg'/>";}
if($rowgift['giftid']== 13){$gift="<img src='gift/13.jpg'/>";} if($rowgift['giftid']== 14){$gift="<img src='gift/14.jpg'/>";}
if($rowgift['giftid']== 15){$gift="<img src='gift/15.jpg'/>";} if($rowgift['giftid']== 16){$gift="<img src='gift/16.jpg'/>";}
if($rowgift['giftid']== 17){$gift="<img src='gift/17.jpg'/>";} if($rowgift['giftid']== 18){$gift="<img src='gift/18.jpg'/>";}
if($_SESSION['userinfo']['username']==$rowgift['fid'])
{$trii = "<a href='delgift.php?id=".$rowgift["id"]."'><br><img src='img/frminus.png' border='none'></a>";}

echo"<td class='b'>$gift <br />Подарил: <a href='$rowgift[uid].html'>$rowgift[uid]</a><br />$trii</td>";
}
?></table>
[sql]                    <?php $runq = mysql_query("SELECT * FROM `users` WHERE username='".$_GET['user']."'");
$row = mysql_fetch_array($runq); ?>
ето я таблицата users:
[sql]CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`username` varchar(15) NOT NULL,
`password` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`rd` varchar(255) NOT NULL,
`pol` varchar(255) NOT NULL,
`grad` varchar(255) NOT NULL,
`timeonline` varchar(255) NOT NULL,
`lastactive` varchar(255) NOT NULL,
`level` varchar(255) NOT NULL DEFAULT 'member',
`totalvotes` int(11) NOT NULL,
`totalscore` int(11) NOT NULL,
`averagerating` varchar(4) NOT NULL DEFAULT '10.0',
`vip` varchar(3) NOT NULL DEFAULT 'no',
`active` varchar(3) NOT NULL DEFAULT 'yes',
`osnovna` text NOT NULL,
`osnovna_normal` text NOT NULL,
`osnovna_big` text NOT NULL,
`nastroenie` text NOT NULL,
`userip` text NOT NULL,
`plus` int(11) NOT NULL,
`minus` int(11) NOT NULL,
`vidim` varchar(255) NOT NULL,
`teglo` varchar(255) NOT NULL,
`ochi` varchar(255) NOT NULL,
`rust` varchar(255) NOT NULL,
`kosa` varchar(255) NOT NULL,
`za` varchar(255) NOT NULL,
`obrazuvanie` varchar(255) NOT NULL,
`profesia` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=169 ;

--
-- Дъмп (схема) на данните в таблицата `users`
--

INSERT INTO `users` (`id`, `name`, `username`, `password`, `email`, `rd`, `pol`, `grad`, `timeonline`, `lastactive`, `level`, `totalvotes`, `totalscore`, `averagerating`, `vip`, `active`, `osnovna`, `osnovna_normal`, `osnovna_big`, `nastroenie`, `userip`, `plus`, `minus`, `vidim`, `teglo`, `ochi`, `rust`, `kosa`, `za`, `obrazuvanie`, `profesia`) VALUES
(167, 'kristiqn', 'krisko0o', '21b3de3ea1ecb7ef46df2500923c92bde1a7a5fc', 'krisko0o231@abv.bg', '23-01-1991', 'boy', 'Нови пазар', '1327172415', '21/01/2012 21:00:15', 'admin', 0, 0, '10.0', 'yes', 'yes', 'photo/krisko0o54237f7d26da6b54ded7a3accadcbeef_osnovna.jpg', 'photo/krisko0o54237f7d26da6b54ded7a3accadcbeef_osnovna_normal.jpg', 'photo/krisko0o54237f7d26da6b54ded7a3accadcbeef_osnovna_big_wt.jpg', 'krisko0o :p :p :p :p', '127.0.0.1', 3, 0, '', '42', 'кафяви', '156', 'Тъмно кестенява', 'Приятелство', 'Средно Училище', 'Ученик'),
(168, 'krisko0o', 'krisko0o0', '510213760129238adfcd1ba5054120136205542f', 'kristiqn3121@abv.bg', '23-01-1995', 'boy', 'Бургас', '1324320692', '19/12/2011 20:51:32', 'member', 0, 0, '10.0', 'no', 'yes', '', '', '', 'asdasd', '127.0.0.1', 0, 0, '', '0', 'кафяв', '- Посочете -', '', '-- Не е посочено --', 'Средно училище', 'Средно училище');
[/sql]
ето я и таблицата gifts:

CREATE TABLE IF NOT EXISTS `gifts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uid` varchar(255) NOT NULL,
`fid` varchar(255) NOT NULL,
`giftid` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=2 ;

--
-- Дъмп (схема) на данните в таблицата `gifts`
--

INSERT INTO `gifts` (`id`, `uid`, `fid`, `giftid`) VALUES
(1, 'krisko0o', 'krisko0o', '6');
[/sql]
 

kristiqn2

Registered
Разбрал си ме погрешно!
Имам проблем с изкарването!
Искам когато влезна в профила на някой да ми показва какви подаръци има той и от кой са изпратени но не ми излизат :(
 

Горе