View unanswered posts | View active topics It is currently Mon Sep 15, 2014 6:27 pm



Reply to topic  [ 5 posts ] 
 Please help me. 
Author Message
Junior Member

Joined: Sat Jun 20, 2009 3:31 am
Posts: 5
Post Please help me.
Hello

I want insert:

$ids_arr[$i] = $ids;
$titles_arr[$i] = $titles;
$stars_arr[$i] = $stars;
$images_arr[$i] = $images;
$types_arr[$i] = $types;

in to my Table from database .

My Problem is: deta do not inserted Correctly in my Table- Please help me.

Thanks a lot
[php]<?php
include("config.php");

mysql_connect($db_server, $db_username, $db_password);
mysql_select_db($db_name);

$query = "SELECT COUNT(ID) FROM ads WHERE Stars=7 and Status=2";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$adcnt = $row[0];

$query = "SELECT * FROM ads WHERE Stars=7 and Status=2";
$result = mysql_query($query);
$i = 1;
while (($row = mysql_fetch_array($result)))
{
$rows[$i] = $row;
$i++;
}

$ids_arr = null;
$titles_arr = null;
$images_arr = null;
$stars_arr = null;
$types_arr = null;

for ($i=1; $i<=10; $i++)
{
$ids = null;
$titles = null;
$stars = null;
$images = null;
$types = null;

for ($j=1; $j<=4; $j++)
{
$cellno = ($i-1)*4+$j;

srand((double)microtime()*1000000);
$adno = mt_rand(1, ($adcnt));

$types[$j] = $rows[$adno][1]['mode'];
$ids[$j] = $rows[$adno][1]['ID'];
$titles[$j] = $rows[$adno][1]['Title'];
$stars[$j] = $rows[$adno][1]['Stars'];
$images[$j] = $rows[$adno][1]['Image'];
}
$ids_arr[$i] = $ids;
$titles_arr[$i] = $titles;
$stars_arr[$i] = $stars;
$images_arr[$i] = $images;
$types_arr[$i] = $types;
}
print( $cellno);

