Uutiset:

Join the Facebook Fan Page.

Main Menu
Advertisement:

Help with ssi_showpoll()

Aloittaja sledge4, maaliskuu 08, 2007, 11:15:22 AP

« edellinen - seuraava »

sledge4

I am trying to set a poll on my homepage that can be changed weekly via a MySQL database.

Example, I can add <?php ssi_showPoll('1176'); ?> to my page where I want to display the poll, but that means weekly someone needs to go into the code and change the value to show a new poll.  For me personally, it's a non-issue, but I have a couple other people helping me that aren't so PHP/HTML savy and could mess things up when attempting to change the 1176 value.

I'm not a PHP expert and I am struggling on how to have that value pull from a database field. Here's what I have, but obviously it's not working.  I believe it's because you can't have php tags inside an echo tag?

<?
$sql = ("SELECT value FROM polls WHERE type='hotm' ") ;
$result = mysql_query ($sql);

while($row = mysql_fetch_array($result))
  {
  echo "<?php ssi_showPoll('value'); ?>" ;
  echo "<br />";
  }

?>

Any advice is greatly appreciated.

Thanks,
Will

sledge4


twistedsymphony

#2
just change this line: echo "<?php ssi_showPoll('value'); ?>" ;
to this: ssi_showPoll('value');

the function you're calling doesn't produce a value it produces an echo itself... also you're already in PHP script mode so there is no need for the <?php tags (that's only if you're placing this alone inside of some HTML).

after that I still don't think it will work because you're sending it a topic id of "value" (as in the actual text  v a l u e) not the actual VALUE of the result.

if you're returning an array it would be more like $result['value'] or $row['value'] where 'value' is the name of the field you want in the result set (it might change depending on your select statement).
your database code could use a bit of work as well.

Advertisement: