Current location: Hot Scripts Forums » Programming Languages » PHP » a little assitance with my php an sql


a little assitance with my php an sql

Reply
  #1 (permalink)  
Old 12-19-06, 09:03 PM
pkcidstudio's Avatar
pkcidstudio pkcidstudio is offline
Coding Addict
 
Join Date: Nov 2005
Posts: 332
Thanks: 0
Thanked 0 Times in 0 Posts
a little assitance with my php an sql

What I am trying to do is, call a row from my table and allow there to be numbers to select different rows, or the user can hit next. but for some reason I am not able to get the information to appear, and am reciving this error.
Code:
Parse error: syntax error, unexpected ';' in /misc/20/103/291/210/0/user/web/uorf.org/new/example.php on line 18
and here is my code. any thoughts? please assist.
PHP Code:

<?php
include("_php/config.php");
// database connection stuff here
$rows_per_page 1;
$sql "SELECT * FROM sponsor WHERE checkSponsorChild='no'";
$result mysql_query($sql);
$total_records mysql_num_rows($result);
$pages ceil($total_records $rows_per_page);
//mysql_free_result($result);
if (!isset($screen))
  
$screen 0;
$start $screen $rows_per_page;
//$sql = "SELECT * FROM sponsor ";
$sql .= "LIMIT $start$rows_per_page";
$result mysql_query($sql);
$rows mysql_num_rows($result);
while (
$i 0$i $rows$i++) {
  
$childrenInfo mysql_fetch_array($result$i0);
  
//$description = mysql_result($result, $i, 0);
  
echo "\t\t"$childrenInfo['childsName'] ."\r\n";
  
//echo "\$description = $description<br>\n";
mysql_free_result($result);
}
echo 
"<p><hr></p>\n";
// let's create the dynamic links now
if ($screen 0) {
  
$url "example.php?screen=" $screen 1;
  echo 
"<a href=\"$url\">Previous</a>\n";
}
// page numbering links now
for ($i 0$i $pages$i++) {
  
$url "example.php?screen=" $i;
  echo 
" | <a href=\"$url\">$i</a> | ";
}
if (
$screen $pages) {
  
$url "example.php?screen=" $screen 1;
  echo 
"<a href=\"$url\">Next</a>\n";
}
?>
I think I am probolly just misusing a function, and or missing a ";" thankx agian for your help.
__________________
learning like everyone else
Reply With Quote
  #2 (permalink)  
Old 12-19-06, 11:19 PM
YourPHPPro's Avatar
YourPHPPro YourPHPPro is offline
Community VIP
 
Join Date: Aug 2003
Posts: 430
Thanks: 0
Thanked 0 Times in 0 Posts
You use 'while' on line 18 when I think you mean 'for'

http://us2.php.net/while

http://us2.php.net/manual/en/control-structures.for.php
Reply With Quote
  #3 (permalink)  
Old 12-20-06, 07:55 AM
pkcidstudio's Avatar
pkcidstudio pkcidstudio is offline
Coding Addict
 
Join Date: Nov 2005
Posts: 332
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by YourPHPPro
You use 'while' on line 18 when I think you mean 'for'
YourPHPPro, when using "for" I only get 1 letter or 1 number for instance; say the word "frenchfry" is in my databse, when using "for" I only recive "f", instead of "frenchfry". any thoughts? maybe I am using the wrong call to with the "for". thank you for your help, I look to here what you or anyone else has to say.
__________________
learning like everyone else
Reply With Quote
  #4 (permalink)  
Old 12-20-06, 08:04 AM
YourPHPPro's Avatar
YourPHPPro YourPHPPro is offline
Community VIP
 
Join Date: Aug 2003
Posts: 430
Thanks: 0
Thanked 0 Times in 0 Posts
Well, the original problem - parse error - was solved, but for people to assist with your new question, it would be good for you to - at least - list the schema for the databases/tables and explain in detail what you want the program to do...
Reply With Quote
  #5 (permalink)  
Old 12-20-06, 08:06 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
EDIT:

A bit too late...

Try,

PHP Code:

while ($childrenInfo mysql_fetch_array($result))

{
  echo 
"\t\t"$childrenInfo['childsName'] ."\r\n";
  
//echo "\$description = $description<br>\n";
}

mysql_free_result($result); 
Reply With Quote
  #6 (permalink)  
Old 12-20-06, 08:24 AM
pkcidstudio's Avatar
pkcidstudio pkcidstudio is offline
Coding Addict
 
Join Date: Nov 2005
Posts: 332
Thanks: 0
Thanked 0 Times in 0 Posts
What the script is suppose to do is display the data, similar to the way Nico used the while script, (that part now works Thank you nico) but also with the "for" section should allow the user to go forward and backword in the database.

Details:

This site is for an orphange, and it will have probolly 100 kids in it at a time.
Table = sponsor
row in table = childsName
row in table = childsAge
...

