Jump to content

Reading Mysql table but just shows 0


jnerotrix

Recommended Posts

I have a Survey site that im building....

 

It supposed to be if the user has not completed the survey it shows up

 

or else if the user has completed the survey it does not show up.

 

But The Codes i have dont work and just display the number 0

 

Heres the index.php Codes

 

<?php
include("include/session.php");
?>

<html>
<head>

<style>
.shakeimage{
position:relative
}
</style>
<script language="JavaScript1.2">

/*
Shake image script (onMouseover)- 
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

//configure shake degree (where larger # equals greater shake)
var rector=3

///////DONE EDITTING///////////
var stopit=0 
var a=1

function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0
}

function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector
}
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector
}
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector
}
else{
shake.style.left=parseInt(shake.style.left)-rector
}
if (a<4)
a++
else
a=1
setTimeout("rattleimage()",50)
}

function stoprattle(which){
stopit=1
which.style.left=0
which.style.top=0
}

</script>
</head>
<title> EpicBux Survey Site </title>
<body>
<center>
<?php

if($session->logged_in){

?>

<img src="./logo.gif"><br>
<a href="./index.php"><img src="./images/btn-home.gif" border="0" class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this);top.focus()" onClick="top.focus()"></a>
<a href="./advertise.php"><img src="./images/btn-ad.gif" border="0" class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this);top.focus()" onClick="top.focus()"></a>
<a href="./process.php"><img src="./images/btn-logout.gif" border="0" class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this);top.focus()" onClick="top.focus()"></a><br>
<table height="440" width="873" border="1">
<table height="400" width="800" bgcolor="lightgreen" align="center">
<tr>
<td> <b>Welcome<?php echo "$session->username"; ?></td>
<td> <b>EpicBux is aGreat New Survey Site Where you can make money easily online by filling out some simple forms and givind friend refferals links</b>
</td>
</tr>
<tr>
<td><font size="6"> Surveys Available </font></td>
<td>
<?php
mysql_connect("localhost", "sex1800_admin", "PASSWORD") or die(mysql_error()); //add you password
mysql_select_db("sex1800_loginbux") or die(mysql_error());

$query = "SELECT * FROM survey JOIN completed_surveys ON survey.id!=completed_surveys.survey_id WHERE member_id='{$_SESSION['userid']}'";
$result = mysql_query($query) or die(mysql_error());

echo mysql_num_rows($result);

die();
while($row = mysql_fetch_array($result)){
echo "<tr><td><a href=\"survey.php?id={$row['id']}\">{$row['title']}</a></td></tr>";
}
?>



</td></tr>
</table>

<?php
} else {

?>

<img src="./logo.gif"><br>
<a href="./index.php"><img src="./images/btn-home.gif" border="0" class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this);top.focus()" onClick="top.focus()"></a>
<a href="./login.php"><img src="./images/btn-login.gif" border="0" class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this);top.focus()" onClick="top.focus()"></a>
<a href="./advertise.php"><img src="./images/btn-ad.gif" border="0" class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this);top.focus()" onClick="top.focus()"></a>
<a href="./register.php"><img src="./images/btn-signup.gif" border="0" class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this);top.focus()" onClick="top.focus()"></a><br>
<img src="./bgimage.gif">


<?php

}

?>


</body>
</html>

 

Link to comment
https://forums.phpfreaks.com/topic/135961-reading-mysql-table-but-just-shows-0/
Share on other sites

Now it Displays

 

SELECT * FROM survey JOIN completed_surveys ON survey.id!=completed_surveys.survey_id WHERE member_id='91f68a4aa718b312895d10b16af381f4'

 

No Errors Though

 

-----------------------

 

is there like a way of

 

php checks

 

if

 

(mysql database) sex1800_loginbux (table) users (field) userid

 

matches

(mysql database) sex1800_loginbux (table) completed_surveys (field) member_id  ALSO(but Not Check If Matches) survey_id

 

For (table) survey (field) id

 

then if match dont display

 

(mysql database) sex1800_loginbux (table) survey

 

else

 

Do Display

 

(mysql database) sex1800_loginbux (table) survey

 

 

ok simple terms of what must happen

 

php / mysql

 

check if members id matches the completed_surveys(table) member_id(field)

and if it does do not -- display that survey in surveys(table)

 

Do u guys understand what i mean

 

and it checks for each survey

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.