PHP:page.php?id= ????


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting PHP:page.php?id= ????
# 1  
Old 07-08-2003
PHP:page.php?id= ????

Hi, i have this script to read from mysql (layout below) and the script will display the course title, and a url to the id, but when i click on the url it just goes back to that page(displaying all the course titles)but when u click on a course title i want it to read from detail table in php and display all the data in detail. how would i modifie the script to do that??

<html>

<body>

<?php



$db = mysql_connect("localhost", "root");

mysql_select_db("compulearn",$db);

// display individual record

if ($id) {

$result = mysql_query("SELECT * FROM courses WHERE id=$id",$db);

$myrow = mysql_fetch_array($result);

printf("First name: %s\n<br>", $myrow["courses"]);




} else {

// show employee list

$result = mysql_query("SELECT * FROM courses",$db);

if ($myrow = mysql_fetch_array($result)) {

// display list if there are records to display

do {

printf("<a href=\"%s?id=%s\">%s %s</a><br>\n", $PHP_SELF, $myrow["id"], $myrow["courses"], $myrow[""]);

} while ($myrow = mysql_fetch_array($result));

} else {


echo "Sorry, no records were found!";

}

}


MYSQL TABLE

+------+-------------------+-------------------+
| ID | Courses | detail |
+------+--------------------+------------------+
| intro | Intoductions | This course....|
+------+--------------------+------------------+

Please someone tell me.i hope u understand what iam lookin for,.
# 2  
Old 10-01-2003
I'm not sure if this wil solve the problem, but kill the quotes in the array indecies and put them directly into a print() call, like so:

print("<a href=\"$PHP_SELF?id=$myrow[id]$myrow[courses]$myrow[]");

then change the if($id) to if(!isset($id))... come to think of it, that's probably what's wrong. If you were getting a valid URL with fprint(), then disregard the first thing i said...
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Web Development

PHP Changes to WOL for New Forum Home Page

Wrote some PHP code today to make the Who Is Online (WOL) in the forums work properly with the new home page: Wrote this global plugin to add the location to both the user table (for members) and session table (for guests + registered users) <?php if (THIS_SCRIPT != 'misc' and... (0 Replies)
Discussion started by: Neo
0 Replies

2. Shell Programming and Scripting

How to get contents of php page using curl in C language?

Hi, I want to write code in C using curl library to get output of php page , the output is in xml. Thanks (2 Replies)
Discussion started by: nitks.abhinav
2 Replies

3. Shell Programming and Scripting

Web page with picture, text, php function

Hello. I'm trying to create a web page which the presentation is as follows: 1 °) at the top of page an image 2 °) below the text 3 °) to complete a php function that returns information. I tried different things but none work. Script 1: <!DOCTYPE html> <html> <head> <style> div { ... (5 Replies)
Discussion started by: jcdole
5 Replies

4. Shell Programming and Scripting

Downloading processed HTML of PHP page

Hi, I am trying to obtain the HTML code of a PHP page (http:// areferee .com/soccer/test1.php?quiz=50&ran=1&t=5) after the page has been processed; I want pure HTML. Is there a Unix command I can use to do this? I have tried wget, GET, curl but I am getting odd behaviour i.e. it is not... (9 Replies)
Discussion started by: djcas
9 Replies

5. Programming

Modify php script to allow multiple countdowns within one page.

Hi, I have the following php countdown script that counts down to a date and time. Please see the below example: <SCRIPT language="JavaScript" SRC="countdown.php?timezone=US/Pacific&countto=2011-06-25 00:00:00&do=t&data=Sorry, This Offer Has Expired."></SCRIPT> And countdown.php: ... (1 Reply)
Discussion started by: rocket_dog
1 Replies

6. UNIX for Dummies Questions & Answers

Integrating bash script into php (page)

I have written a bash script...now i need to call the script from php page. Can you give me an example to demonstrate how it is done?:( (1 Reply)
Discussion started by: xerox
1 Replies

7. Web Development

I can't open my index.php page after insert php code

Hello guys, Does anyone can help me? I've just made my simple index.php without any code, but after insert session code to check if any user is authenticated, my index.php doesn't work anymore. Any fresh eyes could help me to see what and where the code is wrong? <? if... (6 Replies)
Discussion started by: metalfreakbr
6 Replies
Login or Register to Ask a Question