function show_ads()
{
for ($i=1; $i<=10; $i++)
{
$type1 = $GLOBALS['types_arr'][$i][1];
$type2 = $GLOBALS['types_arr'][$i][2];
$type3 = $GLOBALS['types_arr'][$i][3];
$type4 = $GLOBALS['types_arr'][$i][4];

$id1 = $GLOBALS['ids_arr'][$i][1];
$id2 = $GLOBALS['ids_arr'][$i][2];
$id3 = $GLOBALS['ids_arr'][$i][3];
$id4 = $GLOBALS['ids_arr'][$i][4];

$title1 = $GLOBALS['titles_arr'][$i][1];
$title2 = $GLOBALS['titles_arr'][$i][2];
$title3 = $GLOBALS['titles_arr'][$i][3];
$title4 = $GLOBALS['titles_arr'][$i][4];

if ($type1 == 1)
$title1 = "<a href=\"view_express_ad.php?id=$id1\">$title1</a>";
else
$title1 = "<a href=\"view_express_ad.php?id=$id1\">$title1</a>";

if ($type2 == 1)
$title2 = "<a href=\"view_express_ad.php?id=$id2\">$title2</a>";
else
$title2 = "<a href=\"view_express_ad.php?id=$id2\">$title2</a>";

if ($type3 == 1)
$title3 = "<a href=\"view_express_ad.php?id=$id3\">$title3</a>";
else
$title3 = "<a href=\"view_express_ad.php?id=$id3\">$title3</a>";

if ($type4 == 1)
$title4 = "<a href=\"view_express_ad.php?id=$id4\">$title4</a>";
else
$title4 = "<a href=\"view_express_ad.php?id=$id4\">$title4</a>";

$image1 = $GLOBALS['images_arr'][$i][1];
$image2 = $GLOBALS['images_arr'][$i][2];
$image3 = $GLOBALS['images_arr'][$i][3];
$image4 = $GLOBALS['images_arr'][$i][4];

if ($image1 != "")
if ($type1 == 1)
{
$no = ($i-1)*4+1;
$image1 = "<a href=\"view_express_ad.php?id=$id1\"><img id=\"img$no\" src=\"uploads/$image1\"></a>";
}
else
$image1 = "<a href=\"view_express_ad.php?id=$id1\"><img id=\"img$no\" src=\"uploads/$image1\"></a>";

if ($image2 != "")
if ($type2 == 1)
{
$no = ($i-1)*4+2;
$image2 = "<a href=\"view_express_ad.php?id=$id2\"><img id=\"img$no\" src=\"uploads/$image2\"></a>";
}
else
$image2 = "<a href=\"view_express_ad.php?id=$id2\"><img id=\"img$no\" src=\"uploads/$image2\"></a>";

if ($image3 != "")
if ($type3 == 1)
{
$no = ($i-1)*4+3;
$image3 = "<a href=\"view_express_ad.php?id=$id3\"><img id=\"img$no\" src=\"uploads/$image3\"></a>";
}
else
$image3 = "<a href=\"view_express_ad.php?id=$id3\"><img id=\"img$no\" src=\"uploads/$image3\"></a>";

if ($image4 != "")
if ($type4 == 1)
{
$no = ($i-1)*4+4;
$image4 = "<a href=\"view_express_ad.php?id=$id4\"><img id=\"img$no\" src=\"uploads/$image4\"></a>";
}
else
$image4 = "<a href=\"view_express_ad.php?id=$id4\"><img id=\"img$no\" src=\"uploads/$image4\"></a>";

$stars1 = $GLOBALS['stars_arr'][$i][1];
$stars2 = $GLOBALS['stars_arr'][$i][2];
$stars3 = $GLOBALS['stars_arr'][$i][3];
$stars4 = $GLOBALS['stars_arr'][$i][4];

if ($stars1 != "")
{
if ($type1 == 1)
$stars1 = "<img src=\"images/normal_star.gif\">
$stars1";
else
$stars1 = "<a href=\"view_express_products.php?id=$id1\"><img src=\"images/express_ad.gif\"></a>
$stars1";
}

if ($stars2 != "")
{
if ($type2 == 1)
$stars2 = "<img src=\"images/normal_star.gif\">
$stars2";
else
$stars2 = "<a href=\"view_express_products.php?id=$id2\"><img src=\"images/express_ad.gif\"></a>
$stars2";
}

if ($stars3 != "")
{
if ($type3 == 1)
$stars3 = "<img src=\"images/normal_star.gif\">
$stars3";
else
$stars3 = "<a href=\"view_express_products.php?id=$id3\"><img src=\"images/express_ad.gif\"></a>
$stars3";
}

if ($stars4 != "")
{
if ($type4 == 1)
$stars4 = "<img src=\"images/normal_star.gif\">
$stars4";
else
$stars4 = "<a href=\"view_express_products.php?id=$id4\"><img src=\"images/express_ad.gif\"></a>
$stars4";
}

echo "<TABLE class=picc cellSpacing=0 cellPadding=0 width=\"100%\">\n";
echo "<TBODY>\n";
echo "<TR>\n";
echo "<DIV><TABLE class=picc cellSpacing=0 cellPadding=0 width='100%'> <TBODY><TR><TD class=p width=0%>\n";
echo " <TABLE class=\"pictop\" width=\"100%\">\n";
echo " <TBODY>\n";
echo " <TR>\n";
echo " <TD vAlign=center align=middle width=20 id=\"ads1\">\n";
echo " <span lang=\"fa\">$stars1</span></TD>\n";
echo " <TD height=94 id=\"adp1\">\n";
echo " <span lang=\"fa\">$image1</span></TD>\n";
echo " </TR>\n";
echo " <TR>\n";
echo " <TD class=t2 colSpan=2 id=\"adt1\">\n";
echo " <span lang=\"fa\">$title1</span></TD>\n";
echo " </TR>\n";
echo " </TBODY>\n";
echo " </TABLE>\n";
echo "</TD>\n";
echo "<TD class=p width=0%>\n";
echo " <TABLE class=\"pictop\" width=\"100%\">\n";
echo " <TBODY>\n";
echo " <TR>\n";
echo " <TD vAlign=center align=middle width=20 id=\"ads2\"><span lang=\"fa\">$stars2</span></TD>\n";
echo " <TD height=94 id=\"adp2\">\n";
echo " <span lang=\"fa\">$image2</span></TD>\n";
echo " </TR>\n";
echo " <TR>\n";
echo " <TD class=t2 colSpan=2 id=\"adt2\">\n";
echo " <span lang=\"fa\">$title2</span></TD>\n";
echo " </TR>\n";
echo " </TBODY>\n";
echo " </TABLE>\n";
echo "</TD>\n";
echo "<TD class=p width=0%>\n";
echo " <TABLE class=\"pictop\" width=\"100%\">\n";
echo " <TBODY>\n";
echo " <TR>\n";
echo " <TD vAlign=center id=\"ads3\" align=middle width=20><span lang=\"fa\">$stars3</span></TD>\n";
echo " <TD height=94 id=\"adp3\">\n";
echo " <span lang=\"fa\">$image3</span></TD>\n";
echo " </TR>\n";
echo " <TR>\n";
echo " <TD class=t2 colSpan=2 id=\"adt3\">\n";
echo " <span lang=\"fa\">$title3</span></TD>\n";
echo " </TR>\n";
echo " </TBODY>\n";
echo " </TABLE>\n";
echo "</TD>\n";
echo "<TD class=p width=0%>\n";
echo " <TABLE class=\"pictop\" width=\"100%\">\n";
echo " <TBODY>\n";
echo " <TR>\n";
echo " <TD vAlign=center id=\"ads4\" align=middle width=20><span lang=\"fa\">$stars4</span></TD>\n";
echo " <TD height=94 id=\"adp4\">\n";
echo " <span lang=\"fa\">$image4</span></TD>\n";
echo " </TR>\n";
echo " <TR>\n";
echo " <TD class=t2 colSpan=2 id=\"adt4\">\n";
echo " <span lang=\"fa\">$title4</span></TD>\n";
echo " </TR>\n";
echo " </TBODY>\n";
echo " </TABLE>\n";
echo "</TD>\n";
echo "</TR></TBODY></TABLE>\n"; }

$GLOBALS['html'] = $html;
}
?>

[/php]


Sat Oct 03, 2009 3:04 am
Report this post
Profile
Junior Member

Joined: Sun Sep 13, 2009 4:08 pm
Posts: 54
Location: United States Of America
Post 
Try doing it manually through PHPMyAdmin, not from scratch.


Sat Oct 03, 2009 3:18 pm
Report this post
Profile
Junior Member

Joined: Sat Jun 20, 2009 3:31 am
Posts: 5
Post 
XAMPP_LocalHost wrote:
Try doing it manually through PHPMyAdmin, not from scratch.


hi

If may give more details . Which part of the cod should be changed.

i can not speak english very good.

tank


Tue Oct 06, 2009 1:41 am
Report this post
Profile
Junior Member

Joined: Sun Sep 13, 2009 4:08 pm
Posts: 54
Location: United States Of America
Post 
reza01 wrote:
hi

If may give more details . Which part of the cod should be changed.

i can not speak english very good.

tank


Um the code looks ok, maybe you forgot a ';' somewere, otherwise, the code should be good.


Sun Nov 01, 2009 8:49 am
Report this post
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.