Jump to content

Recommended Posts

[php:1:b3cecffc86]<?

@ $db = mysql_pconnect(\"localhost\");

 

if (!$db)

{

echo \"Error: Could not connect to database. Please try again later.\";

exit;

}

 

mysql_select_db(\"mysql\");

$manga_sql = \"select * from manga

where title is not null

order by title desc\";

 

$manga_result = mysql_query($manga_sql);

if (mysql_num_rows($manga_result)) {

 

$manga = mysql_fetch_array($manga_result);

echo \"<a href=\"review.php?id=$manga[id]\">\";

echo $manga[title];

echo \"</a>\";

 

}

 

 

?>

 

This is the mysql query that is run on index.php. It displays all the reviews I have in a databse and visitors are then sent to review.php (the code for it shown below) which displays the review they queried.

 

<?php

 

/* just to be safe with register globals */

$id =& $HTTP_GET_VARS[\'id\'];

 

$sql = \'SELECT *

FROM manga

WHERE id=\'.$id;

 

/* then run the query and get the results etc... */

 

?>

[/php:1:b3cecffc86]

 

How would I integrate the two codes on to one single php file so the original mysql query and the query that is selected is on the same php page?

Give this a shot. Haven\'t tested it but it should work

 

[php:1:0fd7680877]<?php

@ $db = mysql_pconnect(\"localhost\");

 

if (!$db)

{

echo \"Error: Could not connect to database. Please try again later.\";

exit;

}

 

$id = $HTTP_GET_VARS[\'id\'];

 

if ((!$id) || ($id = \'\'))

{

mysql_select_db(\"mysql\");

$manga_sql = \"select * from manga

where title is not null

order by title desc\";

 

$manga_result = mysql_query($manga_sql);

if (mysql_num_rows($manga_result))

{

 

$manga = mysql_fetch_array($manga_result);

echo \"<a href=\"review.php?id=$manga[id]\">\";

echo $manga[title];

echo \"</a>\";

 

}

 

} else {

 

$sql = \'SELECT * FROM manga WHERE id=\'.$id;

 

/* then run the query and get the results etc... */

 

}

?>

[/php:1:0fd7680877]

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.