I need the ability for a user to cycle through the orphans on the database, which is where the
PHP Code:

for($i 0$i $rows$i++) { 

I was trying to use this to allow the user to go to next or previus in the databse.


This is how i was trying to do the next and previus buttons.
PHP Code:

 
if ($screen 0) {
 
$url "example.php?screen=" $screen 1;
 
echo 
"<a href=\"$url\">Previous</a>\n";
 
}
 
// page numbering links now
 
for ($i 0$i $pages$i++) {
 
$url "example.php?screen=" $i;
 
echo 
" | <a href=\"$url\">$i</a> | ";
 
}
 
if (
$screen $pages) {
 
$url "example.php?screen=" $screen 1;
 
echo 
"<a href=\"$url\">Next</a>\n";
 



Hope this helps to explain what I am trying to do., thanks for the help agian.
__________________
learning like everyone else

Last edited by pkcidstudio; 12-20-06 at 08:27 AM.
Reply With Quote
  #7 (permalink)  
Old 12-20-06, 08:44 AM
YourPHPPro's Avatar
YourPHPPro YourPHPPro is offline
Community VIP
 
Join Date: Aug 2003
Posts: 430
Thanks: 0
Thanked 0 Times in 0 Posts
Reply With Quote
  #8 (permalink)  
Old 12-20-06, 08:48 AM
pkcidstudio's Avatar
pkcidstudio pkcidstudio is offline
Coding Addict
 
Join Date: Nov 2005
Posts: 332
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for the sites, but would rather not get into a third party. Thank you though.
__________________
learning like everyone else
Reply With Quote
  #9 (permalink)  
Old 12-20-06, 10:23 AM
pkcidstudio's Avatar
pkcidstudio pkcidstudio is offline
Coding Addict
 
Join Date: Nov 2005
Posts: 332
Thanks: 0
Thanked 0 Times in 0 Posts
Has anyone ever done this with out a third party? If so, If you could help it would be much appreciated. Thank you in advance.
__________________
learning like everyone else
Reply With Quote
  #10 (permalink)  
Old 12-20-06, 07:40 PM
pkcidstudio's Avatar
pkcidstudio pkcidstudio is offline
Coding Addict
 
Join Date: Nov 2005
Posts: 332
Thanks: 0
Thanked 0 Times in 0 Posts
So I got it to display the kids names, thank you to all really am thankful.
Now I am having trouble with the next button working, it doesnt seem to be grabing the next child in line. any thoughts? also the previous is not showing up? Thank you in advance.
PHP Code:

<?php
include("_php/config.php");
// database connection stuff here
$rows_per_page 1;
$sql "SELECT * FROM sponsor WHERE checkSponsorChild='no'";
$result mysql_query($sql);
$total_records mysql_num_rows($result);
$pages ceil($total_records $rows_per_page);
//mysql_free_result($result);
if (!isset($screen))
  
$screen 0;
$start $screen $rows_per_page;
//$sql = "SELECT * FROM sponsor ";
$sql .= "LIMIT $start$rows_per_page";
$result mysql_query($sql);
$rows mysql_num_rows($result);
//this might be gone
//for ($i = 0; $i < $rows; $i++) {
//this might be gone

//test
$i0;
while (
$i $rows){
//test
//reset ($childrenInfo);
 
while ($childrenInfo mysql_fetch_array($result)) 
 
//$description = mysql_result($result, $i, 0);

  echo 
"\t\t"$childrenInfo['childsName'] ."\r\n"
  
//echo "\$description = $description<br>\n"; 

$i++;
//return $children;

//$i++; try this if above doesnt work
}
//test

mysql_free_result($result); 

echo 
"<p><hr></p>\n";
// let's create the dynamic links now
if ($screen 0) {
  
$url "example.php?screen=" $screen 1;
  echo 
"<a href=\"$url\">Previous</a>\n";
}
// page numbering links now
/*for ($i = 0; $i < $pages; $i++) {
  $url = "example.php?screen=" . $i;
  echo " | <a href=\"$url\">$i</a> | ";
}*/
if ($screen $pages) {
  
$url "example.php?screen=" $screen 1;
  echo 
"<a href=\"$url\">Next</a>\n";
}
?>
What should be happening: when user clicks next it selects the next child in line. same with previous, selects the past child. Thank you for your help agian.
__________________
learning like everyone else
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Split data in php from sql? ( usinf | ) ? NabZ PHP 1 04-03-06 03:51 PM
Trying to echo PHP code from SQL and run it. And failing. Sheldon PHP 4 08-01-05 11:22 AM
PHP multi-dimensional array sorting issue aqw PHP 2 06-24-05 11:09 PM
HOT! icon script needed (php no SQL) jayz Script Requests 0 05-02-05 07:11 PM
change my field in this example sal21 ASP 3 07-14-03 02:49 AM


All times are GMT -5. The time now is 05:50 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.