help with pagination and html radio buttons

This is a discussion on "help with pagination and html radio buttons" within the PHP Forum section. This forum, and the thread "help with pagination and html radio buttons are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jul 22nd, 2006, 23:21
AdRock's Avatar
SuperMember

SuperMember
Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to AdRock
help with pagination and html radio buttons

Can anyone please help me insert this line of html and javascript into my php code?

I have a radio button which when clicked will open deletenews.php
I want to put that in the php code so every record will have the radio button next to it so it can be deleted.



Code: Select all
<input style="border:none;" type="radio" name="loc" onClick="go('index.php?page=deletenews');">


PHP: Select all

while($code mysql_fetch_object($q)) { 
     echo(
"<h3>".$code->title."</h3><BR>");} 
I have escaped the quotes (\") but I am getting an error. It says Parse error: syntax error, unexpected '>' in ........on line 47

I am sure it's the $code->title part causing the error and don't know how to get around it

Here is the entire script that works correctly before any changes have been made.

PHP: Select all

 <? 
//REMEMBER TO CONNECT TO DATABASE! include_once("../includes/connection.php");
    
@mysql_connect($host$user$password) or die("ERROR--CAN'T CONNECT TO SERVER"); 
    @
mysql_select_db($database) or die("ERROR--CAN'T CONNECT TO DB"); 
//**EDIT TO YOUR TABLE NAME, ECT. $t = mysql_query("SELECT * FROM `news`"); 
  
if(!$t) die(mysql_error()); 
    
$a                mysql_fetch_object($t); 
$total_items      mysql_num_rows($t); 
$limit            $_GET['limit']; 
$type             $_GET['type']; 
$page             $_GET['pagenum']; //set default if: $limit is empty, non numerical, less than 2, greater than 50 
if((!$limit)  || (is_numeric($limit) == false) || ($limit 2) || ($limit 50)) { 
     
$limit 2//default 

//set default if: $page is empty, non numerical, less than zero, greater than total available 
if((!$page) || (is_numeric($page) == false) || ($page 0) || ($page $total_items)) { 
      
$page 1//default 
//calcuate total pages 
$total_pages     ceil($total_items $limit); 
$set_limit          $page $limit - ($limit); //query: **EDIT TO YOUR TABLE NAME, ECT. $q = mysql_query("SELECT * FROM `news` LIMIT $set_limit, $limit"); 
  
if(!$q) die(mysql_error()); 
     
$err mysql_num_rows($q); 
       if(
$err == 0) die("No matches met your criteria."); //Results per page: **EDIT LINK PATH** 
echo("   
<a href=?page=delete_news&limit=10&amp;pagenum=1></a> 
<a href=?page=delete_news&limit=25&amp;pagenum=1></a> 
<a href=?page=delete_news&limit=50&amp;pagenum=1></a>"
); //show data matching query: 
while($code mysql_fetch_object($q)) { 
     echo(
"<h3>".$code->title."</h3><BR>");
$id urlencode($id); //makes browser friendly //prev. page: **EDIT LINK PATH** $prev_page = $page - 1; if($prev_page >= 1) { 
  
echo("<b>&lt;&lt;</b> <a href=?page=delete_news&limit=$limit&amp;pagenum=$prev_page><b>Prev.</b></a>"); 
//Display middle pages: **EDIT LINK PATH** for($a = 1; $a <= $total_pages; $a++) 

   if(
$a == $page) { 
      echo(
"<b> $a</b> | "); //no link 
     
} else { 
  echo(
"  <a href=?page=delete_news&limit=$limit&amp;pagenum=$a> $a </a> | "); 
     } 
//next page: **EDIT THIS LINK PATH** $next_page = $page + 1; 
if($next_page <= $total_pages) { 
   echo(
"<a href=?page=delete_news&limit=$limit&amp;pagenum=$next_page><b>Next</b></a> &gt; &gt;"); 
//all done 
?>
Reply With Quote

  #2 (permalink)  
Old Jul 23rd, 2006, 09:58
Up'n'Coming Member
Join Date: Jan 2006
Location: East Sussex
Age: 26
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
Re: help with pagination and html radio buttons

while($code = mysql_fetch_object($q)) {
echo(
"<h3>
<input style=\"border:none;\" type=\"radio\" name=\"loc\" onClick=\"go(\'index.php?page=deletenews\');\">".$code->title."</h3><BR>");
}

Should work fine, if you want to delete a certain title only you will need to pass that in the javascript function as well probably dont forget.
Good luck
.
Reply With Quote
  #3 (permalink)  
Old Jul 24th, 2006, 13:16
AdRock's Avatar
SuperMember

SuperMember
Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to AdRock
Re: help with pagination and html radio buttons

Thanks.....that works fine for another page I'm doing where there is no deleting etc but how do i delete a certain item

I have tried this
PHP: Select all

echo("<input style=\"border:none;\" type=\"radio\" name=\"loc\" onClick=\"go(\'deletenews.php?id=<? echo $code[id]; ?>\');\">".$code->title."<BR>");
and it reports T_BAD_CHARACTER.

Is it to do with the \'deletenews.php?id=<? echo $code[\'id\']; ?>\' bit? if so how do i replace it correctly?

Many thanks for helping me sort this problem
Reply With Quote
  #4 (permalink)  
Old Jul 25th, 2006, 15:59
benbacardi's Avatar
Highly Reputable Member
Join Date: Feb 2004
Location: United Kingdom
Age: 20
Posts: 611
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to benbacardi Send a message via Skype™ to benbacardi
Re: help with pagination and html radio buttons

replace that line with:

PHP: Select all

echo("<input style=\"border:none;\" type=\"radio\" name=\"loc\" onClick=\"go(\'deletenews.php?id=".$code['id']."\');\">".$code->title."<BR>"); 

Reply With Quote
  #5 (permalink)  
Old Jul 25th, 2006, 21:02
AdRock's Avatar
SuperMember

SuperMember
Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to AdRock
Re: help with pagination and html radio buttons

I did what you said and now I get the error message syntax error, unexpected $end
Reply With Quote
  #6 (permalink)  
Old Jul 27th, 2006, 12:10
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: help with pagination and html radio buttons

I suspect one of the unescaped double quotes.
Reply With Quote
Reply

Tags
help, pagination, html, radio, buttons

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Help with Radio buttons Oak JavaScript Forum 17 Feb 2nd, 2008 09:44
Radio Buttons and Javascript activeware JavaScript Forum 6 Dec 11th, 2007 18:02
Radio Buttons data through email gomab2 Flash & Multimedia Forum 1 Aug 22nd, 2006 01:19
Radio buttons and mandatory fields joshcxa JavaScript Forum 1 Aug 8th, 2006 10:30
Radio Buttons redhead Web Page Design 2 Apr 12th, 2004 19:00


All times are GMT. The time now is 11:49.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43