help with variable
Posted on
16th Feb 2014 07:03 pm by
admin
I've got a problem, i want to echo some images depending on the $id, however for me to get that id i have to extract it from a query. So i've done that, but i want to extract all id's (not just 1), so i can echo images for all them ids (not just echo the images based on 1 id), so I did a while() loop, however doesnt seem to work
My code:
Code: <?php
include "connect.php";
$user = "Peter";
$sql = mysql_query("select * from game_main where user = '$user'");
while($row = mysql_fetch_array($sql)){
$id = $row['id'];
}
//do i have to do foreach $id as something??
$views = mysql_num_rows(mysql_query("SELECT userip FROM game_views WHERE sub_id = '$id'"));
$sql3 = mysql_query("select monthstamp from game_monthlyfeatured where first = '$id'");
$num3 = mysql_num_rows($sql3);
$sql4 = mysql_query("select weekstamp from game_weeklyfeatured where first = '$id'");
$num4 = mysql_num_rows($sql4);
$sql5 = mysql_query("select daystamp from game_dailyfeatured where first = '$id'");
$num5 = mysql_num_rows($sql5);
$sql6 = mysql_query("select date from site_featured where id = '$id'");
$num6 = mysql_num_rows($sql6);
if($num3 == 1) {
?>
<img src="../images2/game/game_awards_1monthly.gif" width="20" height="20" />
<?php
}
if($num4 == 1) {
?>
<img src="../images2/game/game_awards_topweekly.gif" width="20" height="20" />
<?php
}
if($num5 == 1) {
?>
<img src="../images2/game/game_awards_topdaily.gif" width="20" height="20" />
<?php
}
if ($views > 1000) {
?>
<img src="../images2/game/game_awards_1000views.gif" width="20" height="20" />
<?php
}
if ($views > 25000) {
?>
<img src="../images2/game/game_awards_25000views.gif" width="20" height="20" />
<?php
}
if ($num6 > 0) {
?>
<img src="../images2/game/game_awards_modpick.png" width="16" height="16" />
<?php
}
?>
Hope someone can help, thanks
No comments posted yet
Your Answer:
Login to answer
140
26
Other forums
PHP url branch??
Functionally, using PHP, I'm doing a test of login input submitted by a user via an html form in a f
mysql timestamp manipulation
How could I use a timestamp (e.g 2009-10-30 13:20:35 ), and with php find out if it is:
from
Is there a function ... auto send IP
Is there some function that can be sent to a ddns service that returns the ip address of a ddns forw
phph within href not showing php if change ? to &
Code: [Select]<a href="<?php echo $puser; ?>?m=<?php=(($m-1)&l
php automatically escaping single quotes
I'm trying to test out my security a bit and I've noticed that php is escaping my single quotes. For
use an array from 1 class in a second class
I have a class that adds data to an array
Then I have a second class and I need to check if t
SAP FICO learning materials
Hi all,
I am new to this world of SAP FICO. I have taken training on SAP FICO, but was wonderin
Do not allow posting of whitespace
Currently the script below works if the user does not type a name/message, but if i create a whitesp
url- go to webpage
i have an input text field and submit button.
how do i make the url entered into the textfiel
Contact Form Not Working When I Add Validation Codes
So I built my first working PHP "Contact Us" like form. But, I have been trying to now